linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking
@ 2012-04-06 12:18 Dong Aisheng
  2012-04-06 15:32 ` Stephen Warren
  0 siblings, 1 reply; 4+ messages in thread
From: Dong Aisheng @ 2012-04-06 12:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arm-kernel, linus.walleij, swarren

From: Dong Aisheng <dong.aisheng@linaro.org>

Do not use get_functions_count before checking.

Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
 drivers/pinctrl/pinmux.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 375b214..8849830 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;
 		}
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking
  2012-04-06 12:18 [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking Dong Aisheng
@ 2012-04-06 15:32 ` Stephen Warren
  2012-04-09  3:31   ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Warren @ 2012-04-06 15:32 UTC (permalink / raw)
  To: Dong Aisheng; +Cc: linux-kernel, linux-arm-kernel, linus.walleij, Viresh Kumar

On 04/06/2012 06:18 AM, Dong Aisheng wrote:
> From: Dong Aisheng <dong.aisheng@linaro.org>
> 
> Do not use get_functions_count before checking.
> 
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

IIRC, Viresh added some other get_*_count() functions in the same patch.
Do we need any more fixes similar to the this for those too?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking
  2012-04-06 15:32 ` Stephen Warren
@ 2012-04-09  3:31   ` Viresh Kumar
  2012-04-09  9:09     ` Dong Aisheng
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2012-04-09  3:31 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Dong Aisheng, linux-kernel, linux-arm-kernel, Linus WALLEIJ

On 4/6/2012 9:02 PM, Stephen Warren wrote:
> On 04/06/2012 06:18 AM, Dong Aisheng wrote:
>> > From: Dong Aisheng <dong.aisheng@linaro.org>
>> > 
>> > Do not use get_functions_count before checking.
>> > 
>> > Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> Acked-by: Stephen Warren <swarren@wwwdotorg.org>
> 
> IIRC, Viresh added some other get_*_count() functions in the same patch.
> Do we need any more fixes similar to the this for those too?

Might not be required as this patch handles the pinmux_check_ops() routine.
At other places ops is guaranteed to have correct value.

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking
  2012-04-09  3:31   ` Viresh Kumar
@ 2012-04-09  9:09     ` Dong Aisheng
  0 siblings, 0 replies; 4+ messages in thread
From: Dong Aisheng @ 2012-04-09  9:09 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Stephen Warren, Dong Aisheng-B29396, linux-kernel,
	linux-arm-kernel, Linus WALLEIJ

On Mon, Apr 09, 2012 at 11:31:03AM +0800, Viresh Kumar wrote:
> On 4/6/2012 9:02 PM, Stephen Warren wrote:
> > On 04/06/2012 06:18 AM, Dong Aisheng wrote:
> >> > From: Dong Aisheng <dong.aisheng@linaro.org>
> >> > 
> >> > Do not use get_functions_count before checking.
> >> > 
> >> > Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> > Acked-by: Stephen Warren <swarren@wwwdotorg.org>
> > 
> > IIRC, Viresh added some other get_*_count() functions in the same patch.
> > Do we need any more fixes similar to the this for those too?
> 
> Might not be required as this patch handles the pinmux_check_ops() routine.
> At other places ops is guaranteed to have correct value.
> 
Yes, core can guarantee it after pinmux_check_ops.
But i noticed for user interfaces, we may still need add some error checking
to avoid kernel oops like pinctrl_get_* and debugfs interfaces in case
the mux or config function is not supported by driver.
I'm going to send one more patch to fix it.

Regards
Dong Aisheng


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-09  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-06 12:18 [PATCH 1/1] pinctrl: fix pinmux_check_ops error checking Dong Aisheng
2012-04-06 15:32 ` Stephen Warren
2012-04-09  3:31   ` Viresh Kumar
2012-04-09  9:09     ` Dong Aisheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).