diff mbox series

[v4,23/40] usb: cdc-acm: optimize acm_softint()

Message ID 20240620175703.605111-24-yury.norov@gmail.com (mailing list archive)
State New, archived
Headers show
Series lib/find: add atomic find_bit() primitives | expand

Commit Message

Yury Norov June 20, 2024, 5:56 p.m. UTC
acm_softint() uses for-loop to traverse urbs_in_error_delay bitmap
bit by bit to find and clear set bits.

Simplify it by using for_each_test_and_clear_bit(), because it doesn't
test already clear bits.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/class/cdc-acm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Greg Kroah-Hartman June 27, 2024, 2:03 p.m. UTC | #1
On Thu, Jun 20, 2024 at 10:56:46AM -0700, Yury Norov wrote:
> acm_softint() uses for-loop to traverse urbs_in_error_delay bitmap
> bit by bit to find and clear set bits.
> 
> Simplify it by using for_each_test_and_clear_bit(), because it doesn't
> test already clear bits.
> 
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> Acked-by: Oliver Neukum <oneukum@suse.com>
> ---
>  drivers/usb/class/cdc-acm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 0e7439dba8fe..f8940f0d7ad8 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -18,6 +18,7 @@
>  #undef DEBUG
>  #undef VERBOSE_DEBUG
>  
> +#include <linux/find_atomic.h>
>  #include <linux/kernel.h>
>  #include <linux/sched/signal.h>
>  #include <linux/errno.h>
> @@ -613,9 +614,8 @@ static void acm_softint(struct work_struct *work)
>  	}
>  
>  	if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) {
> -		for (i = 0; i < acm->rx_buflimit; i++)
> -			if (test_and_clear_bit(i, &acm->urbs_in_error_delay))
> -				acm_submit_read_urb(acm, i, GFP_KERNEL);
> +		for_each_test_and_clear_bit(i, &acm->urbs_in_error_delay, acm->rx_buflimit)
> +			acm_submit_read_urb(acm, i, GFP_KERNEL);
>  	}
>  
>  	if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
> -- 
> 2.43.0
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
diff mbox series

Patch

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0e7439dba8fe..f8940f0d7ad8 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -18,6 +18,7 @@ 
 #undef DEBUG
 #undef VERBOSE_DEBUG
 
+#include <linux/find_atomic.h>
 #include <linux/kernel.h>
 #include <linux/sched/signal.h>
 #include <linux/errno.h>
@@ -613,9 +614,8 @@  static void acm_softint(struct work_struct *work)
 	}
 
 	if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) {
-		for (i = 0; i < acm->rx_buflimit; i++)
-			if (test_and_clear_bit(i, &acm->urbs_in_error_delay))
-				acm_submit_read_urb(acm, i, GFP_KERNEL);
+		for_each_test_and_clear_bit(i, &acm->urbs_in_error_delay, acm->rx_buflimit)
+			acm_submit_read_urb(acm, i, GFP_KERNEL);
 	}
 
 	if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))