2020-03-17 12:37:22

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH] iio: buffer: re-introduce bitmap_zalloc() for trialmask

Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
reverted it.

This change adds it back. The only difference is that it's adding
bitmap_zalloc(). There might be some changes later that would require
initializing it to zero. In any case, now it's already zero-ing the
trialmask.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
drivers/iio/industrialio-buffer.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4ada5592aa2b..5ff34ce8b6a2 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -316,8 +316,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
const unsigned long *mask;
unsigned long *trialmask;

- trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
- sizeof(*trialmask), GFP_KERNEL);
+ trialmask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL);
if (trialmask == NULL)
return -ENOMEM;
if (!indio_dev->masklength) {
--
2.20.1


2020-03-17 12:53:40

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] iio: buffer: re-introduce bitmap_zalloc() for trialmask

On Tue, Mar 17, 2020 at 02:36:21PM +0200, Alexandru Ardelean wrote:
> Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
> bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
> reverted it.
>
> This change adds it back. The only difference is that it's adding
> bitmap_zalloc(). There might be some changes later that would require
> initializing it to zero. In any case, now it's already zero-ing the
> trialmask.

FWIW,
Reviewed-by: Andy Shevchenko <[email protected]>

>
> Signed-off-by: Alexandru Ardelean <[email protected]>
> ---
> drivers/iio/industrialio-buffer.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 4ada5592aa2b..5ff34ce8b6a2 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -316,8 +316,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
> const unsigned long *mask;
> unsigned long *trialmask;
>
> - trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
> - sizeof(*trialmask), GFP_KERNEL);
> + trialmask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL);
> if (trialmask == NULL)
> return -ENOMEM;
> if (!indio_dev->masklength) {
> --
> 2.20.1
>

--
With Best Regards,
Andy Shevchenko


2020-03-17 12:54:08

by Alexandru Ardelean

[permalink] [raw]
Subject: Re: [PATCH] iio: buffer: re-introduce bitmap_zalloc() for trialmask

On Tue, 2020-03-17 at 14:52 +0200, Andy Shevchenko wrote:
> [External]
>
> On Tue, Mar 17, 2020 at 02:36:21PM +0200, Alexandru Ardelean wrote:
> > Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
> > bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
> > reverted it.
> >
> > This change adds it back. The only difference is that it's adding
> > bitmap_zalloc(). There might be some changes later that would require
> > initializing it to zero. In any case, now it's already zero-ing the
> > trialmask.
>
> FWIW,
> Reviewed-by: Andy Shevchenko <[email protected]>

Thanks.
And sorry for the hiccup back there.

>
> > Signed-off-by: Alexandru Ardelean <[email protected]>
> > ---
> > drivers/iio/industrialio-buffer.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-
> > buffer.c
> > index 4ada5592aa2b..5ff34ce8b6a2 100644
> > --- a/drivers/iio/industrialio-buffer.c
> > +++ b/drivers/iio/industrialio-buffer.c
> > @@ -316,8 +316,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
> > const unsigned long *mask;
> > unsigned long *trialmask;
> >
> > - trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
> > - sizeof(*trialmask), GFP_KERNEL);
> > + trialmask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL);
> > if (trialmask == NULL)
> > return -ENOMEM;
> > if (!indio_dev->masklength) {
> > --
> > 2.20.1
> >

2020-03-17 13:21:00

by Lars-Peter Clausen

[permalink] [raw]
Subject: Re: [PATCH] iio: buffer: re-introduce bitmap_zalloc() for trialmask

On 3/17/20 1:53 PM, Ardelean, Alexandru wrote:
> On Tue, 2020-03-17 at 14:52 +0200, Andy Shevchenko wrote:
>> [External]
>>
>> On Tue, Mar 17, 2020 at 02:36:21PM +0200, Alexandru Ardelean wrote:
>>> Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
>>> bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
>>> reverted it.
>>>
>>> This change adds it back. The only difference is that it's adding
>>> bitmap_zalloc(). There might be some changes later that would require
>>> initializing it to zero. In any case, now it's already zero-ing the
>>> trialmask.
>>
>> FWIW,
>> Reviewed-by: Andy Shevchenko <[email protected]>
>
> Thanks.
> And sorry for the hiccup back there.

It looks like a merge conflict. Both patches are in parallel sub-trees.
I guess one went through fixes and the other through the normal tree and
then when they were merged, the issue was not resolved properly.

2019-04-21 Greg Kroah-Hartman M─┐ Merge 5.1-rc6 into staging-next
2019-02-20 Lars-Peter Clausen │ o iio: Fix scan mask selection
2019-03-04 Andy Shevchenko o │ iio: buffer: Switch to bitmap_zalloc
2018-02-20 Greg Kroah-Hartman M─┤ Merge tag 'iio-fixes-for-4.16a

2020-03-21 09:01:19

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v2] iio: buffer: re-introduce bitmap_zalloc() for trialmask

Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
reverted it.

This change adds it back. The only difference is that it's adding
bitmap_zalloc(). There might be some changes later that would require
initializing it to zero. In any case, now it's already zero-ing the
trialmask.

Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Alexandru Ardelean <[email protected]>
---

Changelog v1 -> v2:
* add 'Reviewed-by: Andy Shevchenko <[email protected]>'
* re-send from an Analog server; GMail changed the author to @gmail.com

drivers/iio/industrialio-buffer.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4ada5592aa2b..5ff34ce8b6a2 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -316,8 +316,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
const unsigned long *mask;
unsigned long *trialmask;

- trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
- sizeof(*trialmask), GFP_KERNEL);
+ trialmask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL);
if (trialmask == NULL)
return -ENOMEM;
if (!indio_dev->masklength) {
--
2.17.1

2020-03-22 17:02:23

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2] iio: buffer: re-introduce bitmap_zalloc() for trialmask

On Sat, 21 Mar 2020 10:59:56 +0200
Alexandru Ardelean <[email protected]> wrote:

> Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
> bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
> reverted it.
>
> This change adds it back. The only difference is that it's adding
> bitmap_zalloc(). There might be some changes later that would require
> initializing it to zero. In any case, now it's already zero-ing the
> trialmask.
>
> Reviewed-by: Andy Shevchenko <[email protected]>
> Signed-off-by: Alexandru Ardelean <[email protected]>

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to poke it.

Thanks,

Jonathan
> ---
>
> Changelog v1 -> v2:
> * add 'Reviewed-by: Andy Shevchenko <[email protected]>'
> * re-send from an Analog server; GMail changed the author to @gmail.com
>
> drivers/iio/industrialio-buffer.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 4ada5592aa2b..5ff34ce8b6a2 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -316,8 +316,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
> const unsigned long *mask;
> unsigned long *trialmask;
>
> - trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
> - sizeof(*trialmask), GFP_KERNEL);
> + trialmask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL);
> if (trialmask == NULL)
> return -ENOMEM;
> if (!indio_dev->masklength) {

2020-03-22 17:04:50

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH] iio: buffer: re-introduce bitmap_zalloc() for trialmask

On Tue, 17 Mar 2020 14:18:43 +0100
Lars-Peter Clausen <[email protected]> wrote:

> On 3/17/20 1:53 PM, Ardelean, Alexandru wrote:
> > On Tue, 2020-03-17 at 14:52 +0200, Andy Shevchenko wrote:
> >> [External]
> >>
> >> On Tue, Mar 17, 2020 at 02:36:21PM +0200, Alexandru Ardelean wrote:
> >>> Commit 3862828a903d3 ("iio: buffer: Switch to bitmap_zalloc()") introduced
> >>> bitmap_alloc(), but commit 20ea39ef9f2f9 ("iio: Fix scan mask selection")
> >>> reverted it.
> >>>
> >>> This change adds it back. The only difference is that it's adding
> >>> bitmap_zalloc(). There might be some changes later that would require
> >>> initializing it to zero. In any case, now it's already zero-ing the
> >>> trialmask.
> >>
> >> FWIW,
> >> Reviewed-by: Andy Shevchenko <[email protected]>
> >
> > Thanks.
> > And sorry for the hiccup back there.
>
> It looks like a merge conflict. Both patches are in parallel sub-trees.
> I guess one went through fixes and the other through the normal tree and
> then when they were merged, the issue was not resolved properly.
>
> 2019-04-21 Greg Kroah-Hartman M─┐ Merge 5.1-rc6 into staging-next
> 2019-02-20 Lars-Peter Clausen │ o iio: Fix scan mask selection
> 2019-03-04 Andy Shevchenko o │ iio: buffer: Switch to bitmap_zalloc
> 2018-02-20 Greg Kroah-Hartman M─┤ Merge tag 'iio-fixes-for-4.16a

Thanks for the detective work. I've added a note to the patch description.

Jonathan