Skip to contentSkip to conversation

staging: rts5208: Replace udelay() with usleep_range()

PATCH In review Mamta Shukla 4 participants 6 messages Oct 2, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rts5208: Replace udelay() with usleep_range()

udelay(unsigned long usec) replaced with usleep_range(unsigned long min, unsigned long max) to prevent trigger by interrupt in specified duration.Also provides better scheduling,power management for drivers.

Issue found with checkpatch.pl

---
 drivers/staging/rts5208/ms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/ms.c +2 -2
index f53adf1..6654cdd 100644
@@ -3245,7 +3245,7 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
 			return STATUS_FAIL;
 		}
 
-		udelay(30);
+		usleep_range(30, 60);
 
 		rtsx_init_cmd(chip);
 
@@ -4167,7 +4167,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
 #ifdef MG_SET_ICV_SLOW
 	for (i = 0; i < 2; i++) {
-		udelay(50);
+		usleep_range(50, 100);
 
 		rtsx_init_cmd(chip);
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · Mamta Shukla

udelay(unsigned long usec) replaced with usleep_range(unsigned long min, unsigned long max) to prevent trigger by interrupt in specified duration.Also provides better scheduling,power management for drivers.

Thanks for the patch. A few picky comments. In English, it is more readable to put some space after punctuation. It is also not necessary to indent the log message.

Also, it would be good to explain how you chose the upper limit.

julia

Quoted 40 lines

Issue found with checkpatch.pl

---
 drivers/staging/rts5208/ms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/ms.c +2 -3
index f53adf1..6654cdd 100644
@@ -3245,7 +3245,7 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
 			return STATUS_FAIL;
 		}
 
-		udelay(30);
+		usleep_range(30, 60);
 
 		rtsx_init_cmd(chip);
 
@@ -4167,7 +4167,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
 #ifdef MG_SET_ICV_SLOW
 	for (i = 0; i < 2; i++) {
-		udelay(50);
+		usleep_range(50, 100);
 
 		rtsx_init_cmd(chip);
 
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181002130124.GA27163%40armorer.
For more options, visit https://groups.google.com/d/optout.

maintainer
#2 lore raw
Quoted 8 lines · Julia Lawall
Quoted 3 lines · Mamta Shukla

udelay(unsigned long usec) replaced with usleep_range(unsigned long min, unsigned long max) to prevent trigger by interrupt in specified duration.Also provides better scheduling,power management for drivers.

Quoted 5 lines

Thanks for the patch. A few picky comments. In English, it is more readable to put some space after punctuation. It is also not necessary to indent the log message.

Also, it would be good to explain how you chose the upper limit.

It is _required_ to explain this. This change comes up every so often, and I keep rejecting it as no one knows what value to put here that will correctly work. So I recommend just leaving it alone unless you hav the hardware and can test this type of change properly.

thanks,

greg k-h

#3 lore raw
Quoted 7 lines · Greg KH
Quoted 6 lines · Julia Lawall
Quoted 2 lines · Mamta Shukla

udelay(unsigned long usec) replaced with usleep_range(unsigned long min, unsigned long max) to prevent trigger by interrupt in

Quoted 11 lines

specified

Quoted 1 line
Quoted 1 line

duration.Also provides better scheduling,power management for

drivers.

Quoted 3 lines

Thanks for the patch. A few picky comments. In English, it is more readable to put some space after punctuation. It is also not necessary

to

Quoted 3 lines

indent the log message.

Also, it would be good to explain how you chose the upper limit.

Thank you for feedback Julia.I will keep in mind all these while writing
next patch.
I replaced udelay() with usleep_range to improve the responsiveness. I
considered these values
to be equivalent for values by udelay(). But as mentioned by Greg , since
this depends on response
time of hardware and no exact value can be decided.

Quoted 10 lines

It is _required_ to explain this. This change comes up every so often, and I keep rejecting it as no one knows what value to put here that will correctly work. So I recommend just leaving it alone unless you hav the hardware and can test this type of change properly.

thanks,

greg k-h

Thank you for feedback Greg. I understood the hardware dependency for this
driver.
Is it possible to remove this delay ? This driver needs DMA accessibility
in Linux.
So if one has to develop PCIe driver for any processor(intel, altera),
there should be
different driver for each platform.

Thanks,

Mamta Shukla

maintainer
#4 lore raw
Quoted 9 lines · Mamta Shukla
Quoted 6 lines

It is _required_ to explain this. This change comes up every so often, and I keep rejecting it as no one knows what value to put here that will correctly work. So I recommend just leaving it alone unless you hav the hardware and can test this type of change properly.

Thank you for feedback Greg. I understood the hardware dependency for this
driver.
Is it possible to remove this delay ?

It was probably added on purpose, why do you think it can be removed?

Quoted 1 line

This driver needs DMA accessibility in Linux.

What do you mean by this? What does DMA have to do with this driver?

Quoted 2 lines

So if one has to develop PCIe driver for any processor(intel, altera),
there should be different driver for each platform.

No, that is not how Linux drivers are written. They should work on all hardware platforms that the hardware can be plugged into. Any platform-specific issues are handled in bus-specific or architecture specific drivers.

thanks,

greg k-h

#5 lore raw
In reply to Mamta Shukla
Quoted 20 lines · Mamta Shukla
Quoted 7 lines · Greg KH
Quoted 6 lines · Julia Lawall
Quoted 2 lines · Mamta Shukla

udelay(unsigned long usec) replaced with usleep_range(unsigned long min, unsigned long max) to prevent trigger by interrupt in

Quoted 11 lines

specified

Quoted 1 line
Quoted 1 line

duration.Also provides better scheduling,power management for

drivers.

Quoted 3 lines

Thanks for the patch. A few picky comments. In English, it is more readable to put some space after punctuation. It is also not necessary

to

Quoted 3 lines

indent the log message.

Also, it would be good to explain how you chose the upper limit.

Quoted 7 lines

Thank you for feedback Julia.I will keep in mind all these while writing
next patch.
I replaced udelay() with usleep_range to improve the responsiveness. I
considered these values
to be equivalent for values by udelay(). But as mentioned by Greg , since
this depends on response
time of hardware and no exact value can be decided.

The selection b/w udelay() Vs usleep_range() always gets fuzzy. And it is often advised to only play with these if you have the hardware and can the test/verfiy the change.

Selections also depends on Atomic Vs Non-atomic context ...

Signature · 4 lines
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology