Skip to contentSkip to conversation

gpiolib: Fix error return code in gpiolib_dev_init()

PATCH Applied 'Wei Yongjun 2 participants 2 messages Mar 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpiolib: Fix error return code in gpiolib_dev_init()

From: Wei Yongjun <[email protected]>

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes 4731210c09f5 ("gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default")
---
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib.c +2 -1
index cee4333f8ac7..18086262dd48 100644
@@ -4242,7 +4242,8 @@ static int __init gpiolib_dev_init(void)
 		return ret;
 	}
 
-	if (driver_register(&gpio_stub_drv) < 0) {
+	ret = driver_register(&gpio_stub_drv);
+	if (ret < 0) {
 		pr_err("gpiolib: could not register GPIO stub driver\n");
 		bus_unregister(&gpio_bus_type);
 		return ret;
#1 lore raw
Quoted 19 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes 4731210c09f5 ("gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default")
---
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib.c +0 -0
index cee4333f8ac7..18086262dd48 100644

drivers/gpio/gpiolib.c static int __init gpiolib_dev_init(void) · line 4249

Quoted 9 lines
drivers/gpio/gpiolib.c +2 -1
@@ -4242,7 +4242,8 @@ static int __init gpiolib_dev_init(void)
                return ret;
        }
 
-       if (driver_register(&gpio_stub_drv) < 0) {
+       ret = driver_register(&gpio_stub_drv);
+       if (ret < 0) {
                pr_err("gpiolib: could not register GPIO stub driver\n");
                bus_unregister(&gpio_bus_type);
                return ret;

Applied to fixes, thanks!

Bartosz