diff options
-rw-r--r-- | drivers/scsi/scsi_debug.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 83efec2919b1..fc8b3aa083d4 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -258,7 +258,7 @@ struct sdebug_queued_cmd { | |||
258 | static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; | 258 | static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; |
259 | 259 | ||
260 | static unsigned char * fake_storep; /* ramdisk storage */ | 260 | static unsigned char * fake_storep; /* ramdisk storage */ |
261 | static unsigned char *dif_storep; /* protection info */ | 261 | static struct sd_dif_tuple *dif_storep; /* protection info */ |
262 | static void *map_storep; /* provisioning map */ | 262 | static void *map_storep; /* provisioning map */ |
263 | 263 | ||
264 | static unsigned long map_size; | 264 | static unsigned long map_size; |
@@ -277,11 +277,6 @@ static char sdebug_proc_name[] = "scsi_debug"; | |||
277 | 277 | ||
278 | static struct bus_type pseudo_lld_bus; | 278 | static struct bus_type pseudo_lld_bus; |
279 | 279 | ||
280 | static inline sector_t dif_offset(sector_t sector) | ||
281 | { | ||
282 | return sector << 3; | ||
283 | } | ||
284 | |||
285 | static struct device_driver sdebug_driverfs_driver = { | 280 | static struct device_driver sdebug_driverfs_driver = { |
286 | .name = sdebug_proc_name, | 281 | .name = sdebug_proc_name, |
287 | .bus = &pseudo_lld_bus, | 282 | .bus = &pseudo_lld_bus, |
@@ -1727,7 +1722,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, | |||
1727 | 1722 | ||
1728 | start_sec = do_div(tmp_sec, sdebug_store_sectors); | 1723 | start_sec = do_div(tmp_sec, sdebug_store_sectors); |
1729 | 1724 | ||
1730 | sdt = (struct sd_dif_tuple *)(dif_storep + dif_offset(start_sec)); | 1725 | sdt = dif_storep + start_sec; |
1731 | 1726 | ||
1732 | for (i = 0 ; i < sectors ; i++) { | 1727 | for (i = 0 ; i < sectors ; i++) { |
1733 | u16 csum; | 1728 | u16 csum; |
@@ -1782,16 +1777,17 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, | |||
1782 | ei_lba++; | 1777 | ei_lba++; |
1783 | } | 1778 | } |
1784 | 1779 | ||
1785 | resid = sectors * 8; /* Bytes of protection data to copy into sgl */ | 1780 | /* Bytes of protection data to copy into sgl */ |
1781 | resid = sectors * sizeof(*dif_storep); | ||
1786 | sector = start_sec; | 1782 | sector = start_sec; |
1787 | 1783 | ||
1788 | scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) { | 1784 | scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) { |
1789 | int len = min(psgl->length, resid); | 1785 | int len = min(psgl->length, resid); |
1790 | 1786 | ||
1791 | paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; | 1787 | paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; |
1792 | memcpy(paddr, dif_storep + dif_offset(sector), len); | 1788 | memcpy(paddr, dif_storep + sector, len); |
1793 | 1789 | ||
1794 | sector += len >> 3; | 1790 | sector += len / sizeof(*dif_storep); |
1795 | if (sector >= sdebug_store_sectors) { | 1791 | if (sector >= sdebug_store_sectors) { |
1796 | /* Force wrap */ | 1792 | /* Force wrap */ |
1797 | tmp_sec = sector; | 1793 | tmp_sec = sector; |
@@ -1968,7 +1964,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, | |||
1968 | * correctness we need to verify each sector | 1964 | * correctness we need to verify each sector |
1969 | * before writing it to "stable" storage | 1965 | * before writing it to "stable" storage |
1970 | */ | 1966 | */ |
1971 | memcpy(dif_storep + dif_offset(sector), sdt, 8); | 1967 | memcpy(dif_storep + sector, sdt, sizeof(*sdt)); |
1972 | 1968 | ||
1973 | sector++; | 1969 | sector++; |
1974 | 1970 | ||