[PATCH 03/26] usb: storage: Don't use "unsigned long" for 32-bit values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unsignled long will expand to 64-bit unsigned integer on 64-bit
CPUs. This will break current code using it to read out two 32-bit
values returned by READ_CAPACITY. Fix the proble by using "u32"
explicitly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 drivers/usb/storage/usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 89a80c483..db839e39a 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -322,7 +322,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	ccb us_ccb;
-	unsigned long *pcap;
+	u32 *pcap;
 	int result = 0;
 
 	us_ccb.pdata = us_io_buf;
@@ -363,8 +363,8 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 		result = -EIO;
 		goto Exit;
 	}
-	pcap = (unsigned long *)us_ccb.pdata;
-	dev_dbg(dev, "Read Capacity returns: 0x%lx, 0x%lx\n", pcap[0], pcap[1]);
+	pcap = (u32 *)us_ccb.pdata;
+	dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n", pcap[0], pcap[1]);
 	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(be32_to_cpu(pcap[0]) + 1);
 	if (be32_to_cpu(pcap[1]) != SECTOR_SIZE)
 		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux