* [PATCH] drivers: smc911x fix inverted wait_on_timeout
@ 2021-01-29 17:44 Mike Nawrocki
2021-01-31 19:38 ` Ahmad Fatoum
2021-02-01 8:32 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Mike Nawrocki @ 2021-01-29 17:44 UTC (permalink / raw)
To: barebox; +Cc: Mike Nawrocki
The smc911x driver probe routine polls the READY bit using
wait_on_timeout, which returns 0 on success. The error check following
the wait_on_timeout invocation in the probe routine interprets a
returned 0 as failure.
This patch correctly interprets the return value of wait_on_timeout.
Signed-off-by: Mike Nawrocki <michael.nawrocki@gtri.gatech.edu>
---
drivers/net/smc911x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index ea7cea5f1..1edc16ce4 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -541,7 +541,7 @@ static int smc911x_probe(struct device_d *dev)
* forbidden while this bit isn't set. Try for 100ms
*/
ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY);
- if (!ret) {
+ if (ret) {
dev_err(dev, "Device not READY in 100ms aborting\n");
return -ENODEV;
}
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: smc911x fix inverted wait_on_timeout
2021-01-29 17:44 [PATCH] drivers: smc911x fix inverted wait_on_timeout Mike Nawrocki
@ 2021-01-31 19:38 ` Ahmad Fatoum
2021-02-01 8:32 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-01-31 19:38 UTC (permalink / raw)
To: Mike Nawrocki, barebox
Hello Mike,
On 29.01.21 18:44, Mike Nawrocki wrote:
> The smc911x driver probe routine polls the READY bit using
> wait_on_timeout, which returns 0 on success. The error check following
> the wait_on_timeout invocation in the probe routine interprets a
> returned 0 as failure.
>
> This patch correctly interprets the return value of wait_on_timeout.
Apparently two wrongs indeed make one right..
It used to be !smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY,
which was flagged by static analysis and I dropped the !, because
it's clearly wrong. Now I understand why it did work..
Thanks for fixing this properly.
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cheers,
Ahmad
>
> Signed-off-by: Mike Nawrocki <michael.nawrocki@gtri.gatech.edu>
> ---
> drivers/net/smc911x.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index ea7cea5f1..1edc16ce4 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -541,7 +541,7 @@ static int smc911x_probe(struct device_d *dev)
> * forbidden while this bit isn't set. Try for 100ms
> */
> ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY);
> - if (!ret) {
> + if (ret) {
> dev_err(dev, "Device not READY in 100ms aborting\n");
> return -ENODEV;
> }
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: smc911x fix inverted wait_on_timeout
2021-01-29 17:44 [PATCH] drivers: smc911x fix inverted wait_on_timeout Mike Nawrocki
2021-01-31 19:38 ` Ahmad Fatoum
@ 2021-02-01 8:32 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-02-01 8:32 UTC (permalink / raw)
To: Mike Nawrocki; +Cc: barebox
On Fri, Jan 29, 2021 at 12:44:35PM -0500, Mike Nawrocki wrote:
> The smc911x driver probe routine polls the READY bit using
> wait_on_timeout, which returns 0 on success. The error check following
> the wait_on_timeout invocation in the probe routine interprets a
> returned 0 as failure.
>
> This patch correctly interprets the return value of wait_on_timeout.
>
> Signed-off-by: Mike Nawrocki <michael.nawrocki@gtri.gatech.edu>
> ---
> drivers/net/smc911x.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index ea7cea5f1..1edc16ce4 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -541,7 +541,7 @@ static int smc911x_probe(struct device_d *dev)
> * forbidden while this bit isn't set. Try for 100ms
> */
> ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY);
> - if (!ret) {
> + if (ret) {
> dev_err(dev, "Device not READY in 100ms aborting\n");
> return -ENODEV;
> }
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-01 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 17:44 [PATCH] drivers: smc911x fix inverted wait_on_timeout Mike Nawrocki
2021-01-31 19:38 ` Ahmad Fatoum
2021-02-01 8:32 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox