lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 4 Dec 2023 09:43:00 +0100
From:   Hans Verkuil <hverkuil@...all.nl>
To:     Yury Norov <yury.norov@...il.com>, linux-kernel@...r.kernel.org,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org
Cc:     Jan Kara <jack@...e.cz>,
        Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
        Matthew Wilcox <willy@...radead.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Maxim Kuvyrkov <maxim.kuvyrkov@...aro.org>,
        Alexey Klimov <klimov.linux@...il.com>,
        Bart Van Assche <bvanassche@....org>,
        Sergey Shtylyov <s.shtylyov@....ru>
Subject: Re: [PATCH v2 20/35] media: radio-shark: use atomic find_bit() API
 where appropriate

On 03/12/2023 20:32, Yury Norov wrote:
> Despite that it's only 2- or 3-bit maps, convert for-loop followed by
> test_bit() to for_each_test_and_clear_bit() as it makes the code cleaner.
> 
> Signed-off-by: Yury Norov <yury.norov@...il.com>

Acked-by: Hans Verkuil <hverkuil-cisco@...all.nl>

You can take this patch yourself as well.

Regards,

	Hans

> ---
>  drivers/media/radio/radio-shark.c  | 5 +----
>  drivers/media/radio/radio-shark2.c | 5 +----
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
> index 127a3be0e0f0..0c50b3a9623e 100644
> --- a/drivers/media/radio/radio-shark.c
> +++ b/drivers/media/radio/radio-shark.c
> @@ -158,10 +158,7 @@ static void shark_led_work(struct work_struct *work)
>  		container_of(work, struct shark_device, led_work);
>  	int i, res, brightness, actual_len;
>  
> -	for (i = 0; i < 3; i++) {
> -		if (!test_and_clear_bit(i, &shark->brightness_new))
> -			continue;
> -
> +	for_each_test_and_clear_bit(i, &shark->brightness_new, 3) {
>  		brightness = atomic_read(&shark->brightness[i]);
>  		memset(shark->transfer_buffer, 0, TB_LEN);
>  		if (i != RED_LED) {
> diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
> index f1c5c0a6a335..d9ef241e1778 100644
> --- a/drivers/media/radio/radio-shark2.c
> +++ b/drivers/media/radio/radio-shark2.c
> @@ -145,10 +145,7 @@ static void shark_led_work(struct work_struct *work)
>  		container_of(work, struct shark_device, led_work);
>  	int i, res, brightness, actual_len;
>  
> -	for (i = 0; i < 2; i++) {
> -		if (!test_and_clear_bit(i, &shark->brightness_new))
> -			continue;
> -
> +	for_each_test_and_clear_bit(i, &shark->brightness_new, 2) {
>  		brightness = atomic_read(&shark->brightness[i]);
>  		memset(shark->transfer_buffer, 0, TB_LEN);
>  		shark->transfer_buffer[0] = 0x83 + i;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ