diff mbox series

[1/3] PCI: meson: Remove cast between incompatible function type

Message ID 20230629165956.237832-1-kwilczynski@kernel.org (mailing list archive)
State Handled Elsewhere
Headers show
Series [1/3] PCI: meson: Remove cast between incompatible function type | expand

Checks

Context Check Description
conchuod/cover_letter warning Series does not have a cover letter
conchuod/tree_selection success Guessed tree name to be fixes at HEAD b104dbedbe61
conchuod/fixes_present success Fixes tag present in non-next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 6 and now 6
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 9 this patch: 8
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 20 this patch: 20
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success Fixes tag looks correct
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Krzysztof Wilczyński June 29, 2023, 4:59 p.m. UTC
Rather than casting void(*)(struct clk *) to void (*)(void *), that
forces conversion to an incompatible function type, replace the cast
with a small local stub function with a signature that matches what
the devm_add_action_or_reset() function expects.

The sub function takes a void *, then passes it directly to
clk_disable_unprepare(), which handles the more specific type.

Reported by clang when building with warnings enabled:

  drivers/pci/controller/dwc/pci-meson.c:191:6: warning: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
                                   (void (*) (void *))clk_disable_unprepare,
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No functional changes are intended.

Fixes: 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver")
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
 drivers/pci/controller/dwc/pci-meson.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Neil Armstrong June 30, 2023, 7:49 a.m. UTC | #1
On 29/06/2023 18:59, Krzysztof Wilczyński wrote:
> Rather than casting void(*)(struct clk *) to void (*)(void *), that
> forces conversion to an incompatible function type, replace the cast
> with a small local stub function with a signature that matches what
> the devm_add_action_or_reset() function expects.
> 
> The sub function takes a void *, then passes it directly to
> clk_disable_unprepare(), which handles the more specific type.
> 
> Reported by clang when building with warnings enabled:
> 
>    drivers/pci/controller/dwc/pci-meson.c:191:6: warning: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
>                                     (void (*) (void *))clk_disable_unprepare,
>                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> No functional changes are intended.
> 
> Fixes: 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver")
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
> ---
>   drivers/pci/controller/dwc/pci-meson.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 

<snip>


Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Krzysztof Wilczyński July 4, 2023, 4:16 p.m. UTC | #2
Hello,

> Rather than casting void(*)(struct clk *) to void (*)(void *), that
> forces conversion to an incompatible function type, replace the cast
> with a small local stub function with a signature that matches what
> the devm_add_action_or_reset() function expects.
> 
> The sub function takes a void *, then passes it directly to
> clk_disable_unprepare(), which handles the more specific type.
> 
> Reported by clang when building with warnings enabled:
> 
>   drivers/pci/controller/dwc/pci-meson.c:191:6: warning: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
>                                    (void (*) (void *))clk_disable_unprepare,
>                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> No functional changes are intended.

Applied to controller/remove-void-cast, thank you everyone!

[01/03] PCI: meson: Remove cast between incompatible function type
	https://git.kernel.org/pci/pci/c/60fce60ab7b6
[02/03] PCI: keembay: Remove cast between incompatible function type
	https://git.kernel.org/pci/pci/c/43a2eef7cbba
[03/03] PCI: microchip: Remove cast between incompatible function type
	https://git.kernel.org/pci/pci/c/9e4811ce626f

	Krzysztof
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index c1527693bed9..34990a6363d0 100644
--- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -163,6 +163,13 @@  static int meson_pcie_reset(struct meson_pcie *mp)
 	return 0;
 }
 
+static inline void meson_pcie_disable_clock(void *data)
+{
+	struct clk *clk = data;
+
+	clk_disable_unprepare(clk);
+}
+
 static inline struct clk *meson_pcie_probe_clock(struct device *dev,
 						 const char *id, u64 rate)
 {
@@ -187,9 +194,7 @@  static inline struct clk *meson_pcie_probe_clock(struct device *dev,
 		return ERR_PTR(ret);
 	}
 
-	devm_add_action_or_reset(dev,
-				 (void (*) (void *))clk_disable_unprepare,
-				 clk);
+	devm_add_action_or_reset(dev, meson_pcie_disable_clock, clk);
 
 	return clk;
 }