summaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-07 00:00:36 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 08:11:18 +0100
commit3f4dfa9077cb189da4895e9408e8556adec69b26 (patch)
tree7e761e979374c54a1b9b8e58beddc0a8c17b6ecb /drivers/usb/storage/usb.c
parentf2ff12908ee412d1b8ac6b7043d37c58a911d1db (diff)
downloadbarebox-3f4dfa9077cb189da4895e9408e8556adec69b26.tar.gz
usb: storage: Inline usb_limit_blk_cnt()
Usb_limit_blk_cnt() has only one user so we may as well inline it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 335f803..fda24d6 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -269,16 +269,6 @@ static struct block_device_ops usb_mass_storage_ops = {
* Block device routines
***********************************************************************/
-static int usb_limit_blk_cnt(unsigned cnt)
-{
- if (cnt > 0x7fffffff) {
- pr_warn("Limiting device size due to 31 bit contraints\n");
- return 0x7fffffff;
- }
-
- return (int)cnt;
-}
-
/* Prepare a disk device */
static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
{
@@ -314,7 +304,13 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
return result;
}
- pblk_dev->blk.num_blocks = usb_limit_blk_cnt(last_lba + 1);
+ if (last_lba > INT_MAX - 1) {
+ last_lba = INT_MAX - 1;
+ dev_warn(dev,
+ "Limiting device size due to 31 bit contraints\n");
+ }
+
+ pblk_dev->blk.num_blocks = last_lba + 1;
if (block_length != SECTOR_SIZE)
pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
pblk_dev->blk.blockbits = SECTOR_SHIFT;