pinctrl: fix pinmux_check_ops error checking
authorDong Aisheng <dong.aisheng@linaro.org>
Fri, 6 Apr 2012 12:18:09 +0000 (20:18 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 18 Apr 2012 11:53:11 +0000 (13:53 +0200)
Do not use get_functions_count before checking.

Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinmux.c

index 375b214780e938ca25646757318f996fb351009f..8849830e51901ae3ac0a194d49eeb2bcdb198329 100644 (file)
 int pinmux_check_ops(struct pinctrl_dev *pctldev)
 {
        const struct pinmux_ops *ops = pctldev->desc->pmxops;
-       unsigned nfuncs = ops->get_functions_count(pctldev);
+       unsigned nfuncs;
        unsigned selector = 0;
 
        /* Check that we implement required operations */
-       if (!ops->get_functions_count ||
+       if (!ops ||
+           !ops->get_functions_count ||
            !ops->get_function_name ||
            !ops->get_function_groups ||
            !ops->enable ||
@@ -45,11 +46,12 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
                return -EINVAL;
 
        /* Check that all functions registered have names */
+       nfuncs = ops->get_functions_count(pctldev);
        while (selector < nfuncs) {
                const char *fname = ops->get_function_name(pctldev,
                                                           selector);
                if (!fname) {
-                       pr_err("pinmux ops has no name for function%u\n",
+                       dev_err(pctldev->dev, "pinmux ops has no name for function%u\n",
                                selector);
                        return -EINVAL;
                }