From 3f4dfa9077cb189da4895e9408e8556adec69b26 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Thu, 7 Mar 2019 00:00:36 -0800 Subject: 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 Signed-off-by: Sascha Hauer --- drivers/usb/storage/usb.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'drivers/usb/storage/usb.c') diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 335f8033b8..fda24d6167 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; -- cgit v1.2.3