diff options
author | Dingyan Li <18500469033@163.com> | 2024-10-30 16:38:58 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-12-04 16:33:54 +0100 |
commit | d8d936c51388442f769a81e512b505dcf87c6a51 (patch) | |
tree | 89f7d2226ef9cc65624c52c8edff27076a30fad6 /drivers/usb/gadget | |
parent | 3b56774fa25d46bd2ff3707546e30829f52dde9e (diff) | |
download | linux-stable-d8d936c51388442f769a81e512b505dcf87c6a51.tar.gz linux-stable-d8d936c51388442f769a81e512b505dcf87c6a51.tar.bz2 linux-stable-d8d936c51388442f769a81e512b505dcf87c6a51.zip |
usb: storage: add a macro for the upper limit of max LUN
The meaning of this value is already used in several places,
but with constant values and comments to explain it separately.
It's better to have a central place to do this then use the macro
in those places for better readability.
Signed-off-by: Dingyan Li <18500469033@163.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20241030083858.46907-1-18500469033@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/function/f_tcm.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/function/storage_common.h | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 15bb3aa12aa8..e1914b20f816 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -441,14 +441,10 @@ static int usbg_bot_setup(struct usb_function *f, pr_err("No LUNs configured?\n"); return -EINVAL; } - /* - * If 4 LUNs are present we return 3 i.e. LUN 0..3 can be - * accessed. The upper limit is 0xf - */ luns--; - if (luns > 0xf) { + if (luns > US_BULK_MAX_LUN_LIMIT) { pr_info_once("Limiting the number of luns to 16\n"); - luns = 0xf; + luns = US_BULK_MAX_LUN_LIMIT; } ret_lun = cdev->req->buf; *ret_lun = luns; diff --git a/drivers/usb/gadget/function/storage_common.h b/drivers/usb/gadget/function/storage_common.h index ced5d2b09234..11ac785d5eee 100644 --- a/drivers/usb/gadget/function/storage_common.h +++ b/drivers/usb/gadget/function/storage_common.h @@ -131,7 +131,7 @@ static inline bool fsg_lun_is_open(struct fsg_lun *curlun) #define FSG_BUFLEN ((u32)16384) /* Maximal number of LUNs supported in mass storage function */ -#define FSG_MAX_LUNS 16 +#define FSG_MAX_LUNS (US_BULK_MAX_LUN_LIMIT + 1) enum fsg_buffer_state { BUF_STATE_SENDING = -2, |