From: Sebastian Frias <sf84@laposte.net>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Sergei Shtylyov" <sergei.shtylyov@cogentembedded.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
mason <slash.tmp@free.fr>, Daniel Mack <zonque@gmail.com>
Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB
Date: Tue, 22 Mar 2016 15:53:51 +0100 [thread overview]
Message-ID: <56F15C7F.9060404@laposte.net> (raw)
In-Reply-To: <20160321204111.GB6191@pengutronix.de>
Hi,
On 03/21/2016 09:41 PM, Uwe Kleine-König wrote:
>> My patch basically gets rid of all this code. The thing that worries me
>> is that the driver assumes that the reset singal is active low, despite what
>> the GPIO specifier in the device tree has for the GPIO polarity. In fact, it
>> will only work correctly if the specified has GPIO_ACTIVE_HIGH -- which is
>> wrong because the reset signal is active low!
>
> Note that gpio descriptors handle the polarity just fine (i.e. the pin
> is set to 0 after doing gpiod_set_value(1) if the gpio is active low).
>
Isn't that source of bugs?
What about using some #define (or probably better, an enum)?, something
like:
gpiod_set_value(gpiod, GPIO_SET_VALUE_ACTIVE)
gpiod_set_value(gpiod, GPIO_SET_VALUE_INACTIVE)
gpiod_set_value(gpiod, GPIO_SET_VALUE_TRISTATE)
then, somebody reading the code would have to stop and think what do
these mean.
IIUC, currently the "0" or "1" can easily be confused with the actual
logical value of the GPIO.
gpiod_set_value() could also return an int with the actual value it
applied to the GPIO.
For example: if gpiod is active low, gpiod_set_value(gpiod,
GPIO_SET_VALUE_ACTIVE) would return 0;
Conversely, if gpiod is active high, gpiod_set_value(gpiod,
GPIO_SET_VALUE_ACTIVE) would return 1;
Best regards,
Sebastian
> But having said that, the driver gets it wrong.
>
> The right sequence to reset a device using a gpio is:
>
> gpiod_set_value(priv->gpiod_reset, 1);
> msleep(some_time);
> gpiod_set_value(priv->gpiod_reset, 0);
>
> and if the gpio is active low, this should be specified in the device
> tree. This was done wrong in 13a56b449325 (net: phy: at803x: Add support
> for hardware reset).
>
> Best regards
> Uwe
>
next prev parent reply other threads:[~2016-03-22 14:54 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 ` [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 [this message]
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=56F15C7F.9060404@laposte.net \
--to=sf84@laposte.net \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=slash.tmp@free.fr \
--cc=u.kleine-koenig@pengutronix.de \
--cc=zonque@gmail.com \
/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