Skip to contentSkip to conversation

staging: nvec: Fix usleep_range is preferred over udelay

PATCH In review Joshua Abraham 2 participants 3 messages Nov 29, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: nvec: Fix usleep_range is preferred over udelay

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(-)
drivers/staging/nvec/nvec.c +1 -1
index 4ff8f47385da..2a01ef4b54ff 100644
@@ -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");
Signature · 1 line
2.15.0
#1 lore raw
Quoted 17 lines · Joshua Abraham

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(-)
drivers/staging/nvec/nvec.c +0 -0
index 4ff8f47385da..2a01ef4b54ff 100644

drivers/staging/nvec/nvec.c static irqreturn_t nvec_interrupt(int irq, void *dev) · line 637

Quoted 8 lines
drivers/staging/nvec/nvec.c +1 -1
@@ -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

#2 lore raw
Quoted 30 lines · Mikko Perttunen
Quoted 17 lines · Joshua Abraham

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(-)
drivers/staging/nvec/nvec.c +0 -0
index 4ff8f47385da..2a01ef4b54ff 100644

drivers/staging/nvec/nvec.c static irqreturn_t nvec_interrupt(int irq, void *dev) · line 637

Quoted 8 lines
drivers/staging/nvec/nvec.c +1 -1
@@ -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.

Quoted 2 lines

Cheers,
Mikko

My mistake. Thank you for the feedback!
-Josh