Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: meson-mx-sdhc: Avoid cast to incompatible function type

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: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20230510-mmc-sdhci-msm-function-cast-v1-1-5ae634b24fbd@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Simon Horman and committed by
Ulf Hansson
6151bc77 78ce88e7

+6 -2
+6 -2
drivers/mmc/host/meson-mx-sdhc-mmc.c
··· 776 776 regmap_write(host->regmap, MESON_SDHC_ISTA, MESON_SDHC_ISTA_ALL_IRQS); 777 777 } 778 778 779 + static void meason_mx_mmc_free_host(void *data) 780 + { 781 + mmc_free_host(data); 782 + } 783 + 779 784 static int meson_mx_sdhc_probe(struct platform_device *pdev) 780 785 { 781 786 struct device *dev = &pdev->dev; ··· 793 788 if (!mmc) 794 789 return -ENOMEM; 795 790 796 - ret = devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host, 797 - mmc); 791 + ret = devm_add_action_or_reset(dev, meason_mx_mmc_free_host, mmc); 798 792 if (ret) { 799 793 dev_err(dev, "Failed to register mmc_free_host action\n"); 800 794 return ret;