aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ips.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-03-08 23:44:33 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-07 13:15:46 -0400
commit6690bae7e0279451ee92580bf1c5d39a76e3687e (patch)
treec32db080167c4ff68aff4d81fb3635baf1a87357 /drivers/scsi/ips.c
parent1a7a2e1a77f29179f997ca5e873c50ae2fb7fcc1 (diff)
[SCSI] ips: use sg buffer copy helper funcitons
This rewrites ips_scmd_buf_write/read with scsi_sg_copy_from/to_buffer respectively. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Salyzyn, Mark <Mark_Salyzyn@adaptec.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/ips.c')
-rw-r--r--drivers/scsi/ips.c50
1 files changed, 8 insertions, 42 deletions
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 62640366845a..cc4f44fcabb6 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -3502,28 +3502,11 @@ ips_send_wait(ips_ha_t * ha, ips_scb_t * scb, int timeout, int intr)
3502static void 3502static void
3503ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count) 3503ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
3504{ 3504{
3505 int i; 3505 unsigned long flags;
3506 unsigned int min_cnt, xfer_cnt;
3507 char *cdata = (char *) data;
3508 unsigned char *buffer;
3509 unsigned long flags;
3510 struct scatterlist *sg = scsi_sglist(scmd);
3511
3512 for (i = 0, xfer_cnt = 0;
3513 (i < scsi_sg_count(scmd)) && (xfer_cnt < count);
3514 i++, sg = sg_next(sg)) {
3515 min_cnt = min(count - xfer_cnt, sg->length);
3516
3517 /* kmap_atomic() ensures addressability of the data buffer.*/
3518 /* local_irq_save() protects the KM_IRQ0 address slot. */
3519 local_irq_save(flags);
3520 buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
3521 memcpy(buffer, &cdata[xfer_cnt], min_cnt);
3522 kunmap_atomic(buffer - sg->offset, KM_IRQ0);
3523 local_irq_restore(flags);
3524 3506
3525 xfer_cnt += min_cnt; 3507 local_irq_save(flags);
3526 } 3508 scsi_sg_copy_from_buffer(scmd, data, count);
3509 local_irq_restore(flags);
3527} 3510}
3528 3511
3529/****************************************************************************/ 3512/****************************************************************************/
@@ -3536,28 +3519,11 @@ ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
3536static void 3519static void
3537ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count) 3520ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count)
3538{ 3521{
3539 int i; 3522 unsigned long flags;
3540 unsigned int min_cnt, xfer_cnt;
3541 char *cdata = (char *) data;
3542 unsigned char *buffer;
3543 unsigned long flags;
3544 struct scatterlist *sg = scsi_sglist(scmd);
3545
3546 for (i = 0, xfer_cnt = 0;
3547 (i < scsi_sg_count(scmd)) && (xfer_cnt < count);
3548 i++, sg = sg_next(sg)) {
3549 min_cnt = min(count - xfer_cnt, sg->length);
3550
3551 /* kmap_atomic() ensures addressability of the data buffer.*/
3552 /* local_irq_save() protects the KM_IRQ0 address slot. */
3553 local_irq_save(flags);
3554 buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
3555 memcpy(&cdata[xfer_cnt], buffer, min_cnt);
3556 kunmap_atomic(buffer - sg->offset, KM_IRQ0);
3557 local_irq_restore(flags);
3558 3523
3559 xfer_cnt += min_cnt; 3524 local_irq_save(flags);
3560 } 3525 scsi_sg_copy_to_buffer(scmd, data, count);
3526 local_irq_restore(flags);
3561} 3527}
3562 3528
3563/****************************************************************************/ 3529/****************************************************************************/