Skip to contentSkip to conversation

PCI: meson: Remove cast between incompatible function type

PATCH Applied Krzysztof Wilczyński 4 participants 8 messages Jun 29, 2023 – Jul 4, 2023

Subsystems (6)
lore
Share & tools
lore

Krzysztof Wilczyński

author maintainer
#0 lore raw

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

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")
---
 drivers/pci/controller/dwc/pci-meson.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +8 -3
index c1527693bed9..34990a6363d0 100644
@@ -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;
 }
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 2/3 PCI: keembay: Remove cast between incompatible function type

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/pcie-keembay.c:172:12: 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 0c87f90b4c13 ("PCI: keembay: Add support for Intel Keem Bay")
---
 drivers/pci/controller/dwc/pcie-keembay.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-keembay.c +8 -3
index f90f36bac018..289bff99d762 100644
@@ -148,6 +148,13 @@ static const struct dw_pcie_ops keembay_pcie_ops = {
 	.stop_link	= keembay_pcie_stop_link,
 };
 
+static inline void keembay_pcie_disable_clock(void *data)
+{
+	struct clk *clk = data;
+
+	clk_disable_unprepare(clk);
+}
+
 static inline struct clk *keembay_pcie_probe_clock(struct device *dev,
 						   const char *id, u64 rate)
 {
@@ -168,9 +175,7 @@ static inline struct clk *keembay_pcie_probe_clock(struct device *dev,
 	if (ret)
 		return ERR_PTR(ret);
 
-	ret = devm_add_action_or_reset(dev,
-				       (void(*)(void *))clk_disable_unprepare,
-				       clk);
+	ret = devm_add_action_or_reset(dev, keembay_pcie_disable_clock, clk);
 	if (ret)
 		return ERR_PTR(ret);
 
Signature · 1 line
2.41.0
maintainer Acked-by on v1 2/3
#2 lore raw

RE: [PATCH 2/3] PCI: keembay: Remove cast between incompatible function type

Quoted 61 lines

-----Original Message-----
From: Krzysztof Wilczyński <[email protected]>
Sent: Thursday, June 29, 2023 10:30 PM
To: Bjorn Helgaas <[email protected]>
Cc: Lorenzo Pieralisi <[email protected]>; Rob Herring <[email protected]>; Yue Wang <[email protected]>; Neil Armstrong <[email protected]>; Kevin Hilman <[email protected]>; Jerome Brunet <[email protected]>; Martin Blumenstingl <[email protected]>; Thokala, Srikanth <[email protected]>; Daire McNamara <[email protected]>; Conor Dooley <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH 2/3] PCI: keembay: Remove cast between incompatible function type

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/pcie-keembay.c:172:12: 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 0c87f90b4c13 ("PCI: keembay: Add support for Intel Keem Bay")
---
 drivers/pci/controller/dwc/pcie-keembay.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-keembay.c +7 -0
index f90f36bac018..289bff99d762 100644
@@ -148,6 +148,13 @@ static const struct dw_pcie_ops keembay_pcie_ops = {
 	.stop_link	= keembay_pcie_stop_link,
 };
 
+static inline void keembay_pcie_disable_clock(void *data)
+{
+	struct clk *clk = data;
+
+	clk_disable_unprepare(clk);
+}
+
 static inline struct clk *keembay_pcie_probe_clock(struct device *dev,
 						   const char *id, u64 rate)
 {

drivers/pci/controller/dwc/pcie-keembay.c static inline struct clk · line 180

Quoted 9 lines
drivers/pci/controller/dwc/pcie-keembay.c +1 -3
@@ -168,9 +175,7 @@ static inline struct clk
 *keembay_pcie_probe_clock(struct device *dev,
 	if (ret)
 		return ERR_PTR(ret);
 
-	ret = devm_add_action_or_reset(dev,
-				       (void(*)(void *))clk_disable_unprepare,
-				       clk);
+	ret = devm_add_action_or_reset(dev, keembay_pcie_disable_clock,
 clk);

Thank you.

Srikanth

Quoted 5 lines
drivers/pci/controller/dwc/pcie-keembay.c +0 -0
 	if (ret)

return ERR_PTR(ret);

--
2.41.0

author maintainer
#3 lore raw

PATCH 3/3 PCI: microchip: Remove cast between incompatible function type

In reply to Krzysztof Wilczyński

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")
---
 drivers/pci/controller/pcie-microchip-host.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-microchip-host.c +8 -2
index 5e710e485464..d30286f815e7 100644
@@ -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;
 }
Signature · 1 line
2.41.0
Acked-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] PCI: microchip: Remove cast between incompatible function type

Quoted 15 lines · Krzysztof Wilczyński

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.

Quoted 6 lines
Fixes 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")

This looks to be the same content wise as the patch I previously acked & effectively the same as the one I previously reviewed - you could have picked up either of those tags from the other submissions tbh.

Cheers,
Conor.

author maintainer
#5 lore raw

Re: [PATCH 3/3] PCI: microchip: Remove cast between incompatible function type

Hello,

[...]

Quoted 10 lines
Quoted 6 lines
Fixes 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")

This looks to be the same content wise as the patch I previously acked & effectively the same as the one I previously reviewed - you could have picked up either of those tags from the other submissions tbh.

I had thought about it but decided against it, as I wasn't sure if that would be OK, given a new series and new author, etc., even though the code is almost identical. I have seen you offered Reviewed-by and Acked-by once before, and I appreciate that.

Quoted 1 line

Thank you!

Krzysztof

maintainer Reviewed-by on v1 1/3
#6 lore raw
In reply to Krzysztof Wilczyński
Quoted 21 lines · Krzysztof Wilczyński

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")
---
  drivers/pci/controller/dwc/pci-meson.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

<snip>

author maintainer Applied
#7 lore raw
In reply to Krzysztof Wilczyński

Hello,

Quoted 8 lines

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.

Quoted 6 lines

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