Commit cb2b6208 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: mac53c94: Move the SCSI pointer to private command data

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-32-bvanassche@acm.orgReviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 8c0156b1
...@@ -193,7 +193,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -193,7 +193,8 @@ static void mac53c94_interrupt(int irq, void *dev_id)
struct fsc_state *state = (struct fsc_state *) dev_id; struct fsc_state *state = (struct fsc_state *) dev_id;
struct mac53c94_regs __iomem *regs = state->regs; struct mac53c94_regs __iomem *regs = state->regs;
struct dbdma_regs __iomem *dma = state->dma; struct dbdma_regs __iomem *dma = state->dma;
struct scsi_cmnd *cmd = state->current_req; struct scsi_cmnd *const cmd = state->current_req;
struct scsi_pointer *const scsi_pointer = mac53c94_scsi_pointer(cmd);
int nb, stat, seq, intr; int nb, stat, seq, intr;
static int mac53c94_errors; static int mac53c94_errors;
...@@ -263,10 +264,10 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -263,10 +264,10 @@ static void mac53c94_interrupt(int irq, void *dev_id)
/* 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
&& (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) { && (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
nb = cmd->SCp.this_residual; nb = scsi_pointer->this_residual;
if (nb > 0xfff0) if (nb > 0xfff0)
nb = 0xfff0; nb = 0xfff0;
cmd->SCp.this_residual -= nb; scsi_pointer->this_residual -= nb;
writeb(nb, &regs->count_lo); writeb(nb, &regs->count_lo);
writeb(nb >> 8, &regs->count_mid); writeb(nb >> 8, &regs->count_mid);
writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); writeb(CMD_DMA_MODE + CMD_NOP, &regs->command);
...@@ -293,13 +294,13 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -293,13 +294,13 @@ static void mac53c94_interrupt(int irq, void *dev_id)
cmd_done(state, DID_ERROR << 16); cmd_done(state, DID_ERROR << 16);
return; return;
} }
if (cmd->SCp.this_residual != 0 if (scsi_pointer->this_residual != 0
&& (stat & (STAT_MSG|STAT_CD)) == 0) { && (stat & (STAT_MSG|STAT_CD)) == 0) {
/* Set up the count regs to transfer more */ /* Set up the count regs to transfer more */
nb = cmd->SCp.this_residual; nb = scsi_pointer->this_residual;
if (nb > 0xfff0) if (nb > 0xfff0)
nb = 0xfff0; nb = 0xfff0;
cmd->SCp.this_residual -= nb; scsi_pointer->this_residual -= nb;
writeb(nb, &regs->count_lo); writeb(nb, &regs->count_lo);
writeb(nb >> 8, &regs->count_mid); writeb(nb >> 8, &regs->count_mid);
writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); writeb(CMD_DMA_MODE + CMD_NOP, &regs->command);
...@@ -321,8 +322,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -321,8 +322,8 @@ static void mac53c94_interrupt(int irq, void *dev_id)
cmd_done(state, DID_ERROR << 16); cmd_done(state, DID_ERROR << 16);
return; return;
} }
cmd->SCp.Status = readb(&regs->fifo); scsi_pointer->Status = readb(&regs->fifo);
cmd->SCp.Message = readb(&regs->fifo); scsi_pointer->Message = readb(&regs->fifo);
writeb(CMD_ACCEPT_MSG, &regs->command); writeb(CMD_ACCEPT_MSG, &regs->command);
state->phase = busfreeing; state->phase = busfreeing;
break; break;
...@@ -330,8 +331,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) ...@@ -330,8 +331,8 @@ static void mac53c94_interrupt(int irq, void *dev_id)
if (intr != INTR_DISCONNECT) { if (intr != INTR_DISCONNECT) {
printk(KERN_DEBUG "got intr %x when expected disconnect\n", intr); printk(KERN_DEBUG "got intr %x when expected disconnect\n", intr);
} }
cmd_done(state, (DID_OK << 16) + (cmd->SCp.Message << 8) cmd_done(state, (DID_OK << 16) + (scsi_pointer->Message << 8)
+ cmd->SCp.Status); + scsi_pointer->Status);
break; break;
default: default:
printk(KERN_DEBUG "don't know about phase %d\n", state->phase); printk(KERN_DEBUG "don't know about phase %d\n", state->phase);
...@@ -389,7 +390,7 @@ static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd) ...@@ -389,7 +390,7 @@ static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd)
dma_cmd += OUTPUT_LAST - OUTPUT_MORE; dma_cmd += OUTPUT_LAST - OUTPUT_MORE;
dcmds[-1].command = cpu_to_le16(dma_cmd); dcmds[-1].command = cpu_to_le16(dma_cmd);
dcmds->command = cpu_to_le16(DBDMA_STOP); dcmds->command = cpu_to_le16(DBDMA_STOP);
cmd->SCp.this_residual = total; mac53c94_scsi_pointer(cmd)->this_residual = total;
} }
static struct scsi_host_template mac53c94_template = { static struct scsi_host_template mac53c94_template = {
...@@ -401,6 +402,7 @@ static struct scsi_host_template mac53c94_template = { ...@@ -401,6 +402,7 @@ static struct scsi_host_template mac53c94_template = {
.this_id = 7, .this_id = 7,
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.max_segment_size = 65535, .max_segment_size = 65535,
.cmd_size = sizeof(struct mac53c94_cmd_priv),
}; };
static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match) static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match)
......
...@@ -212,4 +212,15 @@ struct mac53c94_regs { ...@@ -212,4 +212,15 @@ struct mac53c94_regs {
#define CF4_TEST 0x02 #define CF4_TEST 0x02
#define CF4_BBTE 0x01 #define CF4_BBTE 0x01
struct mac53c94_cmd_priv {
struct scsi_pointer scsi_pointer;
};
static inline struct scsi_pointer *mac53c94_scsi_pointer(struct scsi_cmnd *cmd)
{
struct mac53c94_cmd_priv *mcmd = scsi_cmd_priv(cmd);
return &mcmd->scsi_pointer;
}
#endif /* _MAC53C94_H */ #endif /* _MAC53C94_H */
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