Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752920AbcCRQTI (ORCPT ); Fri, 18 Mar 2016 12:19:08 -0400 Received: from smtpoutz25.laposte.net ([194.117.213.100]:51515 "EHLO smtp.laposte.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752645AbcCRQTE (ORCPT ); Fri, 18 Mar 2016 12:19:04 -0400 X-Greylist: delayed 1358 seconds by postgrey-1.27 at vger.kernel.org; Fri, 18 Mar 2016 12:19:03 EDT Message-ID: <56EC2525.8000706@laposte.net> Date: Fri, 18 Mar 2016 16:56:21 +0100 From: Sebastian Frias User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: =?windows-1252?Q?Uwe_Kleine-K=F6nig?= , Daniel Mack CC: "David S. Miller" , netdev@vger.kernel.org, lkml , mason , Florian Fainelli , Mans Rullgard , Fabio Estevam , Martin Blumenstingl , Linus Walleij Subject: Re: [PATCH] net: phy: at803x: don't depend on GPIOLIB References: <56E99727.9040702@laposte.net> <20160318125455.GN4292@pengutronix.de> In-Reply-To: <20160318125455.GN4292@pengutronix.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-VR-SrcIP: 83.142.147.193 X-VR-FullState: 0 X-VR-Score: -100 X-VR-Cause-1: gggruggvucftvghtrhhoucdtuddrfeekkedrtdehgddvudduucetufdoteggodetrfdotffvucfrrhho X-VR-Cause-2: fhhilhgvmecunfetrffquffvgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhht X-VR-Cause-3: shculddquddttddmnecujfgurhepkfffhfgfggfvufhfjggtgfesthekrgdttdefheenucfhrhhomhep X-VR-Cause-4: ufgvsggrshhtihgrnhcuhfhrihgrshcuoehsfhekgeeslhgrphhoshhtvgdrnhgvtheqnecukfhppeek X-VR-Cause-5: fedrudegvddrudegjedrudelfeenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopegl X-VR-Cause-6: udejvddrvdejrddtrddvudegngdpihhnvghtpeekfedrudegvddrudegjedrudelfedpmhgrihhlfhhr X-VR-Cause-7: ohhmpehsfhekgeeslhgrphhoshhtvgdrnhgvthdprhgtphhtthhopehurdhklhgvihhnvgdqkhhovghn X-VR-Cause-8: ihhgsehpvghnghhuthhrohhnihigrdguvg X-VR-AvState: No X-VR-State: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3709 Lines: 107 Hi Uwe, Daniel, On 03/18/2016 01:54 PM, Uwe Kleine-K?nig wrote: > [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 >> --- >> 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). Well, from the code, the reset hack is only required when the PHY is ATH8030_PHY_ID, right? However, such change was introduced by Daniel Mack on commit 13a56b449325. Hopefully he can chime in and give his opinion on this. Daniel, while on the subject, I have a question for you: Change 2b8f2a28eac1 introduced "link_status_notify" callback which is called systematically on the PHY state machine. Any reason to make the call systematic as opposed to let say: if (phydev->state != old_state) { if (phydev->drv->link_change_notify) phydev->drv->link_change_notify(phydev); } (it does means that the callback would be called after the state machine processing though) > > With 687908c2b649 I made kernels without GPIOLIB fail to bind this > device. I admit this is not maximally nice. I see, that was not clear from the commit message, sorry. > > 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. It was one of the solutions I had in mind, but: - since the dependency on GPIOLIB was not included on the patch - and given that the previous code had provision to work without GPIO I thought it was an overlook. >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. Let's say that was the case, what would the PHY code do? I mean, it did not get a GPIO, whether it was because GPIOLIB=n or because there's no 'reset' GPIO attached Shall it fail? Shall it continue in a sort of degraded mode? Shall it warn? Because that's the real question here. What would you think of making at803x_link_change_notify() print a message every time it should do a reset but does not has a way to do it? I can make such change to my patch if everybody agrees on it. By the way, in that case, can somebody suggest a way to print such warning? Would printk() be ok or should I use dev_dbg() ? Best regards, Sebastian > > Best regards > Uwe >