2020-06-23 06:15:22

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

Because clk_prepare_enable and clk_disable_unprepare should
check input clock parameter is NULL or not internally, then
we don't need to check them before calling the function.

Fixes: 9e28f6532c61 ("ASoC: fsl_mqs: Add MQS component driver")
Signed-off-by: Shengjiu Wang <[email protected]>
---
sound/soc/fsl/fsl_mqs.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/soc/fsl/fsl_mqs.c b/sound/soc/fsl/fsl_mqs.c
index 0c813a45bba7..b44b134390a3 100644
--- a/sound/soc/fsl/fsl_mqs.c
+++ b/sound/soc/fsl/fsl_mqs.c
@@ -266,11 +266,9 @@ static int fsl_mqs_runtime_resume(struct device *dev)
{
struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);

- if (mqs_priv->ipg)
- clk_prepare_enable(mqs_priv->ipg);
+ clk_prepare_enable(mqs_priv->ipg);

- if (mqs_priv->mclk)
- clk_prepare_enable(mqs_priv->mclk);
+ clk_prepare_enable(mqs_priv->mclk);

if (mqs_priv->use_gpr)
regmap_write(mqs_priv->regmap, IOMUXC_GPR2,
@@ -292,11 +290,8 @@ static int fsl_mqs_runtime_suspend(struct device *dev)
regmap_read(mqs_priv->regmap, REG_MQS_CTRL,
&mqs_priv->reg_mqs_ctrl);

- if (mqs_priv->mclk)
- clk_disable_unprepare(mqs_priv->mclk);
-
- if (mqs_priv->ipg)
- clk_disable_unprepare(mqs_priv->ipg);
+ clk_disable_unprepare(mqs_priv->mclk);
+ clk_disable_unprepare(mqs_priv->ipg);

return 0;
}
--
2.21.0


2020-06-23 06:19:35

by Nicolin Chen

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

On Tue, Jun 23, 2020 at 02:01:11PM +0800, Shengjiu Wang wrote:
> Because clk_prepare_enable and clk_disable_unprepare should
> check input clock parameter is NULL or not internally, then
> we don't need to check them before calling the function.
>
> Fixes: 9e28f6532c61 ("ASoC: fsl_mqs: Add MQS component driver")
> Signed-off-by: Shengjiu Wang <[email protected]>

Acked-by: Nicolin Chen <[email protected]>

2020-06-23 07:41:16

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

> In-Reply-To: <[email protected]>

I guess that it should be sufficient to specify such a field once
for the header information.


> Because clk_prepare_enable and clk_disable_unprepare should
> check input clock parameter is NULL or not internally,

I find this change description unclear.


> then we don't need to check them before calling the function.

Please use an imperative wording for the commit message.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=dd0d718152e4c65b173070d48ea9dfc06894c3e5#n151

Regards,
Markus

2020-06-23 08:36:12

by Shengjiu Wang

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

On Tue, Jun 23, 2020 at 3:38 PM Markus Elfring <[email protected]> wrote:
>
> > In-Reply-To: <[email protected]>
>
> I guess that it should be sufficient to specify such a field once
> for the header information.

seems it's caused by my "git format-patch" command, I will update
it, hope it is better next time.

>
>
> > Because clk_prepare_enable and clk_disable_unprepare should
> > check input clock parameter is NULL or not internally,
>
> I find this change description unclear.

clk_prepare_enable and clk_disable_unprepare check the input
clock parameter in the beginning of the function, if the parameter
is NULL, clk_prepare_enable and clk_disable_unprepare will
return immediately.

So Don't need to check input clock parameters before calling clk
API.

Do you think this commit message is better?

best regards
wang shengjiu

2020-06-23 09:00:30

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

> clk_prepare_enable and clk_disable_unprepare check the input
> clock parameter in the beginning of the function,

These functions call further functions which perform null pointer checks.


> if the parameter
> is NULL, clk_prepare_enable and clk_disable_unprepare will
> return immediately.

The interpretation of these function implementations seems to be reasonable.
Would you like to achieve any improvements for the corresponding software documentation?


> So Don't need to check input clock parameters before calling clk API.

What do you find imperative in this wording?

Another wording alternative:
Thus omit extra null pointer checks before four function calls.

Regards,
Markus

2020-06-23 11:39:11

by Shengjiu Wang

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

On Tue, Jun 23, 2020 at 4:55 PM Markus Elfring <[email protected]> wrote:
>
> > clk_prepare_enable and clk_disable_unprepare check the input
> > clock parameter in the beginning of the function,
>
> These functions call further functions which perform null pointer checks.
>
>
> > if the parameter
> > is NULL, clk_prepare_enable and clk_disable_unprepare will
> > return immediately.
>
> The interpretation of these function implementations seems to be reasonable.
> Would you like to achieve any improvements for the corresponding software documentation?

Which document do you mean?

>
>
> > So Don't need to check input clock parameters before calling clk API.
>
> What do you find imperative in this wording?
>
> Another wording alternative:
> Thus omit extra null pointer checks before four function calls.
>
> Regards,
> Markus

2020-06-23 12:48:24

by Markus Elfring

[permalink] [raw]
Subject: Re: [v2 1/2] ASoC: fsl_mqs: Don't check clock is NULL before calling clk API

>>> if the parameter
>>> is NULL, clk_prepare_enable and clk_disable_unprepare will
>>> return immediately.
>>
>> The interpretation of these function implementations seems to be reasonable.
>> Would you like to achieve any improvements for the corresponding software documentation?
>
> Which document do you mean?

Example:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/clk.h?id=dd0d718152e4c65b173070d48ea9dfc06894c3e5#n905
https://elixir.bootlin.com/linux/v5.7.2/source/include/linux/clk.h#L905

Regards,
Markus