Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] simscsi: convert to use the data buffer accessors

- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

FUJITA Tomonori and committed by
James Bottomley
fd3adb2a 147e505e

+15 -51
+15 -51
arch/ia64/hp/sim/simscsi.c
··· 122 122 } 123 123 124 124 static void 125 - simscsi_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset, unsigned long len) 126 - { 127 - struct disk_stat stat; 128 - struct disk_req req; 129 - 130 - req.addr = __pa(sc->request_buffer); 131 - req.len = len; /* # of bytes to transfer */ 132 - 133 - if (sc->request_bufflen < req.len) 134 - return; 135 - 136 - stat.fd = desc[sc->device->id]; 137 - if (DBG) 138 - printk("simscsi_%s @ %lx (off %lx)\n", 139 - mode == SSC_READ ? "read":"write", req.addr, offset); 140 - ia64_ssc(stat.fd, 1, __pa(&req), offset, mode); 141 - ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION); 142 - 143 - if (stat.count == req.len) { 144 - sc->result = GOOD; 145 - } else { 146 - sc->result = DID_ERROR << 16; 147 - } 148 - } 149 - 150 - static void 151 125 simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset) 152 126 { 153 - int list_len = sc->use_sg; 154 - struct scatterlist *sl = (struct scatterlist *)sc->request_buffer; 127 + int i; 128 + struct scatterlist *sl; 155 129 struct disk_stat stat; 156 130 struct disk_req req; 157 131 158 132 stat.fd = desc[sc->device->id]; 159 133 160 - while (list_len) { 134 + scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) { 161 135 req.addr = __pa(page_address(sl->page) + sl->offset); 162 136 req.len = sl->length; 163 137 if (DBG) 164 138 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n", 165 139 mode == SSC_READ ? "read":"write", req.addr, offset, 166 - list_len, sl->length); 140 + scsi_sg_count(sc) - i, sl->length); 167 141 ia64_ssc(stat.fd, 1, __pa(&req), offset, mode); 168 142 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION); 169 143 ··· 147 173 return; 148 174 } 149 175 offset += sl->length; 150 - sl++; 151 - list_len--; 152 176 } 153 177 sc->result = GOOD; 154 178 } ··· 162 190 unsigned long offset; 163 191 164 192 offset = (((sc->cmnd[1] & 0x1f) << 16) | (sc->cmnd[2] << 8) | sc->cmnd[3])*512; 165 - if (sc->use_sg > 0) 166 - simscsi_sg_readwrite(sc, mode, offset); 167 - else 168 - simscsi_readwrite(sc, mode, offset, sc->cmnd[4]*512); 193 + simscsi_sg_readwrite(sc, mode, offset); 169 194 } 170 195 171 196 static size_t ··· 199 230 | ((unsigned long)sc->cmnd[3] << 16) 200 231 | ((unsigned long)sc->cmnd[4] << 8) 201 232 | ((unsigned long)sc->cmnd[5] << 0))*512UL; 202 - if (sc->use_sg > 0) 203 - simscsi_sg_readwrite(sc, mode, offset); 204 - else 205 - simscsi_readwrite(sc, mode, offset, ((sc->cmnd[7] << 8) | sc->cmnd[8])*512); 233 + simscsi_sg_readwrite(sc, mode, offset); 206 234 } 207 235 208 236 static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len) 209 237 { 210 238 211 - int scatterlen = sc->use_sg; 239 + int i; 240 + unsigned thislen; 212 241 struct scatterlist *slp; 213 242 214 - if (scatterlen == 0) 215 - memcpy(sc->request_buffer, buf, len); 216 - else for (slp = (struct scatterlist *)sc->request_buffer; 217 - scatterlen-- > 0 && len > 0; slp++) { 218 - unsigned thislen = min(len, slp->length); 219 - 243 + scsi_for_each_sg(sc, slp, scsi_sg_count(sc), i) { 244 + if (!len) 245 + break; 246 + thislen = min(len, slp->length); 220 247 memcpy(page_address(slp->page) + slp->offset, buf, thislen); 221 - slp++; 222 248 len -= thislen; 223 249 } 224 250 } ··· 239 275 if (target_id <= 15 && sc->device->lun == 0) { 240 276 switch (sc->cmnd[0]) { 241 277 case INQUIRY: 242 - if (sc->request_bufflen < 35) { 278 + if (scsi_bufflen(sc) < 35) { 243 279 break; 244 280 } 245 281 sprintf (fname, "%s%c", simscsi_root, 'a' + target_id); ··· 292 328 break; 293 329 294 330 case READ_CAPACITY: 295 - if (desc[target_id] < 0 || sc->request_bufflen < 8) { 331 + if (desc[target_id] < 0 || scsi_bufflen(sc) < 8) { 296 332 break; 297 333 } 298 334 buf = localbuf; ··· 314 350 case MODE_SENSE: 315 351 case MODE_SENSE_10: 316 352 /* sd.c uses this to determine whether disk does write-caching. */ 317 - simscsi_fillresult(sc, (char *)empty_zero_page, sc->request_bufflen); 353 + simscsi_fillresult(sc, (char *)empty_zero_page, scsi_bufflen(sc)); 318 354 sc->result = GOOD; 319 355 break; 320 356