[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>
This commit is contained in:
Родитель
1a7a2e1a77
Коммит
6690bae7e0
|
@ -3502,28 +3502,11 @@ ips_send_wait(ips_ha_t * ha, ips_scb_t * scb, int timeout, int intr)
|
||||||
static void
|
static void
|
||||||
ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
|
ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned long flags;
|
||||||
unsigned int min_cnt, xfer_cnt;
|
|
||||||
char *cdata = (char *) data;
|
|
||||||
unsigned char *buffer;
|
|
||||||
unsigned long flags;
|
|
||||||
struct scatterlist *sg = scsi_sglist(scmd);
|
|
||||||
|
|
||||||
for (i = 0, xfer_cnt = 0;
|
local_irq_save(flags);
|
||||||
(i < scsi_sg_count(scmd)) && (xfer_cnt < count);
|
scsi_sg_copy_from_buffer(scmd, data, count);
|
||||||
i++, sg = sg_next(sg)) {
|
local_irq_restore(flags);
|
||||||
min_cnt = min(count - xfer_cnt, sg->length);
|
|
||||||
|
|
||||||
/* kmap_atomic() ensures addressability of the data buffer.*/
|
|
||||||
/* local_irq_save() protects the KM_IRQ0 address slot. */
|
|
||||||
local_irq_save(flags);
|
|
||||||
buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
|
|
||||||
memcpy(buffer, &cdata[xfer_cnt], min_cnt);
|
|
||||||
kunmap_atomic(buffer - sg->offset, KM_IRQ0);
|
|
||||||
local_irq_restore(flags);
|
|
||||||
|
|
||||||
xfer_cnt += min_cnt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -3536,28 +3519,11 @@ ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
|
||||||
static void
|
static void
|
||||||
ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count)
|
ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned long flags;
|
||||||
unsigned int min_cnt, xfer_cnt;
|
|
||||||
char *cdata = (char *) data;
|
|
||||||
unsigned char *buffer;
|
|
||||||
unsigned long flags;
|
|
||||||
struct scatterlist *sg = scsi_sglist(scmd);
|
|
||||||
|
|
||||||
for (i = 0, xfer_cnt = 0;
|
local_irq_save(flags);
|
||||||
(i < scsi_sg_count(scmd)) && (xfer_cnt < count);
|
scsi_sg_copy_to_buffer(scmd, data, count);
|
||||||
i++, sg = sg_next(sg)) {
|
local_irq_restore(flags);
|
||||||
min_cnt = min(count - xfer_cnt, sg->length);
|
|
||||||
|
|
||||||
/* kmap_atomic() ensures addressability of the data buffer.*/
|
|
||||||
/* local_irq_save() protects the KM_IRQ0 address slot. */
|
|
||||||
local_irq_save(flags);
|
|
||||||
buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
|
|
||||||
memcpy(&cdata[xfer_cnt], buffer, min_cnt);
|
|
||||||
kunmap_atomic(buffer - sg->offset, KM_IRQ0);
|
|
||||||
local_irq_restore(flags);
|
|
||||||
|
|
||||||
xfer_cnt += min_cnt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче