Patchwork serial/imx: propagate error from of_alias_get_id instead of using -ENODEV

login
register
mail settings
Submitter Uwe Kleine-König
Date Dec. 14, 2011, 8:26 p.m.
Message ID <1323894411-12294-1-git-send-email-u.kleine-koenig@pengutronix.de>
Download mbox | patch
Permalink /patch/131471/
State New
Headers show

Comments

Uwe Kleine-König - Dec. 14, 2011, 8:26 p.m.
A quick look at of_alias_get_id shows that in the error case it returns
-ENODEV, too, but still it's better style to propagate the value as is.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
Cc: Jason Liu <jason.hui@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/tty/serial/imx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Uwe Kleine-König - Dec. 14, 2011, 8:31 p.m.
Hello,

On Wed, Dec 14, 2011 at 09:26:51PM +0100, Uwe Kleine-König wrote:
> A quick look at of_alias_get_id shows that in the error case it returns
> -ENODEV, too, but still it's better style to propagate the value as is.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
> Cc: Jason Liu <jason.hui@linaro.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/tty/serial/imx.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 163fc90..75c159a 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1301,7 +1301,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
>  	ret = of_alias_get_id(np, "serial");
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
> -		return -ENODEV;
> +		return ret;
>  	}
>  	sport->port.line = ret;
>  
One more comment on serial_imx_probe_dt:

It is used as follows:

        ret = serial_imx_probe_dt(sport, pdev);
	if (ret == -ENODEV)
		serial_imx_probe_pdata(sport, pdev);

IMHO you should distinguish here more carefully between the different
-ENODEV cases. It's OK to call serial_imx_probe_pdata() if

	!pdev->dev.of_node

but if

	of_alias_get_id(np, "serial")

returns an error isn't that something that should make the probing of
the device fail instead of relying on platform data and the device id
that are non-existant and more or less random respectively if the device
is instantiated by dt?

Best regards
Uwe
Shawn Guo - Dec. 15, 2011, 2:06 a.m.
On Wed, Dec 14, 2011 at 09:26:51PM +0100, Uwe Kleine-König wrote:
> A quick look at of_alias_get_id shows that in the error case it returns
> -ENODEV, too, but still it's better style to propagate the value as is.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
> Cc: Jason Liu <jason.hui@linaro.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> ---

Acked-by: Shawn Guo <shawn.guo@linaro.org>

The only errno that of_alias_get_id could return is also -ENODEV though.

Regards,
Shawn

>  drivers/tty/serial/imx.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 163fc90..75c159a 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1301,7 +1301,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
>  	ret = of_alias_get_id(np, "serial");
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
> -		return -ENODEV;
> +		return ret;
>  	}
>  	sport->port.line = ret;
>  
> -- 
> 1.7.7.3
Shawn Guo - Dec. 15, 2011, 2:10 a.m.
On Wed, Dec 14, 2011 at 09:31:53PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Dec 14, 2011 at 09:26:51PM +0100, Uwe Kleine-König wrote:
> > A quick look at of_alias_get_id shows that in the error case it returns
> > -ENODEV, too, but still it's better style to propagate the value as is.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
> > Cc: Alan Cox <alan@linux.intel.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
> > Cc: Jason Liu <jason.hui@linaro.org>
> > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/tty/serial/imx.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index 163fc90..75c159a 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1301,7 +1301,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
> >  	ret = of_alias_get_id(np, "serial");
> >  	if (ret < 0) {
> >  		dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
> > -		return -ENODEV;
> > +		return ret;
> >  	}
> >  	sport->port.line = ret;
> >  
> One more comment on serial_imx_probe_dt:
> 
> It is used as follows:
> 
>         ret = serial_imx_probe_dt(sport, pdev);
> 	if (ret == -ENODEV)
> 		serial_imx_probe_pdata(sport, pdev);
> 
> IMHO you should distinguish here more carefully between the different
> -ENODEV cases. It's OK to call serial_imx_probe_pdata() if
> 
> 	!pdev->dev.of_node
> 
> but if
> 
> 	of_alias_get_id(np, "serial")
> 
> returns an error isn't that something that should make the probing of
> the device fail instead of relying on platform data and the device id
> that are non-existant and more or less random respectively if the device
> is instantiated by dt?
> 
Yes, agreed.  Care to send a fix for that too?
Jason Liu - Dec. 15, 2011, 2:59 a.m.
2011/12/15 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> A quick look at of_alias_get_id shows that in the error case it returns
> -ENODEV, too, but still it's better style to propagate the value as is.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
> Cc: Jason Liu <jason.hui@linaro.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/tty/serial/imx.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 163fc90..75c159a 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1301,7 +1301,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
>        ret = of_alias_get_id(np, "serial");
>        if (ret < 0) {
>                dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
> -               return -ENODEV;
> +               return ret;
>        }
>        sport->port.line = ret;

Acked-by: Jason Liu <jason.hui@linaro.org>

>
> --
> 1.7.7.3
>
Shawn Guo - Dec. 26, 2011, 1:55 a.m.
On Wed, Dec 14, 2011 at 09:26:51PM +0100, Uwe Kleine-König wrote:
> A quick look at of_alias_get_id shows that in the error case it returns
> -ENODEV, too, but still it's better style to propagate the value as is.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jeremy Kerr <jeremy.kerr@canonical.com>
> Cc: Jason Liu <jason.hui@linaro.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>

I queued this for 3.3, and will send a pull-request to Greg.

Patch

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 163fc90..75c159a 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1301,7 +1301,7 @@  static int serial_imx_probe_dt(struct imx_port *sport,
 	ret = of_alias_get_id(np, "serial");
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
-		return -ENODEV;
+		return ret;
 	}
 	sport->port.line = ret;