public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mason <slash.tmp@free.fr>
To: Sebastian Frias <sf84@laposte.net>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>,
	Daniel Mack <daniel@zonque.org>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.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: Wed, 23 Mar 2016 11:17:11 +0100	[thread overview]
Message-ID: <56F26D27.3020106@free.fr> (raw)
In-Reply-To: <20160322194224.GF6191@pengutronix.de>

On 22/03/2016 20:42, Uwe Kleine-König wrote:

> Preconditions:
>  - Some of the devices a given driver handles have a reset line and
>    others don't.
>  - A non-empty subset (maybe all) of the devices that have a reset line
>    require that this reset line is used.
> 
> Then the way to handle this in the driver should be done as follows:
> 
>   unless reset_handling_not_necessary():
>     gpio = gpiod_get_optional("reset")
>     if IS_ERR(gpio):
>       return PTR_ERR(gpio)
> 
> Checking for -ENOSYS or GPIOLIB=n is not allowed because the device
> you're currently handling might need the GPIO, so you must not continue
> without the ability to control the line.
> 
> So the options you have (as you have a phy that doesn't need the reset
> handling):
> 
>  - enable GPIOLIB (either in your .config or introduce a Kconfig
>    dependency)
>  - improve reset_handling_not_necessary() to return true for your case
> 
> There is nothing else.

Here are some numbers for GPIOLIB, on an ARM build:

   text	   data	    bss	    dec	    hex	filename
   1830	      0	      0	   1830	    726	devres.o
    627	      0	      0	    627	    273	gpiolib-legacy.o
  11018	     40	      4	  11062	   2b36	gpiolib.o
   1598	      0	      0	   1598	    63e	gpiolib-of.o
--------------------------------------------------------
  15073	     40	      4	  15117	   3b0d	built-in.o

So ~15 kilobytes.


By the way, since the "reset-by-GPIO" solution is used only for
the Atheros 8030, would it be possible to make the
devm_gpiod_get_optional conditional on ATH8030_PHY_ID?

I'm thinking of something along these lines, for illustration:

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 2d020a3ec0b5..576e7873e049 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -198,12 +198,16 @@ static int at803x_probe(struct phy_device *phydev)
        if (!priv)
                return -ENOMEM;
 
+       if (phydev->drv->phy_id != ATH8030_PHY_ID)
+               goto no_gpio;
+
        gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
        if (IS_ERR(gpiod_reset))
                return PTR_ERR(gpiod_reset);
 
        priv->gpiod_reset = gpiod_reset;
 
+no_gpio:
        phydev->priv = priv;
 
        return 0;


Regards.

  parent reply	other threads:[~2016-03-23 10:17 UTC|newest]

Thread overview: 31+ 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
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 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                   ` Mason [this message]
2016-03-23 10:39                     ` [PATCH] net: phy: at803x: don't depend on GPIOLIB 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=56F26D27.3020106@free.fr \
    --to=slash.tmp@free.fr \
    --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=sergei.shtylyov@cogentembedded.com \
    --cc=sf84@laposte.net \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox