[PATCH] staging: nvec: replace short udelay with usleep_range

Preyas posted 1 patch 1 month, 2 weeks ago
drivers/staging/nvec/nvec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] staging: nvec: replace short udelay with usleep_range
Posted by Preyas 1 month, 2 weeks ago
From: Preyas Sharma <preyas17@zohomail.in>

Hi,

Replace udelay(33) with usleep_range(33, 66) in the nvec IRQ handler.

This avoids busy-waiting while preserving the required delay for the
first byte after a command, and follows guidance for microsecond-range
waits.

Signed-off-by: Preyas Sharma <preyas17@zohomail.in>
---
 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 263774e6a78c..6ffe5e8656d1 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -648,7 +648,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(33, 66);
 			if (nvec->rx->data[0] != 0x01) {
 				dev_err(nvec->dev,
 					"Read without prior read command\n");
-- 
2.43.0
Re: [PATCH] staging: nvec: replace short udelay with usleep_range
Posted by Greg KH 1 month, 2 weeks ago
On Sat, Dec 20, 2025 at 10:08:20AM +0000, Preyas wrote:
> From: Preyas Sharma <preyas17@zohomail.in>
> 
> Hi,

This isn't needed in a changelog, please read the documentation for how
to write a good changelog text.

> Replace udelay(33) with usleep_range(33, 66) in the nvec IRQ handler.
> 
> This avoids busy-waiting while preserving the required delay for the
> first byte after a command, and follows guidance for microsecond-range
> waits.

What guidance?  And why 66?  Do you have the hardware to test this with?
And if you sleep, doesn't this get messed up?

Attempting to fix this checkpatch warning is almost always not a good
idea unless you have access to the hardware and the specs for it to
verify that this is an ok thing to do.

Please read the email archives for the many other times this has come
up for more details.

thanks,

greg k-h