All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sebastian Frias <sf84@laposte.net>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	mason <slash.tmp@free.fr>, Daniel Mack <daniel@zonque.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Mans Rullgard <mans@mansr.com>,
	Fabio Estevam <festevam@gmail.com>,
	Martin Blumenstingl <martin.blumenstingl@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB
Date: Fri, 18 Mar 2016 13:54:55 +0100	[thread overview]
Message-ID: <20160318125455.GN4292@pengutronix.de> (raw)
In-Reply-To: <56E99727.9040702@laposte.net>

[expand cc a bit more]

Hello,

On Wed, Mar 16, 2016 at 06:25:59PM +0100, Sebastian Frias wrote:
> Commit 687908c2b649 ("net: phy: at803x: simplify using
> devm_gpiod_get_optional and its 4th argument") introduced a dependency
> on GPIOLIB that was not there before.
> 
> This commit removes such dependency by checking the return code and
> comparing it against ENOSYS which is returned when GPIOLIB is not
> selected.
> 
> Fixes: 687908c2b649 ("net: phy: at803x: simplify using devm_gpiod_get_optional and its 4th argument")
> 
> Signed-off-by: Sebastian Frias <sf84@laposte.net>
> ---
>  drivers/net/phy/at803x.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 2174ec9..88b7ff3 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -252,7 +252,9 @@ static int at803x_probe(struct phy_device *phydev)
>  		return -ENOMEM;
> 
>  	gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> -	if (IS_ERR(gpiod_reset))
> +	if (PTR_ERR(gpiod_reset) == -ENOSYS)
> +		gpiod_reset = NULL;
> +	else if (IS_ERR(gpiod_reset))

this isn't better either (IMHO it's worse, but maybe this is debatable
and also depends on your POV).

With 687908c2b649 I made kernels without GPIOLIB fail to bind this
device. I admit this is not maximally nice.

Your change makes the driver bind in this case again and then the reset
gpio isn't handled at all which might result in a later and harder to
debug error.

The better approach to fix your problem is: make the driver depend (or
force) on GPIOLIB. Or alternatively, drop reset-handling from the
driver.

>From a driver perspecitive, it would be nice if devm_gpiod_get_optional
returned NULL iff the respective gpio isn't specified even with
GPIOLIB=n, but this isn't sensible either because it would result in
quite some gpiolib code to not being conditionally compiled on
CONFIG_GPIOLIB any more.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

WARNING: multiple messages have this Message-ID (diff)
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sebastian Frias <sf84@laposte.net>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	mason <slash.tmp@free.fr>, Daniel Mack <daniel@zonque.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Mans Rullgard <mans@mansr.com>,
	Fabio Estevam <festevam@gmail.com>,
	Martin Blumenstingl <martin.blumenstingl@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB
Date: Fri, 18 Mar 2016 13:54:55 +0100	[thread overview]
Message-ID: <20160318125455.GN4292@pengutronix.de> (raw)
In-Reply-To: <56E99727.9040702@laposte.net>

[expand cc a bit more]

Hello,

On Wed, Mar 16, 2016 at 06:25:59PM +0100, Sebastian Frias wrote:
> Commit 687908c2b649 ("net: phy: at803x: simplify using
> devm_gpiod_get_optional and its 4th argument") introduced a dependency
> on GPIOLIB that was not there before.
> 
> This commit removes such dependency by checking the return code and
> comparing it against ENOSYS which is returned when GPIOLIB is not
> selected.
> 
> Fixes: 687908c2b649 ("net: phy: at803x: simplify using devm_gpiod_get_optional and its 4th argument")
> 
> Signed-off-by: Sebastian Frias <sf84@laposte.net>
> ---
>  drivers/net/phy/at803x.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 2174ec9..88b7ff3 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -252,7 +252,9 @@ static int at803x_probe(struct phy_device *phydev)
>  		return -ENOMEM;
> 
>  	gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> -	if (IS_ERR(gpiod_reset))
> +	if (PTR_ERR(gpiod_reset) == -ENOSYS)
> +		gpiod_reset = NULL;
> +	else if (IS_ERR(gpiod_reset))

this isn't better either (IMHO it's worse, but maybe this is debatable
and also depends on your POV).

With 687908c2b649 I made kernels without GPIOLIB fail to bind this
device. I admit this is not maximally nice.

Your change makes the driver bind in this case again and then the reset
gpio isn't handled at all which might result in a later and harder to
debug error.

The better approach to fix your problem is: make the driver depend (or
force) on GPIOLIB. Or alternatively, drop reset-handling from the
driver.

From a driver perspecitive, it would be nice if devm_gpiod_get_optional
returned NULL iff the respective gpio isn't specified even with
GPIOLIB=n, but this isn't sensible either because it would result in
quite some gpiolib code to not being conditionally compiled on
CONFIG_GPIOLIB any more.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  parent reply	other threads:[~2016-03-18 12:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 17:25 [PATCH] net: phy: at803x: don't depend on GPIOLIB Sebastian Frias
2016-03-18 12:12 ` Mason
2016-03-18 12:54 ` Uwe Kleine-König [this message]
2016-03-18 12:54   ` Uwe Kleine-König
2016-03-18 15:56   ` Sebastian Frias
2016-03-18 19:12     ` Uwe Kleine-König
2016-03-18 19:31       ` Mason
2016-03-18 20:11         ` Uwe Kleine-König
2016-03-18 20:44           ` Mason
2016-03-19 10:01             ` Måns Rullgård
2016-03-21 12:48       ` Sebastian Frias
2016-03-21 12:48         ` Sebastian Frias
2016-03-21 13:54         ` Uwe Kleine-König
2016-03-21 15:36           ` Sebastian Frias
2016-03-21 20:12             ` Uwe Kleine-König
2016-03-22 14:34               ` Sebastian Frias
2016-03-22 19:42                 ` Uwe Kleine-König
2016-03-23 10:12                   ` Sebastian Frias
2016-03-23 10:49                     ` [PATCH] net: phy: at803x: Request 'reset' GPIO only for AT8030 PHY Sebastian Frias
2016-03-23 17:40                       ` David Miller
2016-03-23 19:42                       ` Sergei Shtylyov
2016-03-24  9:55                         ` Sebastian Frias
2016-03-24 10:10                           ` Sebastian Frias
2016-03-24 13:40                             ` Sergei Shtylyov
2016-03-23 10:17                   ` [PATCH] net: phy: at803x: don't depend on GPIOLIB Mason
2016-03-23 10:39                     ` Sergei Shtylyov
2016-03-23 10:55                       ` Sebastian Frias
2016-03-22 14:34     ` Sebastian Frias
2016-03-21 20:15 ` Sergei Shtylyov
2016-03-21 20:41   ` Uwe Kleine-König
2016-03-21 21:56     ` Sergei Shtylyov
2016-03-22 14:53     ` Sebastian Frias
2016-03-22 14:39   ` Sebastian Frias

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160318125455.GN4292@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=daniel@zonque.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=festevam@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=martin.blumenstingl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sf84@laposte.net \
    --cc=slash.tmp@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.