staging: vc04_services: replace msleep() by usleep_range()
Subsystems (2)
PATCH v2 1/1 staging: vc04_services: replace msleep() by usleep_range()
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by usleep_range(unsigned long min, unsigned long max) in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.
---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 ); }return status;
@@ -894,7 +894,7 @@ enum vchiq_status vchiq_bulk_receive(unsigned int handle, void *data,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 ); }return status;
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 2 lines · Kushal-kothari
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)
No need to put the parameters in a function call.
Quoted 3 lines
in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.
Signed-off-by Kushal-kothari <[email protected]>
We need a "Legal" name here, is that how you sign documents? Sorry, I have to ask.
Quoted 12 lines
---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0
-0
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, · line 860
Quoted 5 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-1@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 );
You can not just randomly pick a range value here without lots of testing and knowing that the hardware really can support this.
Have you done this here?
thanks,
greg k-h
Quoted 3 lines · Kushal-kothari
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.
In addition to Greg's comments, the log message is still not really ideal. There is still the word Fix that doesn't really contribute anything. The prototypes of msleep and usleep are also not useful - the reader either knows them or can easily find them. A better messge could be something like:
"Checkpatch warns that an msleep of less than 20ms can sleep for up to 20ms. Replace msleep(1) by a call to usleep_range that makes the possible range (1ms - 20ms) explicit."
But the argument to msleep is in milliseconds. If the appropriate first argument to usleep_range is 1000, then it would seem that the second argument should be 20000?
One thing that you can do to try to understand such a problem better is to see what others have done before to resolve it. You could try a command like
git log -S msleep -p
to see commits that have changed the number of calls to msleep.
I reiterate Greg's comments that making these timing changes without being able to test the result is risky. These are just suggestions of some methodologies that you could follow for a change where it is more clear that the change is correct.
julia
Quoted 39 lines
Signed-off-by Kushal-kothari <[email protected]>---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-3@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 ); }return status;@@ -894,7 +894,7 @@ enum vchiq_status vchiq_bulk_receive(unsigned int handle, void *data,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 ); }return status; --2.25.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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20211017092900.134752-1-kushalkothari285%40gmail.com.
Hi,
Am 17.10.21 um 11:29 schrieb Kushal-kothari:
Quoted 17 lines
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.Signed-off-by Kushal-kothari <[email protected]>---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0
-0
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, · line 860
Quoted 5 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-1@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ; -msleep (1 ); +usleep_range (1000 ,2000 );
there was a recent discussion about this checkpatch warning [1]
Best regards
Quoted 23 lines · Stefan Wahren
Hi,
Am 17.10.21 um 11:29 schrieb Kushal-kothari:
Quoted 20 lines
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.Signed-off-by Kushal-kothari <[email protected]>---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0
-0@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ;
Quoted 4 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, · line 860
Quoted 2 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-1-msleep (1 ); +usleep_range (1000 ,2000 );there was a recent discussion about this checkpatch warning [1]
Should there be a comment about it?
julia
Quoted 7 lines
Best regards
Am 17.10.21 um 14:33 schrieb Julia Lawall:
Quoted 26 lines · Stefan Wahren
Quoted 24 lines
Hi,
Am 17.10.21 um 11:29 schrieb Kushal-kothari:
Quoted 20 lines
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.Signed-off-by Kushal-kothari <[email protected]>---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0
-0@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ;
Quoted 4 lines
Quoted 3 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, · line 860
Quoted 2 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-1-msleep (1 ); +usleep_range (1000 ,2000 );there was a recent discussion about this checkpatch warning [1]
Should there be a comment about it?
Of course
Best regards
Quoted 13 lines
julia
Quoted 6 lines
Best regards
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 27 lines · Julia Lawall
Quoted 23 lines · Stefan Wahren
Hi,
Am 17.10.21 um 11:29 schrieb Kushal-kothari:
Quoted 20 lines
Fixed the warning:-msleep < 20ms can sleep for up to 20ms by replacing msleep(unsigned long msecs) by
usleep_range(unsigned long min, unsigned long max)in usecs as msleep(1ms~20ms) can sleep for upto 20 ms.Signed-off-by Kushal-kothari <[email protected]>---
Changes from v1: Reword both the subject and the log message.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +0
-0@@ -857,7 +857,7 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size,if (status !=VCHIQ_RETRY )break ;
Quoted 6 lines
Quoted 4 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, · line 860
Quoted 2 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-1-msleep (1 ); +usleep_range (1000 ,2000 );there was a recent discussion about this checkpatch warning [1]
Should there be a comment about it?
Even better would be an alternate wrapper around usleep(1) which would silence the checkpatch warning. Something like:
#define short_sleep() usleep(1)
regards,
dan carpenter