PCI: microchip: Remove cast between incompatible function type
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Thu, 29 Jun 2023 16:59:56 +0000 (16:59 +0000)
committerKrzysztof Wilczyński <kwilczynski@kernel.org>
Thu, 13 Jul 2023 18:20:31 +0000 (18:20 +0000)
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/pcie-microchip-host.c:866:32: warning: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
          devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No functional changes are intended.

Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Link: https://lore.kernel.org/linux-pci/20230629165956.237832-3-kwilczynski@kernel.org
Link: https://lore.kernel.org/linux-pci/20230511-pci-microchip-clk-cast-v1-1-7674f4d4e218@kernel.org
Link: https://lore.kernel.org/linux-pci/20230111125323.1911373-3-daire.mcnamara@microchip.com
Co-developed-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Co-developed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Simon Horman <horms@kernel.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
drivers/pci/controller/pcie-microchip-host.c

index 5e710e485464611f9d7c7f94784b925b67ea9ad9..d30286f815e70f6351ecd0b54aeb3520a4e8d3f6 100644 (file)
@@ -848,6 +848,13 @@ static const struct irq_domain_ops event_domain_ops = {
        .map = mc_pcie_event_map,
 };
 
+static inline void mc_pcie_deinit_clk(void *data)
+{
+       struct clk *clk = data;
+
+       clk_disable_unprepare(clk);
+}
+
 static inline struct clk *mc_pcie_init_clk(struct device *dev, const char *id)
 {
        struct clk *clk;
@@ -863,8 +870,7 @@ static inline struct clk *mc_pcie_init_clk(struct device *dev, const char *id)
        if (ret)
                return ERR_PTR(ret);
 
-       devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
-                                clk);
+       devm_add_action_or_reset(dev, mc_pcie_deinit_clk, clk);
 
        return clk;
 }