Message ID | 20230629165956.237832-2-kwilczynski@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Krzysztof Wilczyński |
Headers | show |
Series | [1/3] PCI: meson: Remove cast between incompatible function type | expand |
> -----Original Message----- > From: Krzysztof Wilczyński <kwilczynski@kernel.org> > Sent: Thursday, June 29, 2023 10:30 PM > To: Bjorn Helgaas <bhelgaas@google.com> > Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>; Rob Herring > <robh@kernel.org>; Yue Wang <yue.wang@Amlogic.com>; Neil Armstrong > <neil.armstrong@linaro.org>; Kevin Hilman <khilman@baylibre.com>; Jerome > Brunet <jbrunet@baylibre.com>; Martin Blumenstingl > <martin.blumenstingl@googlemail.com>; Thokala, Srikanth > <srikanth.thokala@intel.com>; Daire McNamara > <daire.mcnamara@microchip.com>; Conor Dooley <conor.dooley@microchip.com>; > linux-pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux- > amlogic@lists.infradead.org; linux-riscv@lists.infradead.org > 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") > Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> > --- > drivers/pci/controller/dwc/pcie-keembay.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-keembay.c > b/drivers/pci/controller/dwc/pcie-keembay.c > index f90f36bac018..289bff99d762 100644 > --- a/drivers/pci/controller/dwc/pcie-keembay.c > +++ b/drivers/pci/controller/dwc/pcie-keembay.c > @@ -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); Acked-by: Srikanth Thokala <srikanth.thokala@intel.com> Thank you. Srikanth > if (ret) > return ERR_PTR(ret); > > -- > 2.41.0
diff --git a/drivers/pci/controller/dwc/pcie-keembay.c b/drivers/pci/controller/dwc/pcie-keembay.c index f90f36bac018..289bff99d762 100644 --- a/drivers/pci/controller/dwc/pcie-keembay.c +++ b/drivers/pci/controller/dwc/pcie-keembay.c @@ -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);
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") Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> --- drivers/pci/controller/dwc/pcie-keembay.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)