xhci: dbc: Don't shadow error codes in store() functions
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 1 Dec 2023 15:06:34 +0000 (17:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Dec 2023 06:50:40 +0000 (07:50 +0100)
kstrtox() along with regmap API can return different error codes
based on the circumstances. Don't shadow them when returning to
the caller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20231201150647.1307406-7-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-dbgcap.c

index 6b9f4b839270956c0b913edb1e59c99047c265a0..c211c69e80410084863b98e0a3de4cbfbe8313b5 100644 (file)
@@ -977,9 +977,11 @@ static ssize_t dbc_idVendor_store(struct device *dev,
        void __iomem            *ptr;
        u16                     value;
        u32                     dev_info;
+       int ret;
 
-       if (kstrtou16(buf, 0, &value))
-               return -EINVAL;
+       ret = kstrtou16(buf, 0, &value);
+       if (ret)
+               return ret;
 
        xhci = hcd_to_xhci(dev_get_drvdata(dev));
        dbc = xhci->dbc;
@@ -1017,9 +1019,11 @@ static ssize_t dbc_idProduct_store(struct device *dev,
        void __iomem            *ptr;
        u32                     dev_info;
        u16                     value;
+       int ret;
 
-       if (kstrtou16(buf, 0, &value))
-               return -EINVAL;
+       ret = kstrtou16(buf, 0, &value);
+       if (ret)
+               return ret;
 
        xhci = hcd_to_xhci(dev_get_drvdata(dev));
        dbc = xhci->dbc;
@@ -1056,9 +1060,11 @@ static ssize_t dbc_bcdDevice_store(struct device *dev,
        void __iomem *ptr;
        u32 dev_info;
        u16 value;
+       int ret;
 
-       if (kstrtou16(buf, 0, &value))
-               return -EINVAL;
+       ret = kstrtou16(buf, 0, &value);
+       if (ret)
+               return ret;
 
        xhci = hcd_to_xhci(dev_get_drvdata(dev));
        dbc = xhci->dbc;
@@ -1098,9 +1104,13 @@ static ssize_t dbc_bInterfaceProtocol_store(struct device *dev,
        u8 value;
        int ret;
 
-       /* bInterfaceProtocol is 8 bit, but xhci only supports values 0 and 1 */
+       /* bInterfaceProtocol is 8 bit, but... */
        ret = kstrtou8(buf, 0, &value);
-       if (ret || value > 1)
+       if (ret)
+               return ret;
+
+       /* ...xhci only supports values 0 and 1 */
+       if (value > 1)
                return -EINVAL;
 
        xhci = hcd_to_xhci(dev_get_drvdata(dev));