2017-11-29 18:23:31

by Joshua Abraham

[permalink] [raw]
Subject: [PATCH] staging: nvec: Fix usleep_range is preferred over udelay

Signed-off-by: Joshua Abraham <[email protected]>

This patch fixes the issue:

CHECK: usleep_range is preferred over udelay; see
Documentation/timers/timers-howto.txt

---
drivers/staging/nvec/nvec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 4ff8f47385da..2a01ef4b54ff 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -631,7 +631,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
break;
case 2: /* first byte after command */
if (status == (I2C_SL_IRQ | RNW | RCVD)) {
- udelay(33);
+ usleep_range(30, 35);
if (nvec->rx->data[0] != 0x01) {
dev_err(nvec->dev,
"Read without prior read command\n");
--
2.15.0


From 1585417942697477132@xxx Wed Nov 29 16:19:32 +0000 2017
X-GM-THRID: 1585417300663863139
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-29 16:19:33

by Joshua Abraham

[permalink] [raw]
Subject: Re: [PATCH] staging: nvec: Fix usleep_range is preferred over udelay

On Wed, Nov 29, 2017 at 06:07:53PM +0200, Mikko Perttunen wrote:
> On 11/29/2017 06:00 PM, Joshua Abraham wrote:
> > Signed-off-by: Joshua Abraham <[email protected]>
> >
> > This patch fixes the issue:
> >
> > CHECK: usleep_range is preferred over udelay; see
> > Documentation/timers/timers-howto.txt
> >
> > ---
> > drivers/staging/nvec/nvec.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> > index 4ff8f47385da..2a01ef4b54ff 100644
> > --- a/drivers/staging/nvec/nvec.c
> > +++ b/drivers/staging/nvec/nvec.c
> > @@ -631,7 +631,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
> > break;
> > case 2: /* first byte after command */
> > if (status == (I2C_SL_IRQ | RNW | RCVD)) {
> > - udelay(33);
> > + usleep_range(30, 35);
> > if (nvec->rx->data[0] != 0x01) {
> > dev_err(nvec->dev,
> > "Read without prior read command\n");
> >
>
> This is incorrect, as this function is an interrupt handler and we cannot
> sleep in interrupt context.
>
> Cheers,
> Mikko

My mistake. Thank you for the feedback!
-Josh

From 1585417300663863139@xxx Wed Nov 29 16:09:20 +0000 2017
X-GM-THRID: 1585417300663863139
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-29 16:09:20

by Mikko Perttunen

[permalink] [raw]
Subject: Re: [PATCH] staging: nvec: Fix usleep_range is preferred over udelay

On 11/29/2017 06:00 PM, Joshua Abraham wrote:
> Signed-off-by: Joshua Abraham <[email protected]>
>
> This patch fixes the issue:
>
> CHECK: usleep_range is preferred over udelay; see
> Documentation/timers/timers-howto.txt
>
> ---
> drivers/staging/nvec/nvec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 4ff8f47385da..2a01ef4b54ff 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -631,7 +631,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
> break;
> case 2: /* first byte after command */
> if (status == (I2C_SL_IRQ | RNW | RCVD)) {
> - udelay(33);
> + usleep_range(30, 35);
> if (nvec->rx->data[0] != 0x01) {
> dev_err(nvec->dev,
> "Read without prior read command\n");
>

This is incorrect, as this function is an interrupt handler and we
cannot sleep in interrupt context.

Cheers,
Mikko

From 1586046313102807327@xxx Wed Dec 06 14:47:13 +0000 2017
X-GM-THRID: 1586046313102807327
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread