Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757831AbcCUUPV (ORCPT ); Mon, 21 Mar 2016 16:15:21 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:34124 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755746AbcCUUPT (ORCPT ); Mon, 21 Mar 2016 16:15:19 -0400 Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB To: Sebastian Frias , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "David S. Miller" , netdev@vger.kernel.org References: <56E99727.9040702@laposte.net> Cc: lkml , mason From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <56F05651.3030706@cogentembedded.com> Date: Mon, 21 Mar 2016 23:15:13 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56E99727.9040702@laposte.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1816 Lines: 48 Hello. On 03/16/2016 08:25 PM, 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 Do you have the PHY that requires the GPIO reset workaround? Askinjg because I have the patch adding the "reset-gpios" prop handling to phylib and your patch made me aware that I'll have to modify this driver in order to do that... > --- > 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)) return PTR_ERR(gpiod_reset); 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! Can you point me to an actual device tree using this erratic PHY? WBR, Sergei