mbox series

[0/7] Simplify codes with devm_add_action_or_reset

Message ID 1617881896-3164-1-git-send-email-yangyicong@hisilicon.com (mailing list archive)
Headers show
Series Simplify codes with devm_add_action_or_reset | expand

Message

Yicong Yang April 8, 2021, 11:38 a.m. UTC
Some devm variants are implemented with devres_alloc() and devres_add()
manually to only manage a single pointer. This can be simplified with
devm_add_action_or_reset() which works the same. Simplify these functions.

Yicong Yang (7):
  iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
  iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
  iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
  iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
  iio: core: simplify some devm functions
  iio: trigger: simplify __devm_iio_trigger_register
  iio: inkern: simplify some devm functions

 drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
 drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
 drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
 drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
 drivers/iio/industrialio-core.c                    | 43 ++++++---------
 drivers/iio/industrialio-trigger.c                 | 18 ++-----
 drivers/iio/inkern.c                               | 61 ++++++++--------------
 7 files changed, 78 insertions(+), 132 deletions(-)

Comments

Alexandru Ardelean April 8, 2021, 1:14 p.m. UTC | #1
On Thu, Apr 8, 2021 at 2:41 PM Yicong Yang <yangyicong@hisilicon.com> wrote:
>
> Some devm variants are implemented with devres_alloc() and devres_add()
> manually to only manage a single pointer. This can be simplified with
> devm_add_action_or_reset() which works the same. Simplify these functions.
>

Series looks good.
There are a few elements that are a bit strange (from a habit perspective).

For the devm_add_action_or_reset() callback usually there's a cast being done.
But that's a preference I don't feel too strongly about.

> Yicong Yang (7):
>   iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
>   iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
>   iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
>   iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
>   iio: core: simplify some devm functions
>   iio: trigger: simplify __devm_iio_trigger_register
>   iio: inkern: simplify some devm functions
>
>  drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
>  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
>  drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
>  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
>  drivers/iio/industrialio-core.c                    | 43 ++++++---------
>  drivers/iio/industrialio-trigger.c                 | 18 ++-----
>  drivers/iio/inkern.c                               | 61 ++++++++--------------
>  7 files changed, 78 insertions(+), 132 deletions(-)
>
> --
> 2.8.1
>
Lars-Peter Clausen April 9, 2021, 6:58 a.m. UTC | #2
On 4/8/21 1:38 PM, Yicong Yang wrote:
> Some devm variants are implemented with devres_alloc() and devres_add()
> manually to only manage a single pointer. This can be simplified with
> devm_add_action_or_reset() which works the same. Simplify these functions.
>
Whole series looks good to me, thanks.

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Nuno Sa April 9, 2021, 7:27 a.m. UTC | #3
> -----Original Message-----
> From: Yicong Yang <yangyicong@hisilicon.com>
> Sent: Thursday, April 8, 2021 1:38 PM
> To: jic23@kernel.org; linux-iio@vger.kernel.org
> Cc: lars@metafoo.de; Hennerich, Michael
> <Michael.Hennerich@analog.com>; pmeerw@pmeerw.net;
> prime.zeng@huawei.com; tiantao6@hisilicon.com;
> yangyicong@hisilicon.com
> Subject: [PATCH 0/7] Simplify codes with devm_add_action_or_reset
> 
> 
> Some devm variants are implemented with devres_alloc() and
> devres_add()
> manually to only manage a single pointer. This can be simplified with
> devm_add_action_or_reset() which works the same. Simplify these
> functions.
> 

LGTM,

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

Nuno Sá
Andy Shevchenko April 9, 2021, 9:17 a.m. UTC | #4
On Thu, Apr 8, 2021 at 2:41 PM Yicong Yang <yangyicong@hisilicon.com> wrote:
>
> Some devm variants are implemented with devres_alloc() and devres_add()
> manually to only manage a single pointer. This can be simplified with
> devm_add_action_or_reset() which works the same. Simplify these functions.

Thanks, I saw similar patches you have done for other subsystems, this
also LGTM!
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Yicong Yang (7):
>   iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
>   iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
>   iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
>   iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
>   iio: core: simplify some devm functions
>   iio: trigger: simplify __devm_iio_trigger_register
>   iio: inkern: simplify some devm functions
>
>  drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
>  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
>  drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
>  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
>  drivers/iio/industrialio-core.c                    | 43 ++++++---------
>  drivers/iio/industrialio-trigger.c                 | 18 ++-----
>  drivers/iio/inkern.c                               | 61 ++++++++--------------
>  7 files changed, 78 insertions(+), 132 deletions(-)
>
> --
> 2.8.1
>
Jonathan Cameron April 11, 2021, 2:21 p.m. UTC | #5
On Thu, 8 Apr 2021 19:38:09 +0800
Yicong Yang <yangyicong@hisilicon.com> wrote:

> Some devm variants are implemented with devres_alloc() and devres_add()
> manually to only manage a single pointer. This can be simplified with
> devm_add_action_or_reset() which works the same. Simplify these functions.
> 
> Yicong Yang (7):
>   iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
>   iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
>   iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
>   iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
>   iio: core: simplify some devm functions
>   iio: trigger: simplify __devm_iio_trigger_register
>   iio: inkern: simplify some devm functions

Nice set.  Note no rush for a v2 as IIO is effectively closed for the
coming merge window.  Hence these won't hit linux-next now until after
the merge window closes.

Thanks,

Jonathan

> 
>  drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
>  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
>  drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
>  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
>  drivers/iio/industrialio-core.c                    | 43 ++++++---------
>  drivers/iio/industrialio-trigger.c                 | 18 ++-----
>  drivers/iio/inkern.c                               | 61 ++++++++--------------
>  7 files changed, 78 insertions(+), 132 deletions(-)
>
Jonathan Cameron April 24, 2021, 2:15 p.m. UTC | #6
On Sun, 11 Apr 2021 15:21:20 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 8 Apr 2021 19:38:09 +0800
> Yicong Yang <yangyicong@hisilicon.com> wrote:
> 
> > Some devm variants are implemented with devres_alloc() and devres_add()
> > manually to only manage a single pointer. This can be simplified with
> > devm_add_action_or_reset() which works the same. Simplify these functions.
> > 
> > Yicong Yang (7):
> >   iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
> >   iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
> >   iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
> >   iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
> >   iio: core: simplify some devm functions
> >   iio: trigger: simplify __devm_iio_trigger_register
> >   iio: inkern: simplify some devm functions  
> 
> Nice set.  Note no rush for a v2 as IIO is effectively closed for the
> coming merge window.  Hence these won't hit linux-next now until after
> the merge window closes.

On second thoughts was just easier for me to make the minor tweaks and
apply so I did that.

All applied to the togreg branch of iio.git and pushed out as testing
for autobuilders etc to poke at.

Thanks,

Jonathan

> 
> Thanks,
> 
> Jonathan
> 
> > 
> >  drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
> >  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
> >  drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
> >  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
> >  drivers/iio/industrialio-core.c                    | 43 ++++++---------
> >  drivers/iio/industrialio-trigger.c                 | 18 ++-----
> >  drivers/iio/inkern.c                               | 61 ++++++++--------------
> >  7 files changed, 78 insertions(+), 132 deletions(-)
> >   
>
Yicong Yang April 25, 2021, 9:13 a.m. UTC | #7
On 2021/4/24 22:15, Jonathan Cameron wrote:
> On Sun, 11 Apr 2021 15:21:20 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
>> On Thu, 8 Apr 2021 19:38:09 +0800
>> Yicong Yang <yangyicong@hisilicon.com> wrote:
>>
>>> Some devm variants are implemented with devres_alloc() and devres_add()
>>> manually to only manage a single pointer. This can be simplified with
>>> devm_add_action_or_reset() which works the same. Simplify these functions.
>>>
>>> Yicong Yang (7):
>>>   iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register
>>>   iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free
>>>   iio: hw_consumer: simplify devm_iio_hw_consumer_alloc
>>>   iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext
>>>   iio: core: simplify some devm functions
>>>   iio: trigger: simplify __devm_iio_trigger_register
>>>   iio: inkern: simplify some devm functions  
>>
>> Nice set.  Note no rush for a v2 as IIO is effectively closed for the
>> coming merge window.  Hence these won't hit linux-next now until after
>> the merge window closes.
> 
> On second thoughts was just easier for me to make the minor tweaks and
> apply so I did that.
> 
> All applied to the togreg branch of iio.git and pushed out as testing
> for autobuilders etc to poke at.
> 

Thanks a lot! Sorry for didn't update, I have intended to send a v2 series after
the tree reopened. :)

Regards,
Yicong

> Thanks,
> 
> Jonathan
> 
>>
>> Thanks,
>>
>> Jonathan
>>
>>>
>>>  drivers/iio/adc/adi-axi-adc.c                      | 22 ++++----
>>>  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 22 ++++----
>>>  drivers/iio/buffer/industrialio-hw-consumer.c      | 25 ++++-----
>>>  drivers/iio/buffer/industrialio-triggered-buffer.c | 19 ++-----
>>>  drivers/iio/industrialio-core.c                    | 43 ++++++---------
>>>  drivers/iio/industrialio-trigger.c                 | 18 ++-----
>>>  drivers/iio/inkern.c                               | 61 ++++++++--------------
>>>  7 files changed, 78 insertions(+), 132 deletions(-)
>>>   
>>
> 
> 
> .
>