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

drivers/scsi/scsi_debug.c: resolve sg buffer const-ness issue

do_device_access() takes a separate parameter to indicate the direction of
data transfer, which it used to use to select the appropriate function out
of sg_pcopy_{to,from}_buffer(). However these two functions now have

So this patch makes it bypass these wrappers and call the underlying
function sg_copy_buffer() directly; this has the same calling style as
do_device_access() i.e. a separate direction-of-transfer parameter and no
pointers-to-const, so skipping the wrappers not only eliminates the
warning, it also make the code simpler :)

[akpm@linux-foundation.org: fix very broken build]
Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dave Gordon and committed by
Linus Torvalds
386ecb12 2a1bf8f9

+10 -11
+4 -8
drivers/scsi/scsi_debug.c
··· 2363 2363 u64 block, rest = 0; 2364 2364 struct scsi_data_buffer *sdb; 2365 2365 enum dma_data_direction dir; 2366 - size_t (*func)(struct scatterlist *, unsigned int, void *, size_t, 2367 - off_t); 2368 2366 2369 2367 if (do_write) { 2370 2368 sdb = scsi_out(scmd); 2371 2369 dir = DMA_TO_DEVICE; 2372 - func = sg_pcopy_to_buffer; 2373 2370 } else { 2374 2371 sdb = scsi_in(scmd); 2375 2372 dir = DMA_FROM_DEVICE; 2376 - func = sg_pcopy_from_buffer; 2377 2373 } 2378 2374 2379 2375 if (!sdb->length) ··· 2381 2385 if (block + num > sdebug_store_sectors) 2382 2386 rest = block + num - sdebug_store_sectors; 2383 2387 2384 - ret = func(sdb->table.sgl, sdb->table.nents, 2388 + ret = sg_copy_buffer(sdb->table.sgl, sdb->table.nents, 2385 2389 fake_storep + (block * scsi_debug_sector_size), 2386 - (num - rest) * scsi_debug_sector_size, 0); 2390 + (num - rest) * scsi_debug_sector_size, 0, do_write); 2387 2391 if (ret != (num - rest) * scsi_debug_sector_size) 2388 2392 return ret; 2389 2393 2390 2394 if (rest) { 2391 - ret += func(sdb->table.sgl, sdb->table.nents, 2395 + ret += sg_copy_buffer(sdb->table.sgl, sdb->table.nents, 2392 2396 fake_storep, rest * scsi_debug_sector_size, 2393 - (num - rest) * scsi_debug_sector_size); 2397 + (num - rest) * scsi_debug_sector_size, do_write); 2394 2398 } 2395 2399 2396 2400 return ret;
+3
include/linux/scatterlist.h
··· 265 265 unsigned long offset, unsigned long size, 266 266 gfp_t gfp_mask); 267 267 268 + size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf, 269 + size_t buflen, off_t skip, bool to_buffer); 270 + 268 271 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, 269 272 const void *buf, size_t buflen); 270 273 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
+3 -3
lib/scatterlist.c
··· 650 650 * Returns the number of copied bytes. 651 651 * 652 652 **/ 653 - static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, 654 - void *buf, size_t buflen, off_t skip, 655 - bool to_buffer) 653 + size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf, 654 + size_t buflen, off_t skip, bool to_buffer) 656 655 { 657 656 unsigned int offset = 0; 658 657 struct sg_mapping_iter miter; ··· 688 689 local_irq_restore(flags); 689 690 return offset; 690 691 } 692 + EXPORT_SYMBOL(sg_copy_buffer); 691 693 692 694 /** 693 695 * sg_copy_from_buffer - Copy from a linear buffer to an SG list