* [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate [not found] <20220123183925.1052919-1-yury.norov@gmail.com> @ 2022-01-23 18:39 ` Yury Norov 2022-01-24 12:46 ` Andy Shevchenko 0 siblings, 1 reply; 3+ messages in thread From: Yury Norov @ 2022-01-23 18:39 UTC (permalink / raw) To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton, Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing, Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel, Jonathan Cameron, Lars-Peter Clausen, Nathan Chancellor, Alexandru Ardelean, linux-iio drivers/iio calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq, gt} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov <yury.norov@gmail.com> --- drivers/iio/dummy/iio_simple_dummy_buffer.c | 4 ++-- drivers/iio/industrialio-trigger.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c index d81c2b2dad82..670997301e47 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -71,8 +71,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) int i, j; for (i = 0, j = 0; - i < bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); + bitmap_weight_gt(indio_dev->active_scan_mask, + indio_dev->masklength, i); i++, j++) { j = find_next_bit(indio_dev->active_scan_mask, indio_dev->masklength, j); diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index f504ed351b3e..98c54022fecf 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -331,7 +331,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig, { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev); bool no_other_users = - bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; + bitmap_weight_eq(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER, 1); int ret = 0; if (trig->ops && trig->ops->set_trigger_state && no_other_users) { -- 2.30.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate 2022-01-23 18:39 ` [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate Yury Norov @ 2022-01-24 12:46 ` Andy Shevchenko 2022-01-30 12:54 ` Jonathan Cameron 0 siblings, 1 reply; 3+ messages in thread From: Andy Shevchenko @ 2022-01-24 12:46 UTC (permalink / raw) To: Yury Norov Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing, Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel, Jonathan Cameron, Lars-Peter Clausen, Nathan Chancellor, Alexandru Ardelean, linux-iio On Sun, Jan 23, 2022 at 10:39:00AM -0800, Yury Norov wrote: > drivers/iio calls bitmap_weight() to compare the weight of bitmap with > a given number. We can do it more efficiently with bitmap_weight_{eq, gt} > because conditional bitmap_weight may stop traversing the bitmap earlier, > as soon as condition is met. ... > int i, j; > > for (i = 0, j = 0; > - i < bitmap_weight(indio_dev->active_scan_mask, > - indio_dev->masklength); > + bitmap_weight_gt(indio_dev->active_scan_mask, > + indio_dev->masklength, i); > i++, j++) { > j = find_next_bit(indio_dev->active_scan_mask, > indio_dev->masklength, j); This smells like room for improvement. Have you checked this deeply? -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate 2022-01-24 12:46 ` Andy Shevchenko @ 2022-01-30 12:54 ` Jonathan Cameron 0 siblings, 0 replies; 3+ messages in thread From: Jonathan Cameron @ 2022-01-30 12:54 UTC (permalink / raw) To: Andy Shevchenko Cc: Yury Norov, Rasmus Villemoes, Andrew Morton, Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing, Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel, Lars-Peter Clausen, Nathan Chancellor, Alexandru Ardelean, linux-iio On Mon, 24 Jan 2022 14:46:43 +0200 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > On Sun, Jan 23, 2022 at 10:39:00AM -0800, Yury Norov wrote: > > drivers/iio calls bitmap_weight() to compare the weight of bitmap with > > a given number. We can do it more efficiently with bitmap_weight_{eq, gt} > > because conditional bitmap_weight may stop traversing the bitmap earlier, > > as soon as condition is met. > > ... > > > int i, j; > > > > for (i = 0, j = 0; > > - i < bitmap_weight(indio_dev->active_scan_mask, > > - indio_dev->masklength); > > + bitmap_weight_gt(indio_dev->active_scan_mask, > > + indio_dev->masklength, i); > > i++, j++) { > > j = find_next_bit(indio_dev->active_scan_mask, > > indio_dev->masklength, j); > > This smells like room for improvement. Have you checked this deeply? > I have no idea what I was smoking that day. It was near 10 years ago, so I'll blame my younger self ;) Jonathan ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-30 12:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
2022-01-23 18:39 ` [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate Yury Norov
2022-01-24 12:46 ` Andy Shevchenko
2022-01-30 12:54 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).