[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFhGd8oQ5jh21U4SG3aN5eZJ5h+Ywk4WLFa0yPz8bquFmA1mag@mail.gmail.com>
Date: Fri, 16 Feb 2024 10:58:58 -0800
From: Justin Stitt <justinstitt@...gle.com>
To: Jerome Brunet <jbrunet@...libre.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>, Arnd Bergmann <arnd@...db.de>,
Neil Armstrong <neil.armstrong@...aro.org>, Kevin Hilman <khilman@...libre.com>,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>, Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>,
Jernej Skrabec <jernej.skrabec@...il.com>, linux-arm-kernel@...ts.infradead.org,
linux-amlogic@...ts.infradead.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
Hi,
On Tue, Feb 13, 2024 at 6:28 AM Jerome Brunet <jbrunet@...libre.com> wrote:
>
> clang-16 warns about casting functions to incompatible types, as is done
> here to call clk_disable_unprepare:
>
> drivers/nvmem/meson-efuse.c:78:12: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
> 78 | (void(*)(void *))clk_disable_unprepare,
>
> The pattern of getting, enabling and setting a disable callback for a
> clock can be replaced with devm_clk_get_enabled(), which also fixes
> this warning.
>
> Fixes: 611fbca1c861 ("nvmem: meson-efuse: add peripheral clock")
> Reported-by: Arnd Bergmann <arnd@...db.de>
> Signed-off-by: Jerome Brunet <jbrunet@...libre.com>
> ---
> drivers/nvmem/meson-efuse.c | 25 +++----------------------
I love negative diffs ^^^^^^^^^^^^^^^
> 1 file changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
> index b922df99f9bc..33678d0af2c2 100644
> --- a/drivers/nvmem/meson-efuse.c
> +++ b/drivers/nvmem/meson-efuse.c
> @@ -47,7 +47,6 @@ static int meson_efuse_probe(struct platform_device *pdev)
> struct nvmem_config *econfig;
> struct clk *clk;
> unsigned int size;
> - int ret;
>
> sm_np = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0);
> if (!sm_np) {
> @@ -60,27 +59,9 @@ static int meson_efuse_probe(struct platform_device *pdev)
> if (!fw)
> return -EPROBE_DEFER;
>
> - clk = devm_clk_get(dev, NULL);
> - if (IS_ERR(clk)) {
> - ret = PTR_ERR(clk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to get efuse gate");
> - return ret;
> - }
> -
> - ret = clk_prepare_enable(clk);
> - if (ret) {
> - dev_err(dev, "failed to enable gate");
> - return ret;
> - }
> -
> - ret = devm_add_action_or_reset(dev,
> - (void(*)(void *))clk_disable_unprepare,
> - clk);
> - if (ret) {
> - dev_err(dev, "failed to add disable callback");
> - return ret;
> - }
> + clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(clk))
> + return dev_err_probe(dev, PTR_ERR(clk), "failed to get efuse gate");
Wow, this simplified nicely and doesn't make any new helpers (like
Arnd's version).
Reviewed-by: Justin Stitt <justinstitt@...gle.com>
>
> if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) {
> dev_err(dev, "failed to get max user");
> --
> 2.43.0
>
Thanks
Justin
Powered by blists - more mailing lists