aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinmux.c
diff options
context:
space:
mode:
authorDong Aisheng <dong.aisheng@linaro.org>2012-04-06 08:18:09 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-04-18 07:53:11 -0400
commita1d31f71e6ed2f714830df8885ec07dfe1f6632e (patch)
tree023be552c4d60c59414999c8a58c3888c7058824 /drivers/pinctrl/pinmux.c
parentd1e90e9e7467dbfe521b25ba79f520bf676ebc36 (diff)
pinctrl: fix pinmux_check_ops error checking
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>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r--drivers/pinctrl/pinmux.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 375b214780e9..8849830e5190 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -33,11 +33,12 @@
33int pinmux_check_ops(struct pinctrl_dev *pctldev) 33int pinmux_check_ops(struct pinctrl_dev *pctldev)
34{ 34{
35 const struct pinmux_ops *ops = pctldev->desc->pmxops; 35 const struct pinmux_ops *ops = pctldev->desc->pmxops;
36 unsigned nfuncs = ops->get_functions_count(pctldev); 36 unsigned nfuncs;
37 unsigned selector = 0; 37 unsigned selector = 0;
38 38
39 /* Check that we implement required operations */ 39 /* Check that we implement required operations */
40 if (!ops->get_functions_count || 40 if (!ops ||
41 !ops->get_functions_count ||
41 !ops->get_function_name || 42 !ops->get_function_name ||
42 !ops->get_function_groups || 43 !ops->get_function_groups ||
43 !ops->enable || 44 !ops->enable ||
@@ -45,11 +46,12 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
45 return -EINVAL; 46 return -EINVAL;
46 47
47 /* Check that all functions registered have names */ 48 /* Check that all functions registered have names */
49 nfuncs = ops->get_functions_count(pctldev);
48 while (selector < nfuncs) { 50 while (selector < nfuncs) {
49 const char *fname = ops->get_function_name(pctldev, 51 const char *fname = ops->get_function_name(pctldev,
50 selector); 52 selector);
51 if (!fname) { 53 if (!fname) {
52 pr_err("pinmux ops has no name for function%u\n", 54 dev_err(pctldev->dev, "pinmux ops has no name for function%u\n",
53 selector); 55 selector);
54 return -EINVAL; 56 return -EINVAL;
55 } 57 }