提交 84ac86ca 编写于 作者: B Boaz Harrosh 提交者: James Bottomley

[SCSI] arm: convert to accessors and !use_sg cleanup

 - convert to accessors and !use_sg cleanup
Signed-off-by: NBoaz Harrosh <bharrosh@panasas.com>
Tested-by: NRussell King <rmk@arm.linux.org.uk>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 c9e86b8b
...@@ -1790,7 +1790,7 @@ int acornscsi_starttransfer(AS_Host *host) ...@@ -1790,7 +1790,7 @@ int acornscsi_starttransfer(AS_Host *host)
return 0; return 0;
} }
residual = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred; residual = scsi_bufflen(host->SCpnt) - host->scsi.SCp.scsi_xferred;
sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer);
sbic_arm_writenext(host->scsi.io_port, residual >> 16); sbic_arm_writenext(host->scsi.io_port, residual >> 16);
...@@ -2270,7 +2270,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2270,7 +2270,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4b: /* -> PHASE_STATUSIN */ case 0x4b: /* -> PHASE_STATUSIN */
case 0x8b: /* -> PHASE_STATUSIN */ case 0x8b: /* -> PHASE_STATUSIN */
/* DATA IN -> STATUS */ /* DATA IN -> STATUS */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_readstatusbyte(host); acornscsi_readstatusbyte(host);
...@@ -2281,7 +2281,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2281,7 +2281,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4e: /* -> PHASE_MSGOUT */ case 0x4e: /* -> PHASE_MSGOUT */
case 0x8e: /* -> PHASE_MSGOUT */ case 0x8e: /* -> PHASE_MSGOUT */
/* DATA IN -> MESSAGE OUT */ /* DATA IN -> MESSAGE OUT */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_sendmessage(host); acornscsi_sendmessage(host);
...@@ -2291,7 +2291,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2291,7 +2291,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4f: /* message in */ case 0x4f: /* message in */
case 0x8f: /* message in */ case 0x8f: /* message in */
/* DATA IN -> MESSAGE IN */ /* DATA IN -> MESSAGE IN */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */
...@@ -2319,7 +2319,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2319,7 +2319,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4b: /* -> PHASE_STATUSIN */ case 0x4b: /* -> PHASE_STATUSIN */
case 0x8b: /* -> PHASE_STATUSIN */ case 0x8b: /* -> PHASE_STATUSIN */
/* DATA OUT -> STATUS */ /* DATA OUT -> STATUS */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_dma_adjust(host); acornscsi_dma_adjust(host);
...@@ -2331,7 +2331,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2331,7 +2331,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4e: /* -> PHASE_MSGOUT */ case 0x4e: /* -> PHASE_MSGOUT */
case 0x8e: /* -> PHASE_MSGOUT */ case 0x8e: /* -> PHASE_MSGOUT */
/* DATA OUT -> MESSAGE OUT */ /* DATA OUT -> MESSAGE OUT */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_dma_adjust(host); acornscsi_dma_adjust(host);
...@@ -2342,7 +2342,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) ...@@ -2342,7 +2342,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4f: /* message in */ case 0x4f: /* message in */
case 0x8f: /* message in */ case 0x8f: /* message in */
/* DATA OUT -> MESSAGE IN */ /* DATA OUT -> MESSAGE IN */
host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host); acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host); acornscsi_dma_stop(host);
acornscsi_dma_adjust(host); acornscsi_dma_adjust(host);
......
...@@ -18,17 +18,32 @@ ...@@ -18,17 +18,32 @@
* The scatter-gather list handling. This contains all * The scatter-gather list handling. This contains all
* the yucky stuff that needs to be fixed properly. * the yucky stuff that needs to be fixed properly.
*/ */
/*
* copy_SCp_to_sg() Assumes contiguous allocation at @sg of at-most @max
* entries of uninitialized memory. SCp is from scsi-ml and has a valid
* (possibly chained) sg-list
*/
static inline int copy_SCp_to_sg(struct scatterlist *sg, struct scsi_pointer *SCp, int max) static inline int copy_SCp_to_sg(struct scatterlist *sg, struct scsi_pointer *SCp, int max)
{ {
int bufs = SCp->buffers_residual; int bufs = SCp->buffers_residual;
/* FIXME: It should be easy for drivers to loop on copy_SCp_to_sg().
* and to remove this BUG_ON. Use min() in-its-place
*/
BUG_ON(bufs + 1 > max); BUG_ON(bufs + 1 > max);
sg_set_buf(sg, SCp->ptr, SCp->this_residual); sg_set_buf(sg, SCp->ptr, SCp->this_residual);
if (bufs) if (bufs) {
memcpy(sg + 1, SCp->buffer + 1, struct scatterlist *src_sg;
sizeof(struct scatterlist) * bufs); unsigned i;
for_each_sg(sg_next(SCp->buffer), src_sg, bufs, i)
*(++sg) = *src_sg;
sg_mark_end(sg);
}
return bufs + 1; return bufs + 1;
} }
...@@ -36,7 +51,7 @@ static inline int next_SCp(struct scsi_pointer *SCp) ...@@ -36,7 +51,7 @@ static inline int next_SCp(struct scsi_pointer *SCp)
{ {
int ret = SCp->buffers_residual; int ret = SCp->buffers_residual;
if (ret) { if (ret) {
SCp->buffer++; SCp->buffer = sg_next(SCp->buffer);
SCp->buffers_residual--; SCp->buffers_residual--;
SCp->ptr = sg_virt(SCp->buffer); SCp->ptr = sg_virt(SCp->buffer);
SCp->this_residual = SCp->buffer->length; SCp->this_residual = SCp->buffer->length;
...@@ -68,46 +83,46 @@ static inline void init_SCp(struct scsi_cmnd *SCpnt) ...@@ -68,46 +83,46 @@ static inline void init_SCp(struct scsi_cmnd *SCpnt)
{ {
memset(&SCpnt->SCp, 0, sizeof(struct scsi_pointer)); memset(&SCpnt->SCp, 0, sizeof(struct scsi_pointer));
if (SCpnt->use_sg) { if (scsi_bufflen(SCpnt)) {
unsigned long len = 0; unsigned long len = 0;
int buf;
SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; SCpnt->SCp.buffer = scsi_sglist(SCpnt);
SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
SCpnt->SCp.ptr = sg_virt(SCpnt->SCp.buffer); SCpnt->SCp.ptr = sg_virt(SCpnt->SCp.buffer);
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
SCpnt->SCp.phase = SCpnt->request_bufflen; SCpnt->SCp.phase = scsi_bufflen(SCpnt);
#ifdef BELT_AND_BRACES #ifdef BELT_AND_BRACES
/* { /*
* Calculate correct buffer length. Some commands * Calculate correct buffer length. Some commands
* come in with the wrong request_bufflen. * come in with the wrong scsi_bufflen.
*/ */
for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++) struct scatterlist *sg;
len += SCpnt->SCp.buffer[buf].length; unsigned i, sg_count = scsi_sg_count(SCpnt);
if (SCpnt->request_bufflen != len) scsi_for_each_sg(SCpnt, sg, sg_count, i)
printk(KERN_WARNING "scsi%d.%c: bad request buffer " len += sg->length;
"length %d, should be %ld\n", SCpnt->device->host->host_no,
'0' + SCpnt->device->id, SCpnt->request_bufflen, len); if (scsi_bufflen(SCpnt) != len) {
SCpnt->request_bufflen = len; printk(KERN_WARNING
"scsi%d.%c: bad request buffer "
"length %d, should be %ld\n",
SCpnt->device->host->host_no,
'0' + SCpnt->device->id,
scsi_bufflen(SCpnt), len);
/*
* FIXME: Totaly naive fixup. We should abort
* with error
*/
SCpnt->SCp.phase =
min_t(unsigned long, len,
scsi_bufflen(SCpnt));
}
}
#endif #endif
} else { } else {
SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
SCpnt->SCp.this_residual = SCpnt->request_bufflen;
SCpnt->SCp.phase = SCpnt->request_bufflen;
}
/*
* If the upper SCSI layers pass a buffer, but zero length,
* we aren't interested in the buffer pointer.
*/
if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
#if 0 //def BELT_AND_BRACES
printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
"command ", SCpnt->host->host_no, '0' + SCpnt->target);
__scsi_print_command(SCpnt->cmnd);
#endif
SCpnt->SCp.ptr = NULL; SCpnt->SCp.ptr = NULL;
SCpnt->SCp.this_residual = 0;
SCpnt->SCp.phase = 0;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册