* Re: [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV
2011-12-14 20:26 [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Uwe Kleine-König
@ 2011-12-14 20:31 ` Uwe Kleine-König
2011-12-15 2:10 ` Shawn Guo
2011-12-15 2:06 ` [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Shawn Guo
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König @ 2011-12-14 20:31 UTC (permalink / raw)
To: linux-kernel
Cc: kernel, linux-arm-kernel, Shawn Guo, Alan Cox, Grant Likely,
Jeremy Kerr, Jason Liu, Sascha Hauer
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
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV
2011-12-14 20:31 ` Uwe Kleine-König
@ 2011-12-15 2:10 ` Shawn Guo
2011-12-15 8:16 ` [PATCH] serial/imx: let probing fail for the dt case without a valid alias Uwe Kleine-König
0 siblings, 1 reply; 9+ messages in thread
From: Shawn Guo @ 2011-12-15 2:10 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, kernel, linux-arm-kernel, Shawn Guo, Alan Cox,
Grant Likely, Jeremy Kerr, Jason Liu, Sascha Hauer
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?
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH] serial/imx: let probing fail for the dt case without a valid alias
2011-12-15 2:10 ` Shawn Guo
@ 2011-12-15 8:16 ` Uwe Kleine-König
2011-12-15 9:08 ` Shawn Guo
2011-12-26 1:56 ` Shawn Guo
0 siblings, 2 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2011-12-15 8:16 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, Alan Cox, Shawn Guo
Cc: kernel, Grant Likely, Jeremy Kerr, Jason Liu, Sascha Hauer
When the uart device is instantiated by dt but dt doesn't provide an
alias then better let probing fail instead of falling back to an
unrelated device id used for the line number and no platform data.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/tty/serial/imx.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 75c159a..1c94218 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1287,6 +1287,10 @@ static int serial_imx_resume(struct platform_device *dev)
}
#ifdef CONFIG_OF
+/*
+ * This function returns 1 iff pdev isn't a device instatiated by dt, 0 iff it
+ * could successfully get all information from dt or a negative errno.
+ */
static int serial_imx_probe_dt(struct imx_port *sport,
struct platform_device *pdev)
{
@@ -1296,7 +1300,8 @@ static int serial_imx_probe_dt(struct imx_port *sport,
int ret;
if (!np)
- return -ENODEV;
+ /* no device tree device */
+ return 1;
ret = of_alias_get_id(np, "serial");
if (ret < 0) {
@@ -1319,7 +1324,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
static inline int serial_imx_probe_dt(struct imx_port *sport,
struct platform_device *pdev)
{
- return -ENODEV;
+ return 1;
}
#endif
@@ -1354,8 +1359,10 @@ static int serial_imx_probe(struct platform_device *pdev)
return -ENOMEM;
ret = serial_imx_probe_dt(sport, pdev);
- if (ret == -ENODEV)
+ if (ret > 0)
serial_imx_probe_pdata(sport, pdev);
+ else if (ret < 0)
+ goto free;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
--
1.7.7.3
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] serial/imx: let probing fail for the dt case without a valid alias
2011-12-15 8:16 ` [PATCH] serial/imx: let probing fail for the dt case without a valid alias Uwe Kleine-König
@ 2011-12-15 9:08 ` Shawn Guo
2011-12-26 1:56 ` Shawn Guo
1 sibling, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2011-12-15 9:08 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-arm-kernel, linux-kernel, Alan Cox, kernel, Grant Likely,
Jeremy Kerr, Jason Liu, Sascha Hauer
On Thu, Dec 15, 2011 at 09:16:34AM +0100, Uwe Kleine-König wrote:
> When the uart device is instantiated by dt but dt doesn't provide an
> alias then better let probing fail instead of falling back to an
> unrelated device id used for the line number and no platform data.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
Acked-by: Shawn Guo <shawn.guo@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial/imx: let probing fail for the dt case without a valid alias
2011-12-15 8:16 ` [PATCH] serial/imx: let probing fail for the dt case without a valid alias Uwe Kleine-König
2011-12-15 9:08 ` Shawn Guo
@ 2011-12-26 1:56 ` Shawn Guo
1 sibling, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2011-12-26 1:56 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-arm-kernel, linux-kernel, Alan Cox, kernel, Grant Likely,
Jeremy Kerr, Jason Liu, Sascha Hauer, Greg Kroah-Hartman
On Thu, Dec 15, 2011 at 09:16:34AM +0100, Uwe Kleine-König wrote:
> When the uart device is instantiated by dt but dt doesn't provide an
> alias then better let probing fail instead of falling back to an
> unrelated device id used for the line number and no platform data.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
I queued this for 3.3, and will send a pull-request to Greg.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV
2011-12-14 20:26 [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Uwe Kleine-König
2011-12-14 20:31 ` Uwe Kleine-König
@ 2011-12-15 2:06 ` Shawn Guo
2011-12-15 2:59 ` Jason Hui
2011-12-26 1:55 ` Shawn Guo
3 siblings, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2011-12-15 2:06 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, kernel, linux-arm-kernel, Shawn Guo, Alan Cox,
Grant Likely, Jeremy Kerr, Jason Liu, Sascha Hauer
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
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV
2011-12-14 20:26 [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Uwe Kleine-König
2011-12-14 20:31 ` Uwe Kleine-König
2011-12-15 2:06 ` [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Shawn Guo
@ 2011-12-15 2:59 ` Jason Hui
2011-12-26 1:55 ` Shawn Guo
3 siblings, 0 replies; 9+ messages in thread
From: Jason Hui @ 2011-12-15 2:59 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, kernel, linux-arm-kernel, Shawn Guo, Alan Cox,
Grant Likely, Jeremy Kerr, Sascha Hauer
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
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV
2011-12-14 20:26 [PATCH] serial/imx: propagate error from of_alias_get_id instead of using -ENODEV Uwe Kleine-König
` (2 preceding siblings ...)
2011-12-15 2:59 ` Jason Hui
@ 2011-12-26 1:55 ` Shawn Guo
3 siblings, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2011-12-26 1:55 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, kernel, linux-arm-kernel, Shawn Guo, Alan Cox,
Grant Likely, Jeremy Kerr, Jason Liu, Sascha Hauer,
Greg Kroah-Hartman
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.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 9+ messages in thread