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]
Message-ID: <YgYiELMVJn52EZxY@smile.fi.intel.com>
Date:   Fri, 11 Feb 2022 10:45:04 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Yury Norov <yury.norov@...il.com>
Cc:     Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michał Mirosław <mirq-linux@...e.qmqm.pl>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        David Laight <David.Laight@...lab.com>,
        Joe Perches <joe@...ches.com>, Dennis Zhou <dennis@...nel.org>,
        Emil Renner Berthing <kernel@...il.dk>,
        Nicholas Piggin <npiggin@...il.com>,
        Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Alexey Klimov <aklimov@...hat.com>,
        linux-kernel@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Alexandru Ardelean <alexandru.ardelean@...log.com>,
        Nathan Chancellor <nathan@...nel.org>,
        linux-iio@...r.kernel.org
Subject: Re: [PATCH 04/49] iio: fix opencoded for_each_set_bit()

On Thu, Feb 10, 2022 at 02:48:48PM -0800, Yury Norov wrote:
> iio_simple_dummy_trigger_h() is mostly an opencoded for_each_set_bit().
> Using for_each_set_bit() make code much cleaner, and more effective.

I would wait for some testing, but from code perspective looks good.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>

> Signed-off-by: Yury Norov <yury.norov@...il.com>
> ---
>  drivers/iio/dummy/iio_simple_dummy_buffer.c | 48 ++++++++-------------
>  1 file changed, 19 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c
> index d81c2b2dad82..3bc1b7529e2a 100644
> --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c
> +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c
> @@ -45,41 +45,31 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
>  {
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
> +	int i = 0, j;
>  	u16 *data;
>  
>  	data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
>  	if (!data)
>  		goto done;
>  
> -	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
> -		/*
> -		 * Three common options here:
> -		 * hardware scans: certain combinations of channels make
> -		 *   up a fast read.  The capture will consist of all of them.
> -		 *   Hence we just call the grab data function and fill the
> -		 *   buffer without processing.
> -		 * software scans: can be considered to be random access
> -		 *   so efficient reading is just a case of minimal bus
> -		 *   transactions.
> -		 * software culled hardware scans:
> -		 *   occasionally a driver may process the nearest hardware
> -		 *   scan to avoid storing elements that are not desired. This
> -		 *   is the fiddliest option by far.
> -		 * Here let's pretend we have random access. And the values are
> -		 * in the constant table fakedata.
> -		 */
> -		int i, j;
> -
> -		for (i = 0, j = 0;
> -		     i < bitmap_weight(indio_dev->active_scan_mask,
> -				       indio_dev->masklength);
> -		     i++, j++) {
> -			j = find_next_bit(indio_dev->active_scan_mask,
> -					  indio_dev->masklength, j);
> -			/* random access read from the 'device' */
> -			data[i] = fakedata[j];
> -		}
> -	}
> +	/*
> +	 * Three common options here:
> +	 * hardware scans: certain combinations of channels make
> +	 *   up a fast read.  The capture will consist of all of them.
> +	 *   Hence we just call the grab data function and fill the
> +	 *   buffer without processing.
> +	 * software scans: can be considered to be random access
> +	 *   so efficient reading is just a case of minimal bus
> +	 *   transactions.
> +	 * software culled hardware scans:
> +	 *   occasionally a driver may process the nearest hardware
> +	 *   scan to avoid storing elements that are not desired. This
> +	 *   is the fiddliest option by far.
> +	 * Here let's pretend we have random access. And the values are
> +	 * in the constant table fakedata.
> +	 */
> +	for_each_set_bit(j, indio_dev->active_scan_mask, indio_dev->masklength)
> +		data[i++] = fakedata[j];
>  
>  	iio_push_to_buffers_with_timestamp(indio_dev, data,
>  					   iio_get_time_ns(indio_dev));
> -- 
> 2.32.0
> 

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ