Commit f7441a79 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by James Bottomley

[SCSI] ps3rom: Simplify fill_from_dev_buffer()

As we no longer need to calculate the data length of the whole scatterlist,
we can abort the loop earlier and coalesce req_len and act_len into one
variable, making fill_from_dev_buffer() more similar to fetch_to_dev_buffer().
Signed-off-by: default avatarGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent d1e4c9c5
...@@ -95,7 +95,7 @@ static int ps3rom_slave_configure(struct scsi_device *scsi_dev) ...@@ -95,7 +95,7 @@ static int ps3rom_slave_configure(struct scsi_device *scsi_dev)
*/ */
static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
{ {
int k, req_len, act_len, len, active; int k, req_len, len, fin;
void *kaddr; void *kaddr;
struct scatterlist *sgpnt; struct scatterlist *sgpnt;
unsigned int buflen; unsigned int buflen;
...@@ -107,24 +107,22 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) ...@@ -107,24 +107,22 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
if (!scsi_sglist(cmd)) if (!scsi_sglist(cmd))
return -1; return -1;
active = 1; req_len = fin = 0;
req_len = act_len = 0;
scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) {
if (active) {
kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0); kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0);
len = sgpnt->length; len = sgpnt->length;
if ((req_len + len) > buflen) { if ((req_len + len) > buflen) {
active = 0;
len = buflen - req_len; len = buflen - req_len;
fin = 1;
} }
memcpy(kaddr + sgpnt->offset, buf + req_len, len); memcpy(kaddr + sgpnt->offset, buf + req_len, len);
flush_kernel_dcache_page(sg_page(sgpnt)); flush_kernel_dcache_page(sg_page(sgpnt));
kunmap_atomic(kaddr, KM_IRQ0); kunmap_atomic(kaddr, KM_IRQ0);
act_len += len; req_len += len;
} if (fin)
req_len += sgpnt->length; break;
} }
scsi_set_resid(cmd, buflen - act_len); scsi_set_resid(cmd, buflen - req_len);
return 0; return 0;
} }
......
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