]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drivers/scsi/scsi_debug.c: resolve sg buffer const-ness issue
authorDave Gordon <david.s.gordon@intel.com>
Tue, 30 Jun 2015 21:58:57 +0000 (14:58 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Jul 2015 02:44:59 +0000 (19:44 -0700)
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>
drivers/scsi/scsi_debug.c
include/linux/scatterlist.h
lib/scatterlist.c

index 1f8e2dc9c616a0b7e02559537c05b109123b5b80..30268bb2ddb6a3e78dc114606ed8c0b4b615d54a 100644 (file)
@@ -2363,17 +2363,13 @@ do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, bool do_write)
        u64 block, rest = 0;
        struct scsi_data_buffer *sdb;
        enum dma_data_direction dir;
        u64 block, rest = 0;
        struct scsi_data_buffer *sdb;
        enum dma_data_direction dir;
-       size_t (*func)(struct scatterlist *, unsigned int, void *, size_t,
-                      off_t);
 
        if (do_write) {
                sdb = scsi_out(scmd);
                dir = DMA_TO_DEVICE;
 
        if (do_write) {
                sdb = scsi_out(scmd);
                dir = DMA_TO_DEVICE;
-               func = sg_pcopy_to_buffer;
        } else {
                sdb = scsi_in(scmd);
                dir = DMA_FROM_DEVICE;
        } else {
                sdb = scsi_in(scmd);
                dir = DMA_FROM_DEVICE;
-               func = sg_pcopy_from_buffer;
        }
 
        if (!sdb->length)
        }
 
        if (!sdb->length)
@@ -2385,16 +2381,16 @@ do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, bool do_write)
        if (block + num > sdebug_store_sectors)
                rest = block + num - sdebug_store_sectors;
 
        if (block + num > sdebug_store_sectors)
                rest = block + num - sdebug_store_sectors;
 
-       ret = func(sdb->table.sgl, sdb->table.nents,
+       ret = sg_copy_buffer(sdb->table.sgl, sdb->table.nents,
                   fake_storep + (block * scsi_debug_sector_size),
                   fake_storep + (block * scsi_debug_sector_size),
-                  (num - rest) * scsi_debug_sector_size, 0);
+                  (num - rest) * scsi_debug_sector_size, 0, do_write);
        if (ret != (num - rest) * scsi_debug_sector_size)
                return ret;
 
        if (rest) {
        if (ret != (num - rest) * scsi_debug_sector_size)
                return ret;
 
        if (rest) {
-               ret += func(sdb->table.sgl, sdb->table.nents,
+               ret += sg_copy_buffer(sdb->table.sgl, sdb->table.nents,
                            fake_storep, rest * scsi_debug_sector_size,
                            fake_storep, rest * scsi_debug_sector_size,
-                           (num - rest) * scsi_debug_sector_size);
+                           (num - rest) * scsi_debug_sector_size, do_write);
        }
 
        return ret;
        }
 
        return ret;
index 505d0481df1e95dac6bb07e004b6919bdac3565a..9b1ef0c820a72dab0fb8dea4658f26d9bc4ad6ab 100644 (file)
@@ -265,6 +265,9 @@ int sg_alloc_table_from_pages(struct sg_table *sgt,
        unsigned long offset, unsigned long size,
        gfp_t gfp_mask);
 
        unsigned long offset, unsigned long size,
        gfp_t gfp_mask);
 
+size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
+                     size_t buflen, off_t skip, bool to_buffer);
+
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
                           const void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
                           const void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
index 317b62c6da3c2ca871d2f0f236b198a47b984cba..d105a9f56878e57e2587f2704121c0210b8fb941 100644 (file)
@@ -650,9 +650,8 @@ EXPORT_SYMBOL(sg_miter_stop);
  * Returns the number of copied bytes.
  *
  **/
  * Returns the number of copied bytes.
  *
  **/
-static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
-                            void *buf, size_t buflen, off_t skip,
-                            bool to_buffer)
+size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
+                     size_t buflen, off_t skip, bool to_buffer)
 {
        unsigned int offset = 0;
        struct sg_mapping_iter miter;
 {
        unsigned int offset = 0;
        struct sg_mapping_iter miter;
@@ -689,6 +688,7 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
        local_irq_restore(flags);
        return offset;
 }
        local_irq_restore(flags);
        return offset;
 }
+EXPORT_SYMBOL(sg_copy_buffer);
 
 /**
  * sg_copy_from_buffer - Copy from a linear buffer to an SG list
 
 /**
  * sg_copy_from_buffer - Copy from a linear buffer to an SG list