mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
@ 2024-02-13 14:28 Jerome Brunet
  2024-02-13 14:59 ` Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jerome Brunet @ 2024-02-13 14:28 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Jerome Brunet, Arnd Bergmann, Neil Armstrong, Kevin Hilman,
	Martin Blumenstingl, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Jernej Skrabec, linux-arm-kernel,
	linux-amlogic, linux-kernel, llvm

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@arndb.de>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/nvmem/meson-efuse.c | 25 +++----------------------
 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");
 
 	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


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
  2024-02-13 14:28 [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch Jerome Brunet
@ 2024-02-13 14:59 ` Arnd Bergmann
  2024-02-15 22:00 ` Martin Blumenstingl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2024-02-13 14:59 UTC (permalink / raw)
  To: Jerome Brunet, Srinivas Kandagatla
  Cc: Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Jernej Skrabec, linux-arm-kernel, linux-amlogic, linux-kernel,
	llvm

On Tue, Feb 13, 2024, at 15:28, Jerome Brunet 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@arndb.de>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>

Perfect, much nicer than my version.

Acked-by: Arnd Bergmann <arnd@arndb.de>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
  2024-02-13 14:28 [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch Jerome Brunet
  2024-02-13 14:59 ` Arnd Bergmann
@ 2024-02-15 22:00 ` Martin Blumenstingl
  2024-02-16 18:58 ` Justin Stitt
  2024-02-21  7:17 ` Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2024-02-15 22:00 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: Srinivas Kandagatla, Arnd Bergmann, Neil Armstrong, Kevin Hilman,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Jernej Skrabec, linux-arm-kernel, linux-amlogic, linux-kernel,
	llvm

On Tue, Feb 13, 2024 at 3:28 PM Jerome Brunet <jbrunet@baylibre.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@arndb.de>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Thanks Jerome!

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
  2024-02-13 14:28 [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch Jerome Brunet
  2024-02-13 14:59 ` Arnd Bergmann
  2024-02-15 22:00 ` Martin Blumenstingl
@ 2024-02-16 18:58 ` Justin Stitt
  2024-02-21  7:17 ` Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Justin Stitt @ 2024-02-16 18:58 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: Srinivas Kandagatla, Arnd Bergmann, Neil Armstrong, Kevin Hilman,
	Martin Blumenstingl, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Jernej Skrabec, linux-arm-kernel, linux-amlogic,
	linux-kernel, llvm

Hi,

On Tue, Feb 13, 2024 at 6:28 AM Jerome Brunet <jbrunet@baylibre.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@arndb.de>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.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@google.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

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch
  2024-02-13 14:28 [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch Jerome Brunet
                   ` (2 preceding siblings ...)
  2024-02-16 18:58 ` Justin Stitt
@ 2024-02-21  7:17 ` Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2024-02-21  7:17 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: Arnd Bergmann, Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Jernej Skrabec, linux-arm-kernel, linux-amlogic, linux-kernel,
	llvm


On Tue, 13 Feb 2024 15:28:28 +0100, Jerome Brunet 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.
> 
> [...]

Applied, thanks!

[1/1] nvmem: meson-efuse: fix function pointer type mismatch
      commit: 6b475e23544a560b4bf2acfab8dc54c4e7b1749e

Best regards,
-- 
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-21  7:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 14:28 [PATCH v2] nvmem: meson-efuse: fix function pointer type mismatch Jerome Brunet
2024-02-13 14:59 ` Arnd Bergmann
2024-02-15 22:00 ` Martin Blumenstingl
2024-02-16 18:58 ` Justin Stitt
2024-02-21  7:17 ` Srinivas Kandagatla

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®