[v2,1/3] net/fec: change phy-reset-gpio request warning to debug message

Message ID 1316603432-20032-2-git-send-email-shawn.guo@linaro.org
State New
Headers show

Commit Message

Shawn Guo Sept. 21, 2011, 11:10 a.m.
FEC can work without a phy reset on some platforms, which means not
very platform necessarily have a phy-reset gpio encoded in device tree.
So it makes more sense to have the phy-reset-gpio request failure as
a debug message rather than a warning.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/net/ethernet/freescale/fec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Wolfram Sang Sept. 21, 2011, 11:25 a.m. | #1
Hi Shawn,

On Wed, Sep 21, 2011 at 07:10:30PM +0800, Shawn Guo wrote:
> FEC can work without a phy reset on some platforms, which means not
> very platform necessarily have a phy-reset gpio encoded in device tree.
> So it makes more sense to have the phy-reset-gpio request failure as
> a debug message rather than a warning.

Or remove it entirely?

> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/net/ethernet/freescale/fec.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
> index 158b82e..a057abf 100644
> --- a/drivers/net/ethernet/freescale/fec.c
> +++ b/drivers/net/ethernet/freescale/fec.c
> @@ -1422,7 +1422,7 @@ static int __devinit fec_reset_phy(struct platform_device *pdev)
>  	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
>  	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
>  	if (err) {
> -		pr_warn("FEC: failed to get gpio phy-reset: %d\n", err);
> +		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
>  		return err;

I also wanted to suggested to drop returning the error code, since it is
not an error anymore, strictly speaking. Then I noticed that the caller
does not check the error code. So, this could be added or turn the
function to void?

>  	}
>  	msleep(1);
> -- 
> 1.7.4.1
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo Sept. 21, 2011, 12:03 p.m. | #2
On Wed, Sep 21, 2011 at 01:25:55PM +0200, Wolfram Sang wrote:
> Hi Shawn,
> 
> On Wed, Sep 21, 2011 at 07:10:30PM +0800, Shawn Guo wrote:
> > FEC can work without a phy reset on some platforms, which means not
> > very platform necessarily have a phy-reset gpio encoded in device tree.
> > So it makes more sense to have the phy-reset-gpio request failure as
> > a debug message rather than a warning.
> 
> Or remove it entirely?
> 
I would like to keep it.  When people want to debug at this point, they
do not need to type the debug message.

> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  drivers/net/ethernet/freescale/fec.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
> > index 158b82e..a057abf 100644
> > --- a/drivers/net/ethernet/freescale/fec.c
> > +++ b/drivers/net/ethernet/freescale/fec.c
> > @@ -1422,7 +1422,7 @@ static int __devinit fec_reset_phy(struct platform_device *pdev)
> >  	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
> >  	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
> >  	if (err) {
> > -		pr_warn("FEC: failed to get gpio phy-reset: %d\n", err);
> > +		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
> >  		return err;
> 
> I also wanted to suggested to drop returning the error code, since it is
> not an error anymore, strictly speaking. Then I noticed that the caller
> does not check the error code. So, this could be added or turn the
> function to void?
> 
To me, keep the return value as integer is more scalable.  Someday,
someone need to add more stuff in the function, or want to improve
the caller to check return value, it plays.

Regards,
Shawn

> >  	}
> >  	msleep(1);
> > --
Wolfram Sang Sept. 21, 2011, 12:11 p.m. | #3
On Wed, Sep 21, 2011 at 08:03:42PM +0800, Shawn Guo wrote:
> On Wed, Sep 21, 2011 at 01:25:55PM +0200, Wolfram Sang wrote:
> > Hi Shawn,
> > 
> > On Wed, Sep 21, 2011 at 07:10:30PM +0800, Shawn Guo wrote:
> > > FEC can work without a phy reset on some platforms, which means not
> > > very platform necessarily have a phy-reset gpio encoded in device tree.
> > > So it makes more sense to have the phy-reset-gpio request failure as
> > > a debug message rather than a warning.
> > 
> > Or remove it entirely?
> > 
> I would like to keep it.  When people want to debug at this point, they
> do not need to type the debug message.

I just think the message might be confusing in case you don't need the
gpio, because then failing is expected behaviour. For those platforms,
it is not even an error then, so you must drop returning the error. To
be very precise, you should check of_get_named_gpio() and return if no
gpio is specified. Then, you can distinguish that case from problems
when getting the GPIO.

> > I also wanted to suggested to drop returning the error code, since it is
> > not an error anymore, strictly speaking. Then I noticed that the caller
> > does not check the error code. So, this could be added or turn the
> > function to void?
> > 
> To me, keep the return value as integer is more scalable.  Someday,
> someone need to add more stuff in the function, or want to improve
> the caller to check return value, it plays.

I agree that keeping it int is way better. But why not add it now to
keep things proper and tested? If this patch gets accepted as it is and
later someone else will add error checking to the caller, your platform
will lose FEC support as a regression.
Shawn Guo Sept. 21, 2011, 12:44 p.m. | #4
On Wed, Sep 21, 2011 at 02:11:59PM +0200, Wolfram Sang wrote:
> On Wed, Sep 21, 2011 at 08:03:42PM +0800, Shawn Guo wrote:
> > On Wed, Sep 21, 2011 at 01:25:55PM +0200, Wolfram Sang wrote:
> > > Hi Shawn,
> > > 
> > > On Wed, Sep 21, 2011 at 07:10:30PM +0800, Shawn Guo wrote:
> > > > FEC can work without a phy reset on some platforms, which means not
> > > > very platform necessarily have a phy-reset gpio encoded in device tree.
> > > > So it makes more sense to have the phy-reset-gpio request failure as
> > > > a debug message rather than a warning.
> > > 
> > > Or remove it entirely?
> > > 
> > I would like to keep it.  When people want to debug at this point, they
> > do not need to type the debug message.
> 
> I just think the message might be confusing in case you don't need the
> gpio, because then failing is expected behaviour. For those platforms,
> it is not even an error then, so you must drop returning the error. To
> be very precise, you should check of_get_named_gpio() and return if no
> gpio is specified. Then, you can distinguish that case from problems
> when getting the GPIO.
> 
The whole fec_reset_phy() should not be a show-stopper failure.  Even
on platforms that have the gpio, FEC can work without resetting the
phy in FEC driver for some cases, for example, boot loader has done it.
It might be good enough to give a warning message rather than getting
the probe fail.

> > > I also wanted to suggested to drop returning the error code, since it is
> > > not an error anymore, strictly speaking. Then I noticed that the caller
> > > does not check the error code. So, this could be added or turn the
> > > function to void?
> > > 
> > To me, keep the return value as integer is more scalable.  Someday,
> > someone need to add more stuff in the function, or want to improve
> > the caller to check return value, it plays.
> 
> I agree that keeping it int is way better. But why not add it now to
> keep things proper and tested? If this patch gets accepted as it is and
> later someone else will add error checking to the caller, your platform
> will lose FEC support as a regression.
> 
Again, fec_reset_phy() failure is not a show-stopper.  We might not
want to make the probe fail because of that.
Wolfram Sang Sept. 21, 2011, 12:59 p.m. | #5
> > I agree that keeping it int is way better. But why not add it now to
> > keep things proper and tested? If this patch gets accepted as it is and
> > later someone else will add error checking to the caller, your platform
> > will lose FEC support as a regression.
> > 
> Again, fec_reset_phy() failure is not a show-stopper.  We might not
> want to make the probe fail because of that.

That would be an argument to make the function returning void?

Well, I still think something like 

	/* No phy reset configured */
	if (phy_reset == -ENODEV)
		return 0;

might be cleaner, yet I don't have the setup to test such an approach.

So, I'll be quiet now and hope for no problems.
Shawn Guo Sept. 21, 2011, 1:18 p.m. | #6
On Wed, Sep 21, 2011 at 02:59:05PM +0200, Wolfram Sang wrote:
> > > I agree that keeping it int is way better. But why not add it now to
> > > keep things proper and tested? If this patch gets accepted as it is and
> > > later someone else will add error checking to the caller, your platform
> > > will lose FEC support as a regression.
> > > 
> > Again, fec_reset_phy() failure is not a show-stopper.  We might not
> > want to make the probe fail because of that.
> 
> That would be an argument to make the function returning void?
> 
Hmm, it seems to be.  Ok, will send v3 to return void.

Regards,
Shawn

> Well, I still think something like 
> 
> 	/* No phy reset configured */
> 	if (phy_reset == -ENODEV)
> 		return 0;
> 
> might be cleaner, yet I don't have the setup to test such an approach.
> 
> So, I'll be quiet now and hope for no problems.
> 
> -- 
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Patch

diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 158b82e..a057abf 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1422,7 +1422,7 @@  static int __devinit fec_reset_phy(struct platform_device *pdev)
 	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
 	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
 	if (err) {
-		pr_warn("FEC: failed to get gpio phy-reset: %d\n", err);
+		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
 		return err;
 	}
 	msleep(1);