Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH] spi: ppc4xx: use of_property_read_u32 for clock frequency
@ 2026-07-28 20:29 Rosen Penev
  0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-07-28 20:29 UTC (permalink / raw)
  To: linux-spi; +Cc: Mark Brown, open list

Replace of_get_property with of_property_read_u32 for the
"clock-frequency" property, which is the modern typed DT accessor
that returns an error code directly and avoids the raw const unsigned
int * pointer dance.

Also drop the dev_err_probe wrapper on devm_request_irq failure,
returning ret directly since the core already logs probe errors.

Get rid of irqnum in the private struct. It's only used in _probe. Was
used in _remove before devm to free the irq.

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/spi/spi-ppc4xx.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index 95c034cf2336..8a7d5aec12c1 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -112,7 +112,6 @@ struct ppc4xx_spi {
 	struct spi_bitbang bitbang;
 	struct completion done;
 
-	int irqnum;
 	/* need this to set the SPI clock */
 	unsigned int opb_freq;
 
@@ -339,7 +338,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 	struct device *dev = &op->dev;
 	struct device_node *opbnp;
 	int ret;
-	const unsigned int *clk;
+	unsigned int opb_freq;
 	void __iomem *regs;
 	int irqnum;
 
@@ -390,22 +389,21 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 		return -ENODEV;
 	}
 	/* Get the clock (Hz) for the OPB */
-	clk = of_get_property(opbnp, "clock-frequency", NULL);
+	ret = of_property_read_u32(opbnp, "clock-frequency", &opb_freq);
 	of_node_put(opbnp);
-	if (clk == NULL) {
+	if (ret) {
 		dev_err(dev, "OPB: no clock-frequency property set\n");
 		return -ENODEV;
 	}
-	hw->opb_freq = *clk;
-	hw->opb_freq >>= 2;
 
+	hw->opb_freq = opb_freq;
+	hw->opb_freq >>= 2;
 	hw->regs = regs;
-	hw->irqnum = irqnum;
 
-	ret = devm_request_irq(&op->dev, hw->irqnum, spi_ppc4xx_int,
+	ret = devm_request_irq(&op->dev, irqnum, spi_ppc4xx_int,
 			  0, "spi_ppc4xx_of", hw);
 	if (ret)
-		return dev_err_probe(dev, ret, "unable to allocate interrupt\n");
+		return ret;
 
 	spi_ppc4xx_enable(hw);
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-28 20:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 20:29 [PATCH] spi: ppc4xx: use of_property_read_u32 for clock frequency Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox