pinctrl: make pinctrl_register() return proper error code
Currently, pinctrl_register() just returns NULL on error, so the
callers can not know the exact reason of the failure.
Some of the pinctrl drivers return -EINVAL, some -ENODEV, and some
-ENOMEM on error of pinctrl_register(), although the error code
might be different from the real cause of the error.
This commit reworks pinctrl_register() to return the appropriate
error code and modifies all of the pinctrl drivers to use IS_ERR()
for the error checking and PTR_ERR() for getting the error code.
Signed-off-by: Masahiro Yamada <[email protected]>
Acked-by: Patrice Chotard <[email protected]>
Acked-by: Thierry Reding <[email protected]>
Acked-by: Heiko Stuebner <[email protected]>
Tested-by: Mika Westerberg <[email protected]>
Acked-by: Mika Westerberg <[email protected]>
Acked-by: Lee Jones <[email protected]>
Acked-by: Sören Brinkmann <[email protected]>
Acked-by: Laurent Pinchart <[email protected]>
Acked-by: Ray Jui <[email protected]>
Acked-by: Antoine Tenart <[email protected]>
Acked-by: Hongzhou Yang <[email protected]>
Acked-by: Wei Chen <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c
index db0571f..4747e08 100644
--- a/drivers/pinctrl/pinctrl-as3722.c
+++ b/drivers/pinctrl/pinctrl-as3722.c
@@ -586,9 +586,9 @@
as3722_pinctrl_desc.npins = ARRAY_SIZE(as3722_pins_desc);
as_pci->pctl = pinctrl_register(&as3722_pinctrl_desc,
&pdev->dev, as_pci);
- if (!as_pci->pctl) {
+ if (IS_ERR(as_pci->pctl)) {
dev_err(&pdev->dev, "Couldn't register pinctrl driver\n");
- return -EINVAL;
+ return PTR_ERR(as_pci->pctl);
}
as_pci->gpio_chip = as3722_gpio_chip;