linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type
@ 2023-05-10 12:39 Simon Horman
  2023-05-10 12:54 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Horman @ 2023-05-10 12:39 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-mmc,
	linux-arm-kernel, linux-amlogic, llvm, Simon Horman

Rather than casting mmc_free_host to an incompatible function type,
provide a trivial wrapper with the correct signature for the use-case.

Reported by clang-16 with W=1:

 .../meson-mx-sdhc-mmc.c:791:38: error: cast from 'void (*)(struct mmc_host *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
         ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ./include/linux/device.h:265:38: note: expanded from macro 'devm_add_action_or_reset'
         __devm_add_action_or_reset(release, action, data, #action)
                                            ^~~~~~

The same approach is taken in litex_mmc.c with the function
litex_mmc_free_host_wrapper(). There may be scope for consolidation.

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/mmc/host/meson-mx-sdhc-mmc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
index da85c2f2acb8..97168cdfa8e9 100644
--- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
+++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
@@ -776,6 +776,11 @@ static void meson_mx_sdhc_init_hw(struct mmc_host *mmc)
 	regmap_write(host->regmap, MESON_SDHC_ISTA, MESON_SDHC_ISTA_ALL_IRQS);
 }
 
+static void meason_mx_mmc_free_host(void *data)
+{
+       mmc_free_host(data);
+}
+
 static int meson_mx_sdhc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -788,8 +793,7 @@ static int meson_mx_sdhc_probe(struct platform_device *pdev)
 	if (!mmc)
 		return -ENOMEM;
 
-	ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
-				       mmc);
+	ret = devm_add_action_or_reset(dev, meason_mx_mmc_free_host, mmc);
 	if (ret) {
 		dev_err(dev, "Failed to register mmc_free_host action\n");
 		return ret;


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

* Re: [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type
  2023-05-10 12:39 [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type Simon Horman
@ 2023-05-10 12:54 ` Neil Armstrong
  2023-05-10 20:20 ` Martin Blumenstingl
  2023-05-24 13:10 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2023-05-10 12:54 UTC (permalink / raw)
  To: Simon Horman, Ulf Hansson
  Cc: Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-mmc,
	linux-arm-kernel, linux-amlogic, llvm

On 10/05/2023 14:39, Simon Horman wrote:
> Rather than casting mmc_free_host to an incompatible function type,
> provide a trivial wrapper with the correct signature for the use-case.
> 
> Reported by clang-16 with W=1:
> 
>   .../meson-mx-sdhc-mmc.c:791:38: error: cast from 'void (*)(struct mmc_host *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>           ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
>                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   ./include/linux/device.h:265:38: note: expanded from macro 'devm_add_action_or_reset'
>           __devm_add_action_or_reset(release, action, data, #action)
>                                              ^~~~~~
> 
> The same approach is taken in litex_mmc.c with the function
> litex_mmc_free_host_wrapper(). There may be scope for consolidation.
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>   drivers/mmc/host/meson-mx-sdhc-mmc.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
> index da85c2f2acb8..97168cdfa8e9 100644
> --- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
> +++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
> @@ -776,6 +776,11 @@ static void meson_mx_sdhc_init_hw(struct mmc_host *mmc)
>   	regmap_write(host->regmap, MESON_SDHC_ISTA, MESON_SDHC_ISTA_ALL_IRQS);
>   }
>   
> +static void meason_mx_mmc_free_host(void *data)
> +{
> +       mmc_free_host(data);
> +}
> +
>   static int meson_mx_sdhc_probe(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;
> @@ -788,8 +793,7 @@ static int meson_mx_sdhc_probe(struct platform_device *pdev)
>   	if (!mmc)
>   		return -ENOMEM;
>   
> -	ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
> -				       mmc);
> +	ret = devm_add_action_or_reset(dev, meason_mx_mmc_free_host, mmc);
>   	if (ret) {
>   		dev_err(dev, "Failed to register mmc_free_host action\n");
>   		return ret;
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

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

* Re: [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type
  2023-05-10 12:39 [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type Simon Horman
  2023-05-10 12:54 ` Neil Armstrong
@ 2023-05-10 20:20 ` Martin Blumenstingl
  2023-05-24 13:10 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2023-05-10 20:20 UTC (permalink / raw)
  To: Simon Horman
  Cc: Ulf Hansson, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-mmc,
	linux-arm-kernel, linux-amlogic, llvm

On Wed, May 10, 2023 at 2:39 PM Simon Horman <horms@kernel.org> wrote:
>
> Rather than casting mmc_free_host to an incompatible function type,
> provide a trivial wrapper with the correct signature for the use-case.
>
> Reported by clang-16 with W=1:
>
>  .../meson-mx-sdhc-mmc.c:791:38: error: cast from 'void (*)(struct mmc_host *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
>                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  ./include/linux/device.h:265:38: note: expanded from macro 'devm_add_action_or_reset'
>          __devm_add_action_or_reset(release, action, data, #action)
>                                             ^~~~~~
>
> The same approach is taken in litex_mmc.c with the function
> litex_mmc_free_host_wrapper(). There may be scope for consolidation.
>
> No functional change intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

* Re: [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type
  2023-05-10 12:39 [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type Simon Horman
  2023-05-10 12:54 ` Neil Armstrong
  2023-05-10 20:20 ` Martin Blumenstingl
@ 2023-05-24 13:10 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2023-05-24 13:10 UTC (permalink / raw)
  To: Simon Horman
  Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-mmc,
	linux-arm-kernel, linux-amlogic, llvm

On Wed, 10 May 2023 at 14:39, Simon Horman <horms@kernel.org> wrote:
>
> Rather than casting mmc_free_host to an incompatible function type,
> provide a trivial wrapper with the correct signature for the use-case.
>
> Reported by clang-16 with W=1:
>
>  .../meson-mx-sdhc-mmc.c:791:38: error: cast from 'void (*)(struct mmc_host *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
>                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  ./include/linux/device.h:265:38: note: expanded from macro 'devm_add_action_or_reset'
>          __devm_add_action_or_reset(release, action, data, #action)
>                                             ^~~~~~
>
> The same approach is taken in litex_mmc.c with the function
> litex_mmc_free_host_wrapper(). There may be scope for consolidation.
>
> No functional change intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/meson-mx-sdhc-mmc.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
> index da85c2f2acb8..97168cdfa8e9 100644
> --- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
> +++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
> @@ -776,6 +776,11 @@ static void meson_mx_sdhc_init_hw(struct mmc_host *mmc)
>         regmap_write(host->regmap, MESON_SDHC_ISTA, MESON_SDHC_ISTA_ALL_IRQS);
>  }
>
> +static void meason_mx_mmc_free_host(void *data)
> +{
> +       mmc_free_host(data);
> +}
> +
>  static int meson_mx_sdhc_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> @@ -788,8 +793,7 @@ static int meson_mx_sdhc_probe(struct platform_device *pdev)
>         if (!mmc)
>                 return -ENOMEM;
>
> -       ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
> -                                      mmc);
> +       ret = devm_add_action_or_reset(dev, meason_mx_mmc_free_host, mmc);
>         if (ret) {
>                 dev_err(dev, "Failed to register mmc_free_host action\n");
>                 return ret;
>

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

end of thread, other threads:[~2023-05-24 13:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-10 12:39 [PATCH] mmc: meson-mx-sdhc: Avoid cast to incompatible function type Simon Horman
2023-05-10 12:54 ` Neil Armstrong
2023-05-10 20:20 ` Martin Blumenstingl
2023-05-24 13:10 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).