diff options
author | Suwan Kim <suwan.kim027@gmail.com> | 2019-01-07 23:21:11 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-07 17:34:59 +0100 |
commit | f2fd71db12f8269a0384321c3c71a9312c66b415 (patch) | |
tree | 3f4334212b31e1bbbb4e69b1924b76b8c65c8055 /drivers | |
parent | bfeffd155283772bbe78c6a05dec7c0128ee500c (diff) | |
download | linux-f2fd71db12f8269a0384321c3c71a9312c66b415.tar.bz2 |
usb: core: Simplify return value of usb_get_configuration()
It is better to initialize the return value "result" to -ENOMEM
than to 0. And because "result" takes the return value of
usb_parse_configuration() which returns 0 for success, setting
"result" to 0 at before and after of the for loop is unnecessary.
Signed-off-by: Suwan Kim <suwan.kim027@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/core/config.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 7b5cb28ffb35..4a0945c04b4c 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -800,13 +800,12 @@ int usb_get_configuration(struct usb_device *dev) { struct device *ddev = &dev->dev; int ncfg = dev->descriptor.bNumConfigurations; - int result = 0; + int result = -ENOMEM; unsigned int cfgno, length; unsigned char *bigbuffer; struct usb_config_descriptor *desc; cfgno = 0; - result = -ENOMEM; if (ncfg > USB_MAXCONFIG) { dev_warn(ddev, "too many configurations: %d, " "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG); @@ -832,7 +831,6 @@ int usb_get_configuration(struct usb_device *dev) if (!desc) goto err2; - result = 0; for (; cfgno < ncfg; cfgno++) { /* We grab just the first descriptor so we know how long * the whole configuration is */ @@ -889,7 +887,6 @@ int usb_get_configuration(struct usb_device *dev) goto err; } } - result = 0; err: kfree(desc); |