Commit 646158c2 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] mac53c94: convert to use the data buffer accessors

- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 5f60ef6a
...@@ -77,7 +77,7 @@ static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd * ...@@ -77,7 +77,7 @@ static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *
for (i = 0; i < cmd->cmd_len; ++i) for (i = 0; i < cmd->cmd_len; ++i)
printk(" %.2x", cmd->cmnd[i]); printk(" %.2x", cmd->cmnd[i]);
printk("\n" KERN_DEBUG "use_sg=%d request_bufflen=%d request_buffer=%p\n", printk("\n" KERN_DEBUG "use_sg=%d request_bufflen=%d request_buffer=%p\n",
cmd->use_sg, cmd->request_bufflen, cmd->request_buffer); scsi_sg_count(cmd), scsi_bufflen(cmd), scsi_sglist(cmd));
} }
#endif #endif
...@@ -173,8 +173,7 @@ static void mac53c94_start(struct fsc_state *state) ...@@ -173,8 +173,7 @@ static void mac53c94_start(struct fsc_state *state)
writeb(CMD_SELECT, &regs->command); writeb(CMD_SELECT, &regs->command);
state->phase = selecting; state->phase = selecting;
if (cmd->use_sg > 0 || cmd->request_bufflen != 0) set_dma_cmds(state, cmd);
set_dma_cmds(state, cmd);
} }
static irqreturn_t do_mac53c94_interrupt(int irq, void *dev_id) static irqreturn_t do_mac53c94_interrupt(int irq, void *dev_id)
...@@ -262,7 +261,7 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -262,7 +261,7 @@ static void mac53c94_interrupt(int irq, void *dev_id)
writeb(CMD_NOP, &regs->command); writeb(CMD_NOP, &regs->command);
/* set DMA controller going if any data to transfer */ /* set DMA controller going if any data to transfer */
if ((stat & (STAT_MSG|STAT_CD)) == 0 if ((stat & (STAT_MSG|STAT_CD)) == 0
&& (cmd->use_sg > 0 || cmd->request_bufflen != 0)) { && (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
nb = cmd->SCp.this_residual; nb = cmd->SCp.this_residual;
if (nb > 0xfff0) if (nb > 0xfff0)
nb = 0xfff0; nb = 0xfff0;
...@@ -310,14 +309,7 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -310,14 +309,7 @@ static void mac53c94_interrupt(int irq, void *dev_id)
printk(KERN_DEBUG "intr %x before data xfer complete\n", intr); printk(KERN_DEBUG "intr %x before data xfer complete\n", intr);
} }
writel(RUN << 16, &dma->control); /* stop dma */ writel(RUN << 16, &dma->control); /* stop dma */
if (cmd->use_sg != 0) { scsi_dma_unmap(cmd);
pci_unmap_sg(state->pdev,
(struct scatterlist *)cmd->request_buffer,
cmd->use_sg, cmd->sc_data_direction);
} else {
pci_unmap_single(state->pdev, state->dma_addr,
cmd->request_bufflen, cmd->sc_data_direction);
}
/* should check dma status */ /* should check dma status */
writeb(CMD_I_COMPLETE, &regs->command); writeb(CMD_I_COMPLETE, &regs->command);
state->phase = completing; state->phase = completing;
...@@ -365,47 +357,35 @@ static void cmd_done(struct fsc_state *state, int result) ...@@ -365,47 +357,35 @@ static void cmd_done(struct fsc_state *state, int result)
*/ */
static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd) static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd)
{ {
int i, dma_cmd, total; int i, dma_cmd, total, nseg;
struct scatterlist *scl; struct scatterlist *scl;
struct dbdma_cmd *dcmds; struct dbdma_cmd *dcmds;
dma_addr_t dma_addr; dma_addr_t dma_addr;
u32 dma_len; u32 dma_len;
nseg = scsi_dma_map(cmd);
BUG_ON(nseg < 0);
if (!nseg)
return;
dma_cmd = cmd->sc_data_direction == DMA_TO_DEVICE ? dma_cmd = cmd->sc_data_direction == DMA_TO_DEVICE ?
OUTPUT_MORE : INPUT_MORE; OUTPUT_MORE : INPUT_MORE;
dcmds = state->dma_cmds; dcmds = state->dma_cmds;
if (cmd->use_sg > 0) { total = 0;
int nseg;
scsi_for_each_sg(cmd, scl, nseg, i) {
total = 0; dma_addr = sg_dma_address(scl);
scl = (struct scatterlist *) cmd->request_buffer; dma_len = sg_dma_len(scl);
nseg = pci_map_sg(state->pdev, scl, cmd->use_sg, if (dma_len > 0xffff)
cmd->sc_data_direction); panic("mac53c94: scatterlist element >= 64k");
for (i = 0; i < nseg; ++i) { total += dma_len;
dma_addr = sg_dma_address(scl); st_le16(&dcmds->req_count, dma_len);
dma_len = sg_dma_len(scl); st_le16(&dcmds->command, dma_cmd);
if (dma_len > 0xffff)
panic("mac53c94: scatterlist element >= 64k");
total += dma_len;
st_le16(&dcmds->req_count, dma_len);
st_le16(&dcmds->command, dma_cmd);
st_le32(&dcmds->phy_addr, dma_addr);
dcmds->xfer_status = 0;
++scl;
++dcmds;
}
} else {
total = cmd->request_bufflen;
if (total > 0xffff)
panic("mac53c94: transfer size >= 64k");
dma_addr = pci_map_single(state->pdev, cmd->request_buffer,
total, cmd->sc_data_direction);
state->dma_addr = dma_addr;
st_le16(&dcmds->req_count, total);
st_le32(&dcmds->phy_addr, dma_addr); st_le32(&dcmds->phy_addr, dma_addr);
dcmds->xfer_status = 0; dcmds->xfer_status = 0;
++dcmds; ++dcmds;
} }
dma_cmd += OUTPUT_LAST - OUTPUT_MORE; dma_cmd += OUTPUT_LAST - OUTPUT_MORE;
st_le16(&dcmds[-1].command, dma_cmd); st_le16(&dcmds[-1].command, dma_cmd);
st_le16(&dcmds->command, DBDMA_STOP); st_le16(&dcmds->command, DBDMA_STOP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment