[PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP

Peng Fan (OSS) posted 1 patch 1 year, 10 months ago
drivers/pinctrl/pinconf-generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP
Posted by Peng Fan (OSS) 1 year, 10 months ago
From: Peng Fan <peng.fan@nxp.com>

The SCMI error value SCMI_ERR_SUPPORT maps to linux error value
'-EOPNOTSUPP', so when dump configs, need check the error value
EOPNOTSUPP, otherwise there will be log "ERROR READING CONFIG SETTING".

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinconf-generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index cada5d18ffae..541c2ac9ffcb 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -75,7 +75,7 @@ static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev,
 		else
 			ret = pin_config_get_for_pin(pctldev, pin, &config);
 		/* These are legal errors */
-		if (ret == -EINVAL || ret == -ENOTSUPP)
+		if (ret == -EINVAL || ret == -ENOTSUPP || ret == -EOPNOTSUPP)
 			continue;
 		if (ret) {
 			seq_printf(s, "ERROR READING CONFIG SETTING %d ", i);
-- 
2.37.1
Re: [PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP
Posted by Linus Walleij 1 year, 10 months ago
On Mon, Apr 1, 2024 at 4:02 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:

> From: Peng Fan <peng.fan@nxp.com>
>
> The SCMI error value SCMI_ERR_SUPPORT maps to linux error value
> '-EOPNOTSUPP', so when dump configs, need check the error value
> EOPNOTSUPP, otherwise there will be log "ERROR READING CONFIG SETTING".
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
(...)
>                         ret = pin_config_get_for_pin(pctldev, pin, &config);
>                 /* These are legal errors */
> -               if (ret == -EINVAL || ret == -ENOTSUPP)
> +               if (ret == -EINVAL || ret == -ENOTSUPP || ret == -EOPNOTSUPP)

TBH it's a bit odd to call an in-kernel API such as pin_config_get_for_pin()
and get -EOPNOTSUPP back. But it's not like I care a lot, so patch applied.

Yours,
Linus Walleij
Re: [PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP
Posted by Andy Shevchenko 1 year, 10 months ago
On Thu, Apr 04, 2024 at 01:44:50PM +0200, Linus Walleij wrote:
> On Mon, Apr 1, 2024 at 4:02 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
> 
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > The SCMI error value SCMI_ERR_SUPPORT maps to linux error value
> > '-EOPNOTSUPP', so when dump configs, need check the error value
> > EOPNOTSUPP, otherwise there will be log "ERROR READING CONFIG SETTING".
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> (...)
> >                         ret = pin_config_get_for_pin(pctldev, pin, &config);
> >                 /* These are legal errors */
> > -               if (ret == -EINVAL || ret == -ENOTSUPP)
> > +               if (ret == -EINVAL || ret == -ENOTSUPP || ret == -EOPNOTSUPP)
> 
> TBH it's a bit odd to call an in-kernel API such as pin_config_get_for_pin()
> and get -EOPNOTSUPP back. But it's not like I care a lot, so patch applied.

Hmm... I would like actually to get this being consistent. The documentation
explicitly says that in-kernel APIs uses Linux error code and not POSIX one.

This check opens a Pandora box.

FWIW, it just like dozen or so drivers that needs to be fixed, I prefer to
have them being moved to ENOTSUPP, rather this patch.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP
Posted by Linus Walleij 1 year, 10 months ago
On Thu, Apr 4, 2024 at 7:05 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> On Thu, Apr 04, 2024 at 01:44:50PM +0200, Linus Walleij wrote:
> > On Mon, Apr 1, 2024 at 4:02 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
> >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > The SCMI error value SCMI_ERR_SUPPORT maps to linux error value
> > > '-EOPNOTSUPP', so when dump configs, need check the error value
> > > EOPNOTSUPP, otherwise there will be log "ERROR READING CONFIG SETTING".
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > (...)
> > >                         ret = pin_config_get_for_pin(pctldev, pin, &config);
> > >                 /* These are legal errors */
> > > -               if (ret == -EINVAL || ret == -ENOTSUPP)
> > > +               if (ret == -EINVAL || ret == -ENOTSUPP || ret == -EOPNOTSUPP)
> >
> > TBH it's a bit odd to call an in-kernel API such as pin_config_get_for_pin()
> > and get -EOPNOTSUPP back. But it's not like I care a lot, so patch applied.
>
> Hmm... I would like actually to get this being consistent. The documentation
> explicitly says that in-kernel APIs uses Linux error code and not POSIX one.
>
> This check opens a Pandora box.
>
> FWIW, it just like dozen or so drivers that needs to be fixed, I prefer to
> have them being moved to ENOTSUPP, rather this patch.

Andy is one of the wisest men I know so I have taken out the patch.

Peng, what about fixing the problem at its source? Patch away,
we will help you if need be.

Yours,
Linus Walleij
Re: [PATCH] pinctrl: pinconf-generic: check error value EOPNOTSUPP
Posted by Andy Shevchenko 1 year, 10 months ago
On Thu, Apr 04, 2024 at 09:03:02PM +0200, Linus Walleij wrote:
> On Thu, Apr 4, 2024 at 7:05 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Thu, Apr 04, 2024 at 01:44:50PM +0200, Linus Walleij wrote:
> > > On Mon, Apr 1, 2024 at 4:02 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
> > >
> > > > From: Peng Fan <peng.fan@nxp.com>
> > > >
> > > > The SCMI error value SCMI_ERR_SUPPORT maps to linux error value
> > > > '-EOPNOTSUPP', so when dump configs, need check the error value
> > > > EOPNOTSUPP, otherwise there will be log "ERROR READING CONFIG SETTING".
> > > >
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > (...)
> > > >                         ret = pin_config_get_for_pin(pctldev, pin, &config);
> > > >                 /* These are legal errors */
> > > > -               if (ret == -EINVAL || ret == -ENOTSUPP)
> > > > +               if (ret == -EINVAL || ret == -ENOTSUPP || ret == -EOPNOTSUPP)
> > >
> > > TBH it's a bit odd to call an in-kernel API such as pin_config_get_for_pin()
> > > and get -EOPNOTSUPP back. But it's not like I care a lot, so patch applied.
> >
> > Hmm... I would like actually to get this being consistent. The documentation
> > explicitly says that in-kernel APIs uses Linux error code and not POSIX one.
> >
> > This check opens a Pandora box.
> >
> > FWIW, it just like dozen or so drivers that needs to be fixed, I prefer to
> > have them being moved to ENOTSUPP, rather this patch.

$ git grep -lw EOPNOTSUPP -- drivers/pinctrl/ drivers/gpio/
drivers/gpio/gpio-crystalcove.c
drivers/gpio/gpio-pcie-idio-24.c
drivers/gpio/gpio-regmap.c
drivers/gpio/gpio-wcove.c
// drivers/gpio/gpiolib-cdev.c <<< Here it goes to user space, no need to fix
drivers/pinctrl/actions/pinctrl-s500.c
drivers/pinctrl/mediatek/mtk-eint.c
drivers/pinctrl/mediatek/mtk-eint.h
drivers/pinctrl/nxp/pinctrl-s32cc.c
drivers/pinctrl/pinctrl-at91-pio4.c
// drivers/pinctrl/pinctrl-aw9523.c <<< Should be fixed in Linus' tree by me
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/renesas/pinctrl-rzg2l.c
drivers/pinctrl/renesas/pinctrl-rzv2m.c
drivers/pinctrl/sunplus/sppctl.c
drivers/pinctrl/visconti/pinctrl-common.c

> Andy is one of the wisest men I know so I have taken out the patch.
> 
> Peng, what about fixing the problem at its source? Patch away,
> we will help you if need be.

Indeed.

-- 
With Best Regards,
Andy Shevchenko