linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] pinctrl: add some error checking for user interfaces
@ 2012-04-09 10:30 Dong Aisheng
  2012-04-09 15:03 ` Stephen Warren
  0 siblings, 1 reply; 4+ messages in thread
From: Dong Aisheng @ 2012-04-09 10:30 UTC (permalink / raw)
  To: linux-arm-kernel

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

This patch can avoid kernel oops in case the mux or config
function is not supported by driver.

Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
 drivers/pinctrl/pinconf.c |    4 ++++
 drivers/pinctrl/pinmux.c  |   15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index eb3a14f..384dcc1 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -448,8 +448,12 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
 static int pinconf_pins_show(struct seq_file *s, void *what)
 {
 	struct pinctrl_dev *pctldev = s->private;
+	const struct pinconf_ops *ops = pctldev->desc->confops;
 	unsigned i, pin;
 
+	if (!ops || !ops->pin_config_get)
+		return 0;
+
 	seq_puts(s, "Pin config settings per pin\n");
 	seq_puts(s, "Format: pin (name): pinmux setting array\n");
 
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 8849830..ade661d 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -323,6 +323,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
 	const unsigned *pins;
 	unsigned num_pins;
 
+	if (!pmxops) {
+		dev_err(pctldev->dev, "dose not support mux functron\n");
+		return -EINVAL;
+	}
+
 	setting->data.mux.func =
 		pinmux_func_name_to_selector(pctldev, map->data.mux.function);
 	if (setting->data.mux.func < 0)
@@ -481,11 +486,14 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
 {
 	struct pinctrl_dev *pctldev = s->private;
 	const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
-	unsigned nfuncs = pmxops->get_functions_count(pctldev);
+	unsigned nfuncs;
 	unsigned func_selector = 0;
 
-	mutex_lock(&pinctrl_mutex);
+	if (!pmxops)
+		return 0;
 
+	mutex_lock(&pinctrl_mutex);
+	nfuncs = pmxops->get_functions_count(pctldev);
 	while (func_selector < nfuncs) {
 		const char *func = pmxops->get_function_name(pctldev,
 							  func_selector);
@@ -520,6 +528,9 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
 	const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
 	unsigned i, pin;
 
+	if (!pmxops)
+		return 0;
+
 	seq_puts(s, "Pinmux settings per pin\n");
 	seq_puts(s, "Format: pin (name): mux_owner gpio_owner hog?\n");
 
-- 
1.7.0.4

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

* [PATCH 1/1] pinctrl: add some error checking for user interfaces
  2012-04-09 10:30 [PATCH 1/1] pinctrl: add some error checking for user interfaces Dong Aisheng
@ 2012-04-09 15:03 ` Stephen Warren
  2012-04-10  3:49   ` Dong Aisheng
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Warren @ 2012-04-09 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/09/2012 04:30 AM, Dong Aisheng wrote:
> From: Dong Aisheng <dong.aisheng@linaro.org>
> 
> This patch can avoid kernel oops in case the mux or config
> function is not supported by driver.
> 
> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> ---
>  drivers/pinctrl/pinconf.c |    4 ++++
>  drivers/pinctrl/pinmux.c  |   15 +++++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
> index eb3a14f..384dcc1 100644
> --- a/drivers/pinctrl/pinconf.c
> +++ b/drivers/pinctrl/pinconf.c
> @@ -448,8 +448,12 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
>  static int pinconf_pins_show(struct seq_file *s, void *what)
>  {
>  	struct pinctrl_dev *pctldev = s->private;
> +	const struct pinconf_ops *ops = pctldev->desc->confops;
>  	unsigned i, pin;
>  
> +	if (!ops || !ops->pin_config_get)
> +		return 0;

I don't think this is necessary; it looks like this function (and those
it calls) always checks ops where they're used.

> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index 8849830..ade661d 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -323,6 +323,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
>  	const unsigned *pins;
>  	unsigned num_pins;
>  
> +	if (!pmxops) {
> +		dev_err(pctldev->dev, "dose not support mux functron\n");

s/dose/does/
s/functron/function/

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

* [PATCH 1/1] pinctrl: add some error checking for user interfaces
  2012-04-10  3:49   ` Dong Aisheng
@ 2012-04-10  3:44     ` Stephen Warren
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Warren @ 2012-04-10  3:44 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/09/2012 09:49 PM, Dong Aisheng wrote:
> On Mon, Apr 09, 2012 at 11:03:06PM +0800, Stephen Warren wrote:
>> On 04/09/2012 04:30 AM, Dong Aisheng wrote:
>>> From: Dong Aisheng <dong.aisheng@linaro.org>
>>>
>>> This patch can avoid kernel oops in case the mux or config
>>> function is not supported by driver.
...
>>>  static int pinconf_pins_show(struct seq_file *s, void *what)
>>>  {
>>>  	struct pinctrl_dev *pctldev = s->private;
>>> +	const struct pinconf_ops *ops = pctldev->desc->confops;
>>>  	unsigned i, pin;
>>>  
>>> +	if (!ops || !ops->pin_config_get)
>>> +		return 0;
>>
>> I don't think this is necessary; it looks like this function (and those
>> it calls) always checks ops where they're used.
>
> Yes, it's true.
> But it will still dump all pins configs although there's no config value
> which is almost the same as another debug entry 'pins'.
> It looks it does not make too much sense to dump this info if no config support.
> The existing pinconf_group_show did like this way(no output).
> So i changed pinconf_pins_show in the same behavior as pinconf_group_show.
> 
> Do you think it's reasonable?

OK, I guess so.

I was thinking the file wouldn't be compiled without pin config support,
but that's only the core support and doesn't necessarily imply the
individual driver has support.

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

* [PATCH 1/1] pinctrl: add some error checking for user interfaces
  2012-04-09 15:03 ` Stephen Warren
@ 2012-04-10  3:49   ` Dong Aisheng
  2012-04-10  3:44     ` Stephen Warren
  0 siblings, 1 reply; 4+ messages in thread
From: Dong Aisheng @ 2012-04-10  3:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 09, 2012 at 11:03:06PM +0800, Stephen Warren wrote:
> On 04/09/2012 04:30 AM, Dong Aisheng wrote:
> > From: Dong Aisheng <dong.aisheng@linaro.org>
> > 
> > This patch can avoid kernel oops in case the mux or config
> > function is not supported by driver.
> > 
> > Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
> > ---
> >  drivers/pinctrl/pinconf.c |    4 ++++
> >  drivers/pinctrl/pinmux.c  |   15 +++++++++++++--
> >  2 files changed, 17 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
> > index eb3a14f..384dcc1 100644
> > --- a/drivers/pinctrl/pinconf.c
> > +++ b/drivers/pinctrl/pinconf.c
> > @@ -448,8 +448,12 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
> >  static int pinconf_pins_show(struct seq_file *s, void *what)
> >  {
> >  	struct pinctrl_dev *pctldev = s->private;
> > +	const struct pinconf_ops *ops = pctldev->desc->confops;
> >  	unsigned i, pin;
> >  
> > +	if (!ops || !ops->pin_config_get)
> > +		return 0;
> 
> I don't think this is necessary; it looks like this function (and those
> it calls) always checks ops where they're used.
> 
Yes, it's true.
But it will still dump all pins configs although there's no config value
which is almost the same as another debug entry 'pins'.
It looks it does not make too much sense to dump this info if no config support.
The existing pinconf_group_show did like this way(no output).
So i changed pinconf_pins_show in the same behavior as pinconf_group_show.

Do you think it's reasonable?

Regards
Dong Aisheng

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

end of thread, other threads:[~2012-04-10  3:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-09 10:30 [PATCH 1/1] pinctrl: add some error checking for user interfaces Dong Aisheng
2012-04-09 15:03 ` Stephen Warren
2012-04-10  3:49   ` Dong Aisheng
2012-04-10  3:44     ` Stephen Warren

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).