* [PATCH v1 1/1] usb: musb: Use read_poll_timeout()
@ 2023-07-03 12:19 Andy Shevchenko
2023-07-04 9:08 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-03 12:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Linus Walleij, linux-usb, linux-kernel
Cc: Bin Liu, Andy Shevchenko
Use read_poll_timeout() instead of open coding it.
In the same time, fix the typo in the error message.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/usb/musb/tusb6010.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index cbc707fe570f..2ae82e049f88 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -21,6 +21,7 @@
#include <linux/usb.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
@@ -1029,7 +1030,7 @@ static int tusb_musb_start(struct musb *musb)
void __iomem *tbase = musb->ctrl_base;
unsigned long flags;
u32 reg;
- int i;
+ int ret;
/*
* Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -1037,17 +1038,13 @@ static int tusb_musb_start(struct musb *musb)
* provide then PGOOD signal to TUSB6010 which will release it from reset.
*/
gpiod_set_value(glue->enable, 1);
- msleep(1);
/* Wait for 100ms until TUSB6010 pulls INT pin down */
- i = 100;
- while (i && gpiod_get_value(glue->intpin)) {
- msleep(1);
- i--;
- }
- if (!i) {
- pr_err("tusb: Powerup respones failed\n");
- return -ENODEV;
+ ret = read_poll_timeout(gpiod_get_value, reg, !reg, 1000, 100000, true,
+ glue->intpin);
+ if (ret) {
+ pr_err("tusb: Powerup response failed\n");
+ return ret;
}
spin_lock_irqsave(&musb->lock, flags);
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] usb: musb: Use read_poll_timeout()
2023-07-03 12:19 [PATCH v1 1/1] usb: musb: Use read_poll_timeout() Andy Shevchenko
@ 2023-07-04 9:08 ` Linus Walleij
2023-07-10 9:44 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2023-07-04 9:08 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Bin Liu
On Mon, Jul 3, 2023 at 2:19 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Use read_poll_timeout() instead of open coding it.
> In the same time, fix the typo in the error message.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
(...)
> + ret = read_poll_timeout(gpiod_get_value, reg, !reg, 1000, 100000, true,
> + glue->intpin);
Wow that's really cool. I had no idea that you could use read_poll_timeout()
together with gpiod_get_value() like this!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] usb: musb: Use read_poll_timeout()
2023-07-04 9:08 ` Linus Walleij
@ 2023-07-10 9:44 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-10 9:44 UTC (permalink / raw)
To: Linus Walleij; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Bin Liu
On Tue, Jul 04, 2023 at 11:08:41AM +0200, Linus Walleij wrote:
> On Mon, Jul 3, 2023 at 2:19 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>
> > Use read_poll_timeout() instead of open coding it.
> > In the same time, fix the typo in the error message.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> (...)
> > + ret = read_poll_timeout(gpiod_get_value, reg, !reg, 1000, 100000, true,
> > + glue->intpin);
>
> Wow that's really cool. I had no idea that you could use read_poll_timeout()
> together with gpiod_get_value() like this!
Yep, after 5f5323a14cad ("iopoll: introduce read_poll_timeout macro").
I just realized that we need to bump the sleep_us parameter as beneath
it divides it by 4, so I would put 5000 there in v2.
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-10 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03 12:19 [PATCH v1 1/1] usb: musb: Use read_poll_timeout() Andy Shevchenko
2023-07-04 9:08 ` Linus Walleij
2023-07-10 9:44 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).