mbox series

[0/4] Provide devm_clk_bulk_get_all_enabled() helper

Message ID 20240914-clk_bulk_ena_fix-v1-0-ce3537585c06@collabora.com (mailing list archive)
Headers show
Series Provide devm_clk_bulk_get_all_enabled() helper | expand

Message

Cristian Ciocaltea Sept. 14, 2024, 6:04 p.m. UTC
Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
clocks") added devm_clk_bulk_get_all_enable() function, but missed to
return the number of clocks stored in the clk_bulk_data table referenced
by the clks argument.

That is required in case there is a need to iterate these clocks later,
therefore I couldn't see any use case of this parameter and should have
been simply removed from the function declaration.

The first patch in the series provides devm_clk_bulk_get_all_enabled()
variant, which is consistent with devm_clk_bulk_get_all() in terms of
the returned value:

 > 0 if one or more clocks have been stored
 = 0 if there are no clocks
 < 0 if an error occurred

Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use
the past form of 'enable'.

The next two patches switch existing users of devm_clk_get_enable() to
the new helper - there were only two, as of next-20240913.

The last patch drops the now obsolete devm_clk_bulk_get_all_enable()
helper.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Cristian Ciocaltea (4):
      clk: Provide devm_clk_bulk_get_all_enabled() helper
      soc: mediatek: pwrap: Switch to devm_clk_bulk_get_all_enabled()
      PCI: exynos: Switch to devm_clk_bulk_get_all_enabled()
      clk: Drop obsolete devm_clk_bulk_get_all_enable() helper

 drivers/clk/clk-devres.c                | 30 ++++++++++++++++--------------
 drivers/pci/controller/dwc/pci-exynos.c |  2 +-
 drivers/soc/mediatek/mtk-pmic-wrap.c    |  4 ++--
 include/linux/clk.h                     | 12 +++++++-----
 4 files changed, 26 insertions(+), 22 deletions(-)
---
base-commit: 5acd9952f95fb4b7da6d09a3be39195a80845eb6
change-id: 20240912-clk_bulk_ena_fix-16ba77358ddf

Comments

Manivannan Sadhasivam Sept. 24, 2024, 2:36 p.m. UTC | #1
On Sat, Sep 14, 2024 at 09:04:53PM +0300, Cristian Ciocaltea wrote:
> Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
> clocks") added devm_clk_bulk_get_all_enable() function, but missed to
> return the number of clocks stored in the clk_bulk_data table referenced
> by the clks argument.
> 
> That is required in case there is a need to iterate these clocks later,
> therefore I couldn't see any use case of this parameter and should have
> been simply removed from the function declaration.
> 

Is there an user that currerntly does this?

- Mani

> The first patch in the series provides devm_clk_bulk_get_all_enabled()
> variant, which is consistent with devm_clk_bulk_get_all() in terms of
> the returned value:
> 
>  > 0 if one or more clocks have been stored
>  = 0 if there are no clocks
>  < 0 if an error occurred
> 
> Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use
> the past form of 'enable'.
> 
> The next two patches switch existing users of devm_clk_get_enable() to
> the new helper - there were only two, as of next-20240913.
> 
> The last patch drops the now obsolete devm_clk_bulk_get_all_enable()
> helper.
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> Cristian Ciocaltea (4):
>       clk: Provide devm_clk_bulk_get_all_enabled() helper
>       soc: mediatek: pwrap: Switch to devm_clk_bulk_get_all_enabled()
>       PCI: exynos: Switch to devm_clk_bulk_get_all_enabled()
>       clk: Drop obsolete devm_clk_bulk_get_all_enable() helper
> 
>  drivers/clk/clk-devres.c                | 30 ++++++++++++++++--------------
>  drivers/pci/controller/dwc/pci-exynos.c |  2 +-
>  drivers/soc/mediatek/mtk-pmic-wrap.c    |  4 ++--
>  include/linux/clk.h                     | 12 +++++++-----
>  4 files changed, 26 insertions(+), 22 deletions(-)
> ---
> base-commit: 5acd9952f95fb4b7da6d09a3be39195a80845eb6
> change-id: 20240912-clk_bulk_ena_fix-16ba77358ddf
>
AngeloGioacchino Del Regno Sept. 25, 2024, 7:52 a.m. UTC | #2
Il 24/09/24 16:36, Manivannan Sadhasivam ha scritto:
> On Sat, Sep 14, 2024 at 09:04:53PM +0300, Cristian Ciocaltea wrote:
>> Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
>> clocks") added devm_clk_bulk_get_all_enable() function, but missed to
>> return the number of clocks stored in the clk_bulk_data table referenced
>> by the clks argument.
>>
>> That is required in case there is a need to iterate these clocks later,
>> therefore I couldn't see any use case of this parameter and should have
>> been simply removed from the function declaration.
>>
> 
> Is there an user that currerntly does this?
> 

Yes and the patch wasn't sent upstream yet, but anyway, regardless of that,
this series is fixing inconsistency with both naming and usage between the
clock (bulk) API functions, with that being the only function acting
different from the others, at best confusing people.

Cheers,
Angelo

> - Mani
> 
>> The first patch in the series provides devm_clk_bulk_get_all_enabled()
>> variant, which is consistent with devm_clk_bulk_get_all() in terms of
>> the returned value:
>>
>>   > 0 if one or more clocks have been stored
>>   = 0 if there are no clocks
>>   < 0 if an error occurred
>>
>> Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use
>> the past form of 'enable'.
>>
>> The next two patches switch existing users of devm_clk_get_enable() to
>> the new helper - there were only two, as of next-20240913.
>>
>> The last patch drops the now obsolete devm_clk_bulk_get_all_enable()
>> helper.
>>
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>> ---
>> Cristian Ciocaltea (4):
>>        clk: Provide devm_clk_bulk_get_all_enabled() helper
>>        soc: mediatek: pwrap: Switch to devm_clk_bulk_get_all_enabled()
>>        PCI: exynos: Switch to devm_clk_bulk_get_all_enabled()
>>        clk: Drop obsolete devm_clk_bulk_get_all_enable() helper
>>
>>   drivers/clk/clk-devres.c                | 30 ++++++++++++++++--------------
>>   drivers/pci/controller/dwc/pci-exynos.c |  2 +-
>>   drivers/soc/mediatek/mtk-pmic-wrap.c    |  4 ++--
>>   include/linux/clk.h                     | 12 +++++++-----
>>   4 files changed, 26 insertions(+), 22 deletions(-)
>> ---
>> base-commit: 5acd9952f95fb4b7da6d09a3be39195a80845eb6
>> change-id: 20240912-clk_bulk_ena_fix-16ba77358ddf
>>
>
Manivannan Sadhasivam Sept. 25, 2024, 7:56 a.m. UTC | #3
On Wed, Sep 25, 2024 at 09:52:44AM +0200, AngeloGioacchino Del Regno wrote:
> Il 24/09/24 16:36, Manivannan Sadhasivam ha scritto:
> > On Sat, Sep 14, 2024 at 09:04:53PM +0300, Cristian Ciocaltea wrote:
> > > Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
> > > clocks") added devm_clk_bulk_get_all_enable() function, but missed to
> > > return the number of clocks stored in the clk_bulk_data table referenced
> > > by the clks argument.
> > > 
> > > That is required in case there is a need to iterate these clocks later,
> > > therefore I couldn't see any use case of this parameter and should have
> > > been simply removed from the function declaration.
> > > 
> > 
> > Is there an user that currerntly does this?
> > 
> 
> Yes and the patch wasn't sent upstream yet, but anyway, regardless of that,
> this series is fixing inconsistency with both naming and usage between the
> clock (bulk) API functions, with that being the only function acting
> different from the others, at best confusing people.
> 

I agree with the 'inconsistency' part of the API, but I wouldn't call it as
*broken* as this series does. Please fix that and you can have my:

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> Cheers,
> Angelo
> 
> > - Mani
> > 
> > > The first patch in the series provides devm_clk_bulk_get_all_enabled()
> > > variant, which is consistent with devm_clk_bulk_get_all() in terms of
> > > the returned value:
> > > 
> > >   > 0 if one or more clocks have been stored
> > >   = 0 if there are no clocks
> > >   < 0 if an error occurred
> > > 
> > > Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use
> > > the past form of 'enable'.
> > > 
> > > The next two patches switch existing users of devm_clk_get_enable() to
> > > the new helper - there were only two, as of next-20240913.
> > > 
> > > The last patch drops the now obsolete devm_clk_bulk_get_all_enable()
> > > helper.
> > > 
> > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> > > ---
> > > Cristian Ciocaltea (4):
> > >        clk: Provide devm_clk_bulk_get_all_enabled() helper
> > >        soc: mediatek: pwrap: Switch to devm_clk_bulk_get_all_enabled()
> > >        PCI: exynos: Switch to devm_clk_bulk_get_all_enabled()
> > >        clk: Drop obsolete devm_clk_bulk_get_all_enable() helper
> > > 
> > >   drivers/clk/clk-devres.c                | 30 ++++++++++++++++--------------
> > >   drivers/pci/controller/dwc/pci-exynos.c |  2 +-
> > >   drivers/soc/mediatek/mtk-pmic-wrap.c    |  4 ++--
> > >   include/linux/clk.h                     | 12 +++++++-----
> > >   4 files changed, 26 insertions(+), 22 deletions(-)
> > > ---
> > > base-commit: 5acd9952f95fb4b7da6d09a3be39195a80845eb6
> > > change-id: 20240912-clk_bulk_ena_fix-16ba77358ddf
> > > 
> > 
> 
>
Cristian Ciocaltea Sept. 26, 2024, 10:49 a.m. UTC | #4
On 9/25/24 10:56 AM, Manivannan Sadhasivam wrote:
> On Wed, Sep 25, 2024 at 09:52:44AM +0200, AngeloGioacchino Del Regno wrote:
>> Il 24/09/24 16:36, Manivannan Sadhasivam ha scritto:
>>> On Sat, Sep 14, 2024 at 09:04:53PM +0300, Cristian Ciocaltea wrote:
>>>> Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
>>>> clocks") added devm_clk_bulk_get_all_enable() function, but missed to
>>>> return the number of clocks stored in the clk_bulk_data table referenced
>>>> by the clks argument.
>>>>
>>>> That is required in case there is a need to iterate these clocks later,
>>>> therefore I couldn't see any use case of this parameter and should have
>>>> been simply removed from the function declaration.
>>>>
>>>
>>> Is there an user that currerntly does this?
>>>
>>
>> Yes and the patch wasn't sent upstream yet, but anyway, regardless of that,
>> this series is fixing inconsistency with both naming and usage between the
>> clock (bulk) API functions, with that being the only function acting
>> different from the others, at best confusing people.
>>
> 
> I agree with the 'inconsistency' part of the API, but I wouldn't call it as
> *broken* as this series does. Please fix that and you can have my:
> 
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks Angelo and Mani for reviewing this.

I've submitted v2:

https://lore.kernel.org/lkml/20240926-clk_bulk_ena_fix-v2-0-9c767510fbb5@collabora.com/

Regards,
Cristian