Skip to contentSkip to conversation

clk: clk_register is deprecated

DISCUSSION Jerome Brunet 2 participants 4 messages Apr 30, 2020 – May 5, 2020

Subsystems (2)
lore
Share & tools
lore

Jerome Brunet

author reviewer
#0 lore raw

Hi Stephen,

We have a question regarding drivers which register clocks in CCF and later need to use these clocks.

So far, these drivers had been using clk_register() to get a 'struct clk*' they could later use with the linux/clk.h API.

Now that this clk_register() is deprecated in favor of clk_hw_register(), how are these driver supposed to get the per-user "struct clk*" they need ?

In this mmc thread [0] Martin proposed to go through a provider. I think it is overkill, especially for a device which will not provide its clocks to any other device.

They other way available is "hw->clk". I suspect it is not recommended to do so, is it ?

If not, what would be the recommended way to get the "struct clk*" from a newly registered "struct clk_hw *" ? Should we add something new to clk-provider.h API ?

Cheers
Jerome

[0]: https://lore.kernel.org/linux-amlogic/[email protected]

maintainer
#1 lore raw

Quoting Jerome Brunet (2020-04-30 05:24:41)

Quoted 16 lines

Hi Stephen,

We have a question regarding drivers which register clocks in CCF and later need to use these clocks.

So far, these drivers had been using clk_register() to get a 'struct clk*' they could later use with the linux/clk.h API.

Now that this clk_register() is deprecated in favor of clk_hw_register(), how are these driver supposed to get the per-user "struct clk*" they need ?

In this mmc thread [0] Martin proposed to go through a provider. I think it is overkill, especially for a device which will not provide its clocks to any other device.

Quoted 7 lines

They other way available is "hw->clk". I suspect it is not recommended to do so, is it ?

If not, what would be the recommended way to get the "struct clk*" from a newly registered "struct clk_hw *" ? Should we add something new to clk-provider.h API ?

Yes we should add a clk_hw_get_clk() API that takes a device pointer and a string name, mirroring the clk_get() API but cutting out the part where we have to go through the provider to find it.

This is so that one day in "the future" we can remove hw->clk and make that an internal detail that struct clk_hw can't see because we go through the clk_hw::clk_core pointer instead.

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

author reviewer
#2 lore raw
Quoted 20 lines · Stephen Boyd

Quoting Jerome Brunet (2020-04-30 05:24:41)

Quoted 19 lines

Hi Stephen,

We have a question regarding drivers which register clocks in CCF and later need to use these clocks.

So far, these drivers had been using clk_register() to get a 'struct clk*' they could later use with the linux/clk.h API.

Now that this clk_register() is deprecated in favor of clk_hw_register(), how are these driver supposed to get the per-user "struct clk*" they need ?

In this mmc thread [0] Martin proposed to go through a provider. I think it is overkill, especially for a device which will not provide its clocks to any other device.

They other way available is "hw->clk". I suspect it is not recommended to do so, is it ?

Quoted 8 lines
Quoted 4 lines

If not, what would be the recommended way to get the "struct clk*" from a newly registered "struct clk_hw *" ? Should we add something new to clk-provider.h API ?

Yes we should add a clk_hw_get_clk() API that takes a device pointer and a string name, mirroring the clk_get() API but cutting out the part where we have to go through the provider to find it.

We will try to propose something for clk_hw_get_clk() soon. If we do so, could we "UN-deprecate" clk_register() and make it a wrapper around clk_hw_register() and clk_hw_get_clk() ?

It would make it easier on drivers which both register and use clocks.

To get a short term solution for Martin and his MMC driver:
- If the above wrapper is OK and we commit on doing it soon, would you also be OK for martin to use clk_register() in his MMC driver (now) ?

- If not, could we use clk_hw->clk until we have clk_hw_get_clk() in CCF ?

Quoted 4 lines

This is so that one day in "the future" we can remove hw->clk and make that an internal detail that struct clk_hw can't see because we go through the clk_hw::clk_core pointer instead.

Yes, I know it is your secret plan ... ;)

maintainer
#3 lore raw

Quoting Jerome Brunet (2020-05-05 09:03:21)

Quoted 21 lines · Stephen Boyd
Quoted 11 lines

Quoting Jerome Brunet (2020-04-30 05:24:41)

Quoted 5 lines

If not, what would be the recommended way to get the "struct clk*" from a newly registered "struct clk_hw *" ? Should we add something new to clk-provider.h API ?

Yes we should add a clk_hw_get_clk() API that takes a device pointer and a string name, mirroring the clk_get() API but cutting out the part where we have to go through the provider to find it.

We will try to propose something for clk_hw_get_clk() soon. If we do so, could we "UN-deprecate" clk_register() and make it a wrapper around clk_hw_register() and clk_hw_get_clk() ?

It would make it easier on drivers which both register and use clocks.

To get a short term solution for Martin and his MMC driver:

Review

Quoted 5 lines
(quoted diff) +0 -2
-  If the above wrapper is OK and we commit on doing it soon, would you
   also be OK for martin to use clk_register() in his MMC driver (now) ?
 
-  If not, could we use clk_hw->clk until  we have clk_hw_get_clk() in
   CCF ?

Using clk_hw->clk until we have clk_hw_get_clk() is fine for now. Various drivers do that already and I hope that a simple coccinelle script can figure out how to convert that to the new function.l Is it much work to introduce this API now? I thought it would be fairly simple to do it but I haven't looked deeply.

Quoted 9 lines
Quoted 5 lines

This is so that one day in "the future" we can remove hw->clk and make that an internal detail that struct clk_hw can't see because we go through the clk_hw::clk_core pointer instead.

Yes, I know it is your secret plan ... ;)

Hehe