2014-02-05 06:51:33

by Florian Vaussard

[permalink] [raw]
Subject: [PATCH] pinctrl: do not init debugfs entries for unimplemented functionalities

Commit c420619 "pinctrl: pinconf: remove checks on ops->pin_config_get"
removed the check on (ops != NULL) when performing pinconf_pins_show() or
pinconf_groups_show(). As these entries are always enabled, even if
pinconf is not supported, reading will result in an oops due to NULL
ops.

Instead of checking for ops, remove the corresponding debugfs entries if
pinconf and/or pinmux are not implemented.

Tested on OMAP3 (pinctrl-single).

Signed-off-by: Florian Vaussard <[email protected]>
---
drivers/pinctrl/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 5ee61a4..3f64c01 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1642,8 +1642,10 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
device_root, pctldev, &pinctrl_groups_ops);
debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO,
device_root, pctldev, &pinctrl_gpioranges_ops);
- pinmux_init_device_debugfs(device_root, pctldev);
- pinconf_init_device_debugfs(device_root, pctldev);
+ if (pctldev->desc->pmxops)
+ pinmux_init_device_debugfs(device_root, pctldev);
+ if (pctldev->desc->confops)
+ pinconf_init_device_debugfs(device_root, pctldev);
}

static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
--
1.8.5.3


2014-02-06 12:48:14

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: do not init debugfs entries for unimplemented functionalities

On Wed, Feb 5, 2014 at 7:51 AM, Florian Vaussard
<[email protected]> wrote:

> Commit c420619 "pinctrl: pinconf: remove checks on ops->pin_config_get"
> removed the check on (ops != NULL) when performing pinconf_pins_show() or
> pinconf_groups_show(). As these entries are always enabled, even if
> pinconf is not supported, reading will result in an oops due to NULL
> ops.
>
> Instead of checking for ops, remove the corresponding debugfs entries if
> pinconf and/or pinmux are not implemented.
>
> Tested on OMAP3 (pinctrl-single).
>
> Signed-off-by: Florian Vaussard <[email protected]>

Oh that was an elegant fix, thanks!
Patch applied for fixes, tagged for stable.

Yours,
Linus Walleij