From: Dong Aisheng Date: Fri, 6 Apr 2012 12:18:09 +0000 (+0800) Subject: pinctrl: fix pinmux_check_ops error checking X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a1d31f71e6ed2f714830df8885ec07dfe1f6632e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git pinctrl: fix pinmux_check_ops error checking Do not use get_functions_count before checking. Acked-by: Stephen Warren Signed-off-by: Dong Aisheng Signed-off-by: Linus Walleij --- 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 @@ 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; }