* [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
@ 2024-08-21 1:39 Huan Yang
2024-08-21 7:00 ` Christophe JAILLET
0 siblings, 1 reply; 6+ messages in thread
From: Huan Yang @ 2024-08-21 1:39 UTC (permalink / raw)
To: Jassi Brar, Orson Zhai, Baolin Wang, Chunyan Zhang, linux-kernel
Cc: opensource.kernel, Huan Yang, Christophe JAILLET
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids the calls to clk_disable_unprepare().
Due to clk only used in probe, not in suspend\resume, this pointer can
remove from sprd_mbox_priv to save a little memory.
Signed-off-by: Huan Yang <link@vivo.com>
Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v1 -> v2: remove clk pointer from sprd_mbox_priv
drivers/mailbox/sprd-mailbox.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/drivers/mailbox/sprd-mailbox.c b/drivers/mailbox/sprd-mailbox.c
index 9ae57de77d4d..ee8539dfcef5 100644
--- a/drivers/mailbox/sprd-mailbox.c
+++ b/drivers/mailbox/sprd-mailbox.c
@@ -62,7 +62,6 @@ struct sprd_mbox_priv {
void __iomem *outbox_base;
/* Base register address for supplementary outbox */
void __iomem *supp_base;
- struct clk *clk;
u32 outbox_fifo_depth;
struct mutex lock;
@@ -291,19 +290,13 @@ static const struct mbox_chan_ops sprd_mbox_ops = {
.shutdown = sprd_mbox_shutdown,
};
-static void sprd_mbox_disable(void *data)
-{
- struct sprd_mbox_priv *priv = data;
-
- clk_disable_unprepare(priv->clk);
-}
-
static int sprd_mbox_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct sprd_mbox_priv *priv;
int ret, inbox_irq, outbox_irq, supp_irq;
unsigned long id, supp;
+ struct clk *clk;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -331,20 +324,10 @@ static int sprd_mbox_probe(struct platform_device *pdev)
if (IS_ERR(priv->outbox_base))
return PTR_ERR(priv->outbox_base);
- priv->clk = devm_clk_get(dev, "enable");
- if (IS_ERR(priv->clk)) {
+ clk = devm_clk_get_enabled(dev, "enable");
+ if (IS_ERR(clk)) {
dev_err(dev, "failed to get mailbox clock\n");
- return PTR_ERR(priv->clk);
- }
-
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- return ret;
-
- ret = devm_add_action_or_reset(dev, sprd_mbox_disable, priv);
- if (ret) {
- dev_err(dev, "failed to add mailbox disable action\n");
- return ret;
+ return PTR_ERR(clk);
}
inbox_irq = platform_get_irq_byname(pdev, "inbox");
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
2024-08-21 1:39 [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers Huan Yang
@ 2024-08-21 7:00 ` Christophe JAILLET
2024-08-21 7:08 ` Huan Yang
0 siblings, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2024-08-21 7:00 UTC (permalink / raw)
To: Huan Yang, Jassi Brar, Orson Zhai, Baolin Wang, Chunyan Zhang,
linux-kernel
Cc: opensource.kernel
Le 21/08/2024 à 03:39, Huan Yang a écrit :
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids the calls to clk_disable_unprepare().
>
> Due to clk only used in probe, not in suspend\resume, this pointer can
> remove from sprd_mbox_priv to save a little memory.
>
> Signed-off-by: Huan Yang <link@vivo.com>
> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Nitpick: no need to add this S-b. I just made a comment when looking at
your patch in order to improve it. I'm not the one that suggested the
initial change. All merit is yours.
Also, I think that, if used, it should be above your Signed-off.
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v1 -> v2: remove clk pointer from sprd_mbox_priv
>
> drivers/mailbox/sprd-mailbox.c | 25 ++++---------------------
> 1 file changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/mailbox/sprd-mailbox.c b/drivers/mailbox/sprd-mailbox.c
> index 9ae57de77d4d..ee8539dfcef5 100644
> --- a/drivers/mailbox/sprd-mailbox.c
> +++ b/drivers/mailbox/sprd-mailbox.c
> @@ -62,7 +62,6 @@ struct sprd_mbox_priv {
> void __iomem *outbox_base;
> /* Base register address for supplementary outbox */
> void __iomem *supp_base;
> - struct clk *clk;
> u32 outbox_fifo_depth;
>
> struct mutex lock;
> @@ -291,19 +290,13 @@ static const struct mbox_chan_ops sprd_mbox_ops = {
> .shutdown = sprd_mbox_shutdown,
> };
>
> -static void sprd_mbox_disable(void *data)
> -{
> - struct sprd_mbox_priv *priv = data;
> -
> - clk_disable_unprepare(priv->clk);
> -}
> -
> static int sprd_mbox_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct sprd_mbox_priv *priv;
> int ret, inbox_irq, outbox_irq, supp_irq;
> unsigned long id, supp;
> + struct clk *clk;
>
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -331,20 +324,10 @@ static int sprd_mbox_probe(struct platform_device *pdev)
> if (IS_ERR(priv->outbox_base))
> return PTR_ERR(priv->outbox_base);
>
> - priv->clk = devm_clk_get(dev, "enable");
> - if (IS_ERR(priv->clk)) {
> + clk = devm_clk_get_enabled(dev, "enable");
> + if (IS_ERR(clk)) {
> dev_err(dev, "failed to get mailbox clock\n");
> - return PTR_ERR(priv->clk);
> - }
> -
> - ret = clk_prepare_enable(priv->clk);
> - if (ret)
> - return ret;
> -
> - ret = devm_add_action_or_reset(dev, sprd_mbox_disable, priv);
> - if (ret) {
> - dev_err(dev, "failed to add mailbox disable action\n");
> - return ret;
> + return PTR_ERR(clk);
> }
>
> inbox_irq = platform_get_irq_byname(pdev, "inbox");
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
2024-08-21 7:00 ` Christophe JAILLET
@ 2024-08-21 7:08 ` Huan Yang
2024-08-21 10:09 ` Christophe JAILLET
0 siblings, 1 reply; 6+ messages in thread
From: Huan Yang @ 2024-08-21 7:08 UTC (permalink / raw)
To: Christophe JAILLET, Jassi Brar, Orson Zhai, Baolin Wang,
Chunyan Zhang, linux-kernel
Cc: opensource.kernel
在 2024/8/21 15:00, Christophe JAILLET 写道:
> Le 21/08/2024 à 03:39, Huan Yang a écrit :
>> The devm_clk_get_enabled() helpers:
>> - call devm_clk_get()
>> - call clk_prepare_enable() and register what is needed in
>> order to
>> call clk_disable_unprepare() when needed, as a managed resource.
>>
>> This simplifies the code and avoids the calls to
>> clk_disable_unprepare().
>>
>> Due to clk only used in probe, not in suspend\resume, this pointer can
>> remove from sprd_mbox_priv to save a little memory.
>>
>> Signed-off-by: Huan Yang <link@vivo.com>
>> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
>
> Nitpick: no need to add this S-b. I just made a comment when looking
> at your patch in order to improve it. I'm not the one that suggested
> the initial change. All merit is yours.
Your suggestion is helpfull, help this patch be better.
>
> Also, I think that, if used, it should be above your Signed-off.
Hmmm, it's neccessary? If so, I'd like to update it.
>
>
> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
>> ---
>> v1 -> v2: remove clk pointer from sprd_mbox_priv
>>
>> drivers/mailbox/sprd-mailbox.c | 25 ++++---------------------
>> 1 file changed, 4 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/mailbox/sprd-mailbox.c
>> b/drivers/mailbox/sprd-mailbox.c
>> index 9ae57de77d4d..ee8539dfcef5 100644
>> --- a/drivers/mailbox/sprd-mailbox.c
>> +++ b/drivers/mailbox/sprd-mailbox.c
>> @@ -62,7 +62,6 @@ struct sprd_mbox_priv {
>> void __iomem *outbox_base;
>> /* Base register address for supplementary outbox */
>> void __iomem *supp_base;
>> - struct clk *clk;
>> u32 outbox_fifo_depth;
>> struct mutex lock;
>> @@ -291,19 +290,13 @@ static const struct mbox_chan_ops sprd_mbox_ops
>> = {
>> .shutdown = sprd_mbox_shutdown,
>> };
>> -static void sprd_mbox_disable(void *data)
>> -{
>> - struct sprd_mbox_priv *priv = data;
>> -
>> - clk_disable_unprepare(priv->clk);
>> -}
>> -
>> static int sprd_mbox_probe(struct platform_device *pdev)
>> {
>> struct device *dev = &pdev->dev;
>> struct sprd_mbox_priv *priv;
>> int ret, inbox_irq, outbox_irq, supp_irq;
>> unsigned long id, supp;
>> + struct clk *clk;
>> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>> if (!priv)
>> @@ -331,20 +324,10 @@ static int sprd_mbox_probe(struct
>> platform_device *pdev)
>> if (IS_ERR(priv->outbox_base))
>> return PTR_ERR(priv->outbox_base);
>> - priv->clk = devm_clk_get(dev, "enable");
>> - if (IS_ERR(priv->clk)) {
>> + clk = devm_clk_get_enabled(dev, "enable");
>> + if (IS_ERR(clk)) {
>> dev_err(dev, "failed to get mailbox clock\n");
>> - return PTR_ERR(priv->clk);
>> - }
>> -
>> - ret = clk_prepare_enable(priv->clk);
>> - if (ret)
>> - return ret;
>> -
>> - ret = devm_add_action_or_reset(dev, sprd_mbox_disable, priv);
>> - if (ret) {
>> - dev_err(dev, "failed to add mailbox disable action\n");
>> - return ret;
>> + return PTR_ERR(clk);
>> }
>> inbox_irq = platform_get_irq_byname(pdev, "inbox");
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
2024-08-21 7:08 ` Huan Yang
@ 2024-08-21 10:09 ` Christophe JAILLET
2024-08-21 14:45 ` Jassi Brar
0 siblings, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2024-08-21 10:09 UTC (permalink / raw)
To: Huan Yang, Jassi Brar, Orson Zhai, Baolin Wang, Chunyan Zhang,
linux-kernel
Cc: opensource.kernel
Le 21/08/2024 à 09:08, Huan Yang a écrit :
>
> 在 2024/8/21 15:00, Christophe JAILLET 写道:
>> Le 21/08/2024 à 03:39, Huan Yang a écrit :
>>> The devm_clk_get_enabled() helpers:
>>> - call devm_clk_get()
>>> - call clk_prepare_enable() and register what is needed in
>>> order to
>>> call clk_disable_unprepare() when needed, as a managed resource.
>>>
>>> This simplifies the code and avoids the calls to
>>> clk_disable_unprepare().
>>>
>>> Due to clk only used in probe, not in suspend\resume, this pointer can
>>> remove from sprd_mbox_priv to save a little memory.
>>>
>>> Signed-off-by: Huan Yang <link@vivo.com>
>>> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>
>>
>> Nitpick: no need to add this S-b. I just made a comment when looking
>> at your patch in order to improve it. I'm not the one that suggested
>> the initial change. All merit is yours.
> Your suggestion is helpfull, help this patch be better.
>>
>> Also, I think that, if used, it should be above your Signed-off.
> Hmmm, it's neccessary? If so, I'd like to update it.
I don't think it is useful and personally I would remove it, but you can
keep it if it makes sense to you.
CJ
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
2024-08-21 10:09 ` Christophe JAILLET
@ 2024-08-21 14:45 ` Jassi Brar
2024-08-22 1:54 ` Huan Yang
0 siblings, 1 reply; 6+ messages in thread
From: Jassi Brar @ 2024-08-21 14:45 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Huan Yang, Orson Zhai, Baolin Wang, Chunyan Zhang, linux-kernel,
opensource.kernel
On Wed, Aug 21, 2024 at 5:09 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 21/08/2024 à 09:08, Huan Yang a écrit :
> >
> > 在 2024/8/21 15:00, Christophe JAILLET 写道:
> >> Le 21/08/2024 à 03:39, Huan Yang a écrit :
> >>> The devm_clk_get_enabled() helpers:
> >>> - call devm_clk_get()
> >>> - call clk_prepare_enable() and register what is needed in
> >>> order to
> >>> call clk_disable_unprepare() when needed, as a managed resource.
> >>>
> >>> This simplifies the code and avoids the calls to
> >>> clk_disable_unprepare().
> >>>
> >>> Due to clk only used in probe, not in suspend\resume, this pointer can
> >>> remove from sprd_mbox_priv to save a little memory.
> >>>
> >>> Signed-off-by: Huan Yang <link@vivo.com>
> >>> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >>
> >>
> >> Nitpick: no need to add this S-b. I just made a comment when looking
> >> at your patch in order to improve it. I'm not the one that suggested
> >> the initial change. All merit is yours.
> > Your suggestion is helpfull, help this patch be better.
> >>
> >> Also, I think that, if used, it should be above your Signed-off.
> > Hmmm, it's neccessary? If so, I'd like to update it.
>
> I don't think it is useful and personally I would remove it, but you can
> keep it if it makes sense to you.
>
I think Reviewed-by is appropriate.
cheers!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers
2024-08-21 14:45 ` Jassi Brar
@ 2024-08-22 1:54 ` Huan Yang
0 siblings, 0 replies; 6+ messages in thread
From: Huan Yang @ 2024-08-22 1:54 UTC (permalink / raw)
To: Jassi Brar, Christophe JAILLET
Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, linux-kernel, opensource.kernel
在 2024/8/21 22:45, Jassi Brar 写道:
> On Wed, Aug 21, 2024 at 5:09 AM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>> Le 21/08/2024 à 09:08, Huan Yang a écrit :
>>> 在 2024/8/21 15:00, Christophe JAILLET 写道:
>>>> Le 21/08/2024 à 03:39, Huan Yang a écrit :
>>>>> The devm_clk_get_enabled() helpers:
>>>>> - call devm_clk_get()
>>>>> - call clk_prepare_enable() and register what is needed in
>>>>> order to
>>>>> call clk_disable_unprepare() when needed, as a managed resource.
>>>>>
>>>>> This simplifies the code and avoids the calls to
>>>>> clk_disable_unprepare().
>>>>>
>>>>> Due to clk only used in probe, not in suspend\resume, this pointer can
>>>>> remove from sprd_mbox_priv to save a little memory.
>>>>>
>>>>> Signed-off-by: Huan Yang <link@vivo.com>
>>>>> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>>
>>>> Nitpick: no need to add this S-b. I just made a comment when looking
>>>> at your patch in order to improve it. I'm not the one that suggested
>>>> the initial change. All merit is yours.
>>> Your suggestion is helpfull, help this patch be better.
>>>> Also, I think that, if used, it should be above your Signed-off.
>>> Hmmm, it's neccessary? If so, I'd like to update it.
>> I don't think it is useful and personally I would remove it, but you can
>> keep it if it makes sense to you.
>>
> I think Reviewed-by is appropriate.
OK, I'll update it
>
> cheers!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-22 1:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21 1:39 [PATCH v2] mailbox: sprd: Use devm_clk_get_enabled() helpers Huan Yang
2024-08-21 7:00 ` Christophe JAILLET
2024-08-21 7:08 ` Huan Yang
2024-08-21 10:09 ` Christophe JAILLET
2024-08-21 14:45 ` Jassi Brar
2024-08-22 1:54 ` Huan Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®