diff mbox series

[v1,2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg

Message ID 20230614155556.4095526-3-daire.mcnamara@microchip.com (mailing list archive)
State Superseded
Delegated to: Krzysztof Wilczyński
Headers show
Series PCI: microchip: Fixes and clean-ups | expand

Commit Message

Daire McNamara June 14, 2023, 3:55 p.m. UTC
From: Daire McNamara <daire.mcnamara@microchip.com>

The kernel test robot reported that the ugly cast from
void(*)(struct clk *) to void (*)(void *) converts to incompatible
function type.  This commit adopts the common convention of creating a
trivial stub function that takes a void * and passes it to the
underlying function that expects the more specific type.

Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 drivers/pci/controller/pcie-microchip-host.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Krzysztof Wilczyński June 24, 2023, 6:34 p.m. UTC | #1
[+CC Simon]

Hello,

> The kernel test robot reported that the ugly cast from
> void(*)(struct clk *) to void (*)(void *) converts to incompatible
> function type.  This commit adopts the common convention of creating a
> trivial stub function that takes a void * and passes it to the
> underlying function that expects the more specific type.

This is a nice change, but it seems it has been carried along a few other
series and through their different revisions.  Simon also found the problem
and addressed it independently per:

  https://lore.kernel.org/linux-pci/20230511-pci-microchip-clk-cast-v1-1-7674f4d4e218@kernel.org

However, we have a few other drivers where we could take care of this, per:

drivers/pci/controller/pcie-microchip-host.c
864-		return ERR_PTR(ret);
865-
866:	devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
867-				 clk);
868-

drivers/pci/controller/dwc/pcie-keembay.c
170-
171-	ret = devm_add_action_or_reset(dev,
172:				       (void(*)(void *))clk_disable_unprepare,
173-				       clk);
174-	if (ret)

drivers/pci/controller/dwc/pci-meson.c
189-
190-	devm_add_action_or_reset(dev,
191:				 (void (*) (void *))clk_disable_unprepare,
192-				 clk);
193-

If neither you nor Simon has objections, I can send a small series to
address these in a single take.  You could then drop this particular patch
from v2 of this series, should you send a second revision at some point.

Thoughts?

	Krzysztof
Simon Horman June 24, 2023, 7:03 p.m. UTC | #2
On Sun, Jun 25, 2023 at 03:34:28AM +0900, Krzysztof Wilczyński wrote:
> [+CC Simon]
> 
> Hello,
> 
> > The kernel test robot reported that the ugly cast from
> > void(*)(struct clk *) to void (*)(void *) converts to incompatible
> > function type.  This commit adopts the common convention of creating a
> > trivial stub function that takes a void * and passes it to the
> > underlying function that expects the more specific type.
> 
> This is a nice change, but it seems it has been carried along a few other
> series and through their different revisions.  Simon also found the problem
> and addressed it independently per:
> 
>   https://lore.kernel.org/linux-pci/20230511-pci-microchip-clk-cast-v1-1-7674f4d4e218@kernel.org
> 
> However, we have a few other drivers where we could take care of this, per:
> 
> drivers/pci/controller/pcie-microchip-host.c
> 864-		return ERR_PTR(ret);
> 865-
> 866:	devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
> 867-				 clk);
> 868-
> 
> drivers/pci/controller/dwc/pcie-keembay.c
> 170-
> 171-	ret = devm_add_action_or_reset(dev,
> 172:				       (void(*)(void *))clk_disable_unprepare,
> 173-				       clk);
> 174-	if (ret)
> 
> drivers/pci/controller/dwc/pci-meson.c
> 189-
> 190-	devm_add_action_or_reset(dev,
> 191:				 (void (*) (void *))clk_disable_unprepare,
> 192-				 clk);
> 193-
> 
> If neither you nor Simon has objections, I can send a small series to
> address these in a single take.  You could then drop this particular patch
> from v2 of this series, should you send a second revision at some point.

Hi Krzysztof,

Sure, that is fine my me.

My 2c worth, is that it would be nice to have a common
helper for these cases. But I don't feel strongly about it.
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index dd5245904c87..73046bad1521 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -848,6 +848,13 @@  static const struct irq_domain_ops event_domain_ops = {
 	.map = mc_pcie_event_map,
 };
 
+static inline void mc_pcie_chip_off_action(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_chip_off_action, clk);
 
 	return clk;
 }