diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2008-02-25 08:24:31 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-04-07 13:15:41 -0400 |
commit | f7441a791aeaeac2e1f1f71b485d1372016f9285 (patch) | |
tree | 25d5b16e6c9f587d0f841794f382ba6a4dc6cd90 /drivers/scsi/ps3rom.c | |
parent | d1e4c9c57c2ed4722795443db22a5d813cd4f0e5 (diff) |
[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: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/ps3rom.c')
-rw-r--r-- | drivers/scsi/ps3rom.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index fad6cb5cba28..0eed5ca1e032 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c | |||
@@ -95,7 +95,7 @@ static int ps3rom_slave_configure(struct scsi_device *scsi_dev) | |||
95 | */ | 95 | */ |
96 | static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) | 96 | static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) |
97 | { | 97 | { |
98 | int k, req_len, act_len, len, active; | 98 | int k, req_len, len, fin; |
99 | void *kaddr; | 99 | void *kaddr; |
100 | struct scatterlist *sgpnt; | 100 | struct scatterlist *sgpnt; |
101 | unsigned int buflen; | 101 | unsigned int buflen; |
@@ -107,24 +107,22 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) | |||
107 | if (!scsi_sglist(cmd)) | 107 | if (!scsi_sglist(cmd)) |
108 | return -1; | 108 | return -1; |
109 | 109 | ||
110 | active = 1; | 110 | req_len = fin = 0; |
111 | req_len = act_len = 0; | ||
112 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { | 111 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { |
113 | if (active) { | 112 | kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0); |
114 | kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0); | 113 | len = sgpnt->length; |
115 | len = sgpnt->length; | 114 | if ((req_len + len) > buflen) { |
116 | if ((req_len + len) > buflen) { | 115 | len = buflen - req_len; |
117 | active = 0; | 116 | fin = 1; |
118 | len = buflen - req_len; | ||
119 | } | ||
120 | memcpy(kaddr + sgpnt->offset, buf + req_len, len); | ||
121 | flush_kernel_dcache_page(sg_page(sgpnt)); | ||
122 | kunmap_atomic(kaddr, KM_IRQ0); | ||
123 | act_len += len; | ||
124 | } | 117 | } |
125 | req_len += sgpnt->length; | 118 | memcpy(kaddr + sgpnt->offset, buf + req_len, len); |
119 | flush_kernel_dcache_page(sg_page(sgpnt)); | ||
120 | kunmap_atomic(kaddr, KM_IRQ0); | ||
121 | req_len += len; | ||
122 | if (fin) | ||
123 | break; | ||
126 | } | 124 | } |
127 | scsi_set_resid(cmd, buflen - act_len); | 125 | scsi_set_resid(cmd, buflen - req_len); |
128 | return 0; | 126 | return 0; |
129 | } | 127 | } |
130 | 128 | ||