07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

195 * pick up from where this one left <strong>of</strong>f. */<br />

196<br />

197 unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,<br />

198 unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,<br />

199 unsigned int *<strong>of</strong>fset, enum xfer_buf_dir dir)<br />

200 {<br />

201 unsigned int cnt;<br />

202<br />

203 /* If not using scatter-gather, just transfer the data directly.<br />

204 * Make certain it will fit in the available buffer space. */<br />

205 if (srb->use_sg == 0) {<br />

206 if (*<strong>of</strong>fset >= srb->request_bufflen)<br />

207 return 0;<br />

208 cnt = min(buflen, srb->request_bufflen - *<strong>of</strong>fset);<br />

209 if (dir == TO_XFER_BUF)<br />

210 memcpy((unsigned char *) srb->request_buffer + *<strong>of</strong>fset,<br />

211 buffer, cnt);<br />

212 else<br />

213 memcpy(buffer, (unsigned char *) srb->request_buffer +<br />

214 *<strong>of</strong>fset, cnt);<br />

215 *<strong>of</strong>fset += cnt;<br />

216<br />

217 /* Using scatter-gather. We have to go through the list one entry<br />

218 * at a time. Each s-g entry contains some number <strong>of</strong> pages, and<br />

219 * each page has to be kmap()'ed separately. If the page is already<br />

220 * in kernel-addressable memory then kmap() will return its address.<br />

221 * If the page is not directly accessible -- such as a user buffer<br />

222 * located in high memory -- then kmap() will map it to a temporary<br />

223 * position in the kernel's virtual address space. */<br />

224 } else {<br />

225 struct scatterlist *sg =<br />

226 (struct scatterlist *) srb->request_buffer<br />

227 + *index;<br />

228<br />

229 /* This loop handles a single s-g list entry, which may<br />

230 * include multiple pages. Find the initial page structure<br />

133<br />

231 * and the starting <strong>of</strong>fset within the page, and update<br />

232 * the *<strong>of</strong>fset and *index values for the next loop. */<br />

233 cnt = 0;<br />

234 while (cnt < buflen && *index < srb->use_sg) {<br />

235 struct page *page = sg->page +<br />

236 ((sg-><strong>of</strong>fset + *<strong>of</strong>fset) >> PAGE_SHIFT);<br />

237 unsigned int p<strong>of</strong>f =

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!