mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable
@ 2026-07-05 17:27 Krzysztof Kozlowski
  2026-07-05 17:27 ` [PATCH 2/3] spi: atmel-quadspi: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-05 17:27 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	linux-spi, linux-arm-kernel, linux-kernel
  Cc: Krzysztof Kozlowski

Instead of multiple '&pdev->dev' dereferences, just use a local 'dev'
variable which makes multiple function calls shorter thus easier to
follow.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/spi/atmel-quadspi.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index aaf7f4c46b22..8d9c77f5de43 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -1347,20 +1347,21 @@ static const struct atmel_qspi_ops atmel_qspi_sama7g5_ops = {
 
 static int atmel_qspi_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct spi_controller *ctrl;
 	struct atmel_qspi *aq;
 	struct resource *res;
 	int irq, err = 0;
 
-	ctrl = devm_spi_alloc_host(&pdev->dev, sizeof(*aq));
+	ctrl = devm_spi_alloc_host(dev, sizeof(*aq));
 	if (!ctrl)
 		return -ENOMEM;
 
 	aq = spi_controller_get_devdata(ctrl);
 
-	aq->caps = of_device_get_match_data(&pdev->dev);
+	aq->caps = of_device_get_match_data(dev);
 	if (!aq->caps) {
-		dev_err(&pdev->dev, "Could not retrieve QSPI caps\n");
+		dev_err(dev, "Could not retrieve QSPI caps\n");
 		return -EINVAL;
 	}
 
@@ -1387,31 +1388,31 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 	/* Map the registers */
 	aq->regs = devm_platform_ioremap_resource_byname(pdev, "qspi_base");
 	if (IS_ERR(aq->regs))
-		return dev_err_probe(&pdev->dev, PTR_ERR(aq->regs),
+		return dev_err_probe(dev, PTR_ERR(aq->regs),
 				     "missing registers\n");
 
 	/* Map the AHB memory */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mmap");
-	aq->mem = devm_ioremap_resource(&pdev->dev, res);
+	aq->mem = devm_ioremap_resource(dev, res);
 	if (IS_ERR(aq->mem))
-		return dev_err_probe(&pdev->dev, PTR_ERR(aq->mem),
+		return dev_err_probe(dev, PTR_ERR(aq->mem),
 				     "missing AHB memory\n");
 
 	aq->mmap_size = resource_size(res);
 	aq->mmap_phys_base = (dma_addr_t)res->start;
 
 	/* Get the peripheral clock */
-	aq->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
+	aq->pclk = devm_clk_get_enabled(dev, "pclk");
 	if (IS_ERR(aq->pclk))
-		aq->pclk = devm_clk_get_enabled(&pdev->dev, NULL);
+		aq->pclk = devm_clk_get_enabled(dev, NULL);
 
 	if (IS_ERR(aq->pclk))
-		return dev_err_probe(&pdev->dev, PTR_ERR(aq->pclk),
+		return dev_err_probe(dev, PTR_ERR(aq->pclk),
 				     "missing peripheral clock\n");
 
 	if (aq->caps->has_qspick) {
 		/* Get the QSPI system clock */
-		aq->qspick = devm_clk_get_enabled(&pdev->dev, "qspick");
+		aq->qspick = devm_clk_get_enabled(dev, "qspick");
 		if (IS_ERR(aq->qspick)) {
 			dev_err(&pdev->dev, "missing system clock\n");
 			err = PTR_ERR(aq->qspick);
@@ -1420,7 +1421,7 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 
 	} else if (aq->caps->has_gclk) {
 		/* Get the QSPI generic clock */
-		aq->gclk = devm_clk_get(&pdev->dev, "gclk");
+		aq->gclk = devm_clk_get(dev, "gclk");
 		if (IS_ERR(aq->gclk)) {
 			dev_err(&pdev->dev, "missing Generic clock\n");
 			err = PTR_ERR(aq->gclk);
@@ -1439,15 +1440,15 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt,
-			       0, dev_name(&pdev->dev), aq);
+	err = devm_request_irq(dev, irq, atmel_qspi_interrupt,
+			       0, dev_name(dev), aq);
 	if (err)
 		return err;
 
-	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	devm_pm_runtime_set_active_enabled(&pdev->dev);
-	devm_pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(dev, 500);
+	pm_runtime_use_autosuspend(dev);
+	devm_pm_runtime_set_active_enabled(dev);
+	devm_pm_runtime_get_noresume(dev);
 
 	err = atmel_qspi_init(aq);
 	if (err)
@@ -1457,7 +1458,7 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
-	pm_runtime_put_autosuspend(&pdev->dev);
+	pm_runtime_put_autosuspend(dev);
 
 	return 0;
 }
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] spi: atmel-quadspi: Simplify with dev_err_probe()
  2026-07-05 17:27 [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Krzysztof Kozlowski
@ 2026-07-05 17:27 ` Krzysztof Kozlowski
  2026-07-05 17:27 ` [PATCH 3/3] spi: altera: " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-05 17:27 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	linux-spi, linux-arm-kernel, linux-kernel
  Cc: Krzysztof Kozlowski

Use dev_err_probe() to make error code handling simpler and handle
deferred probe nicely (avoid spamming logs).

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/spi/atmel-quadspi.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 8d9c77f5de43..e3a4697fabce 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -1413,20 +1413,15 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 	if (aq->caps->has_qspick) {
 		/* Get the QSPI system clock */
 		aq->qspick = devm_clk_get_enabled(dev, "qspick");
-		if (IS_ERR(aq->qspick)) {
-			dev_err(&pdev->dev, "missing system clock\n");
-			err = PTR_ERR(aq->qspick);
-			return err;
-		}
-
+		if (IS_ERR(aq->qspick))
+			return dev_err_probe(dev, PTR_ERR(aq->qspick),
+					     "missing system clock\n");
 	} else if (aq->caps->has_gclk) {
 		/* Get the QSPI generic clock */
 		aq->gclk = devm_clk_get(dev, "gclk");
-		if (IS_ERR(aq->gclk)) {
-			dev_err(&pdev->dev, "missing Generic clock\n");
-			err = PTR_ERR(aq->gclk);
-			return err;
-		}
+		if (IS_ERR(aq->gclk))
+			return dev_err_probe(dev, PTR_ERR(aq->gclk),
+					     "missing Generic clock\n");
 	}
 
 	if (aq->caps->has_dma) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] spi: altera: Simplify with dev_err_probe()
  2026-07-05 17:27 [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Krzysztof Kozlowski
  2026-07-05 17:27 ` [PATCH 2/3] spi: atmel-quadspi: Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2026-07-05 17:27 ` Krzysztof Kozlowski
  2026-07-06 10:58 ` [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Alexander Dahl
  2026-07-14 11:51 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-05 17:27 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	linux-spi, linux-arm-kernel, linux-kernel
  Cc: Krzysztof Kozlowski

Use dev_err_probe() to make error code handling simpler and handle
deferred probe nicely (avoid spamming logs).

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/spi/spi-altera-platform.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-altera-platform.c b/drivers/spi/spi-altera-platform.c
index 3de7df73f216..4fe69ce9da16 100644
--- a/drivers/spi/spi-altera-platform.c
+++ b/drivers/spi/spi-altera-platform.c
@@ -77,10 +77,8 @@ static int altera_spi_probe(struct platform_device *pdev)
 		struct resource *regoff;
 
 		hw->regmap = dev_get_regmap(pdev->dev.parent, NULL);
-		if (!hw->regmap) {
-			dev_err(&pdev->dev, "get regmap failed\n");
-			return -ENODEV;
-		}
+		if (!hw->regmap)
+			return dev_err_probe(&pdev->dev, -ENODEV, "get regmap failed\n");
 
 		regoff = platform_get_resource(pdev, IORESOURCE_REG, 0);
 		if (regoff)
@@ -94,10 +92,9 @@ static int altera_spi_probe(struct platform_device *pdev)
 
 		hw->regmap = devm_regmap_init_mmio(&pdev->dev, res,
 						   &spi_altera_config);
-		if (IS_ERR(hw->regmap)) {
-			dev_err(&pdev->dev, "regmap mmio init failed\n");
-			return PTR_ERR(hw->regmap);
-		}
+		if (IS_ERR(hw->regmap))
+			return dev_err_probe(&pdev->dev, PTR_ERR(hw->regmap),
+					     "regmap mmio init failed\n");
 	}
 
 	altera_spi_init_host(host);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable
  2026-07-05 17:27 [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Krzysztof Kozlowski
  2026-07-05 17:27 ` [PATCH 2/3] spi: atmel-quadspi: Simplify with dev_err_probe() Krzysztof Kozlowski
  2026-07-05 17:27 ` [PATCH 3/3] spi: altera: " Krzysztof Kozlowski
@ 2026-07-06 10:58 ` Alexander Dahl
  2026-07-06 11:14   ` Krzysztof Kozlowski
  2026-07-14 11:51 ` Mark Brown
  3 siblings, 1 reply; 6+ messages in thread
From: Alexander Dahl @ 2026-07-06 10:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	linux-spi, linux-arm-kernel, linux-kernel

Hello Krzysztof,

I think you missed some.  At least the two outlined below, but maybe
more which are not part of the lines covered by the patch?

Am Sun, Jul 05, 2026 at 07:27:38PM +0200 schrieb Krzysztof Kozlowski:
> Instead of multiple '&pdev->dev' dereferences, just use a local 'dev'
> variable which makes multiple function calls shorter thus easier to
> follow.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> ---
>  drivers/spi/atmel-quadspi.c | 37 +++++++++++++++++++------------------
>  1 file changed, 19 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
> index aaf7f4c46b22..8d9c77f5de43 100644
> --- a/drivers/spi/atmel-quadspi.c
> +++ b/drivers/spi/atmel-quadspi.c
> @@ -1347,20 +1347,21 @@ static const struct atmel_qspi_ops atmel_qspi_sama7g5_ops = {
>  
>  static int atmel_qspi_probe(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
>  	struct spi_controller *ctrl;
>  	struct atmel_qspi *aq;
>  	struct resource *res;
>  	int irq, err = 0;
>  
> -	ctrl = devm_spi_alloc_host(&pdev->dev, sizeof(*aq));
> +	ctrl = devm_spi_alloc_host(dev, sizeof(*aq));
>  	if (!ctrl)
>  		return -ENOMEM;
>  
>  	aq = spi_controller_get_devdata(ctrl);
>  
> -	aq->caps = of_device_get_match_data(&pdev->dev);
> +	aq->caps = of_device_get_match_data(dev);
>  	if (!aq->caps) {
> -		dev_err(&pdev->dev, "Could not retrieve QSPI caps\n");
> +		dev_err(dev, "Could not retrieve QSPI caps\n");
>  		return -EINVAL;
>  	}
>  
> @@ -1387,31 +1388,31 @@ static int atmel_qspi_probe(struct platform_device *pdev)
>  	/* Map the registers */
>  	aq->regs = devm_platform_ioremap_resource_byname(pdev, "qspi_base");
>  	if (IS_ERR(aq->regs))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(aq->regs),
> +		return dev_err_probe(dev, PTR_ERR(aq->regs),
>  				     "missing registers\n");
>  
>  	/* Map the AHB memory */
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mmap");
> -	aq->mem = devm_ioremap_resource(&pdev->dev, res);
> +	aq->mem = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(aq->mem))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(aq->mem),
> +		return dev_err_probe(dev, PTR_ERR(aq->mem),
>  				     "missing AHB memory\n");
>  
>  	aq->mmap_size = resource_size(res);
>  	aq->mmap_phys_base = (dma_addr_t)res->start;
>  
>  	/* Get the peripheral clock */
> -	aq->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
> +	aq->pclk = devm_clk_get_enabled(dev, "pclk");
>  	if (IS_ERR(aq->pclk))
> -		aq->pclk = devm_clk_get_enabled(&pdev->dev, NULL);
> +		aq->pclk = devm_clk_get_enabled(dev, NULL);
>  
>  	if (IS_ERR(aq->pclk))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(aq->pclk),
> +		return dev_err_probe(dev, PTR_ERR(aq->pclk),
>  				     "missing peripheral clock\n");
>  
>  	if (aq->caps->has_qspick) {
>  		/* Get the QSPI system clock */
> -		aq->qspick = devm_clk_get_enabled(&pdev->dev, "qspick");
> +		aq->qspick = devm_clk_get_enabled(dev, "qspick");
>  		if (IS_ERR(aq->qspick)) {
>  			dev_err(&pdev->dev, "missing system clock\n");

Here.

>  			err = PTR_ERR(aq->qspick);
> @@ -1420,7 +1421,7 @@ static int atmel_qspi_probe(struct platform_device *pdev)
>  
>  	} else if (aq->caps->has_gclk) {
>  		/* Get the QSPI generic clock */
> -		aq->gclk = devm_clk_get(&pdev->dev, "gclk");
> +		aq->gclk = devm_clk_get(dev, "gclk");
>  		if (IS_ERR(aq->gclk)) {
>  			dev_err(&pdev->dev, "missing Generic clock\n");

Here.

>  			err = PTR_ERR(aq->gclk);
> @@ -1439,15 +1440,15 @@ static int atmel_qspi_probe(struct platform_device *pdev)
>  	if (irq < 0)
>  		return irq;
>  
> -	err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt,
> -			       0, dev_name(&pdev->dev), aq);
> +	err = devm_request_irq(dev, irq, atmel_qspi_interrupt,
> +			       0, dev_name(dev), aq);
>  	if (err)
>  		return err;
>  
> -	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
> -	pm_runtime_use_autosuspend(&pdev->dev);
> -	devm_pm_runtime_set_active_enabled(&pdev->dev);
> -	devm_pm_runtime_get_noresume(&pdev->dev);
> +	pm_runtime_set_autosuspend_delay(dev, 500);
> +	pm_runtime_use_autosuspend(dev);
> +	devm_pm_runtime_set_active_enabled(dev);
> +	devm_pm_runtime_get_noresume(dev);
>  
>  	err = atmel_qspi_init(aq);
>  	if (err)
> @@ -1457,7 +1458,7 @@ static int atmel_qspi_probe(struct platform_device *pdev)
>  	if (err)
>  		return err;
>  
> -	pm_runtime_put_autosuspend(&pdev->dev);
> +	pm_runtime_put_autosuspend(dev);
>  
>  	return 0;
>  }

Greets
Alex


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable
  2026-07-06 10:58 ` [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Alexander Dahl
@ 2026-07-06 11:14   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-06 11:14 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	linux-spi, linux-arm-kernel, linux-kernel

On 06/07/2026 12:58, Alexander Dahl wrote:
> Hello Krzysztof,
> 
> I think you missed some.  At least the two outlined below, but maybe
> more which are not part of the lines covered by the patch?

Next one does it, no need to change the same line twice.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable
  2026-07-05 17:27 [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2026-07-06 10:58 ` [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Alexander Dahl
@ 2026-07-14 11:51 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-07-14 11:51 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, linux-spi,
	linux-arm-kernel, linux-kernel, Krzysztof Kozlowski

On Sun, 05 Jul 2026 19:27:38 +0200, Krzysztof Kozlowski wrote:
> spi: atmel-quadspi: Simplify probe() with local 'dev' variable

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3

Thanks!

[1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable
      https://git.kernel.org/broonie/sound/c/51f761e4071f
[2/3] spi: atmel-quadspi: Simplify with dev_err_probe()
      https://git.kernel.org/broonie/sound/c/3ae07d8f3075
[3/3] spi: altera: Simplify with dev_err_probe()
      https://git.kernel.org/broonie/sound/c/3e106385e3e6

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-14 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-05 17:27 [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Krzysztof Kozlowski
2026-07-05 17:27 ` [PATCH 2/3] spi: atmel-quadspi: Simplify with dev_err_probe() Krzysztof Kozlowski
2026-07-05 17:27 ` [PATCH 3/3] spi: altera: " Krzysztof Kozlowski
2026-07-06 10:58 ` [PATCH 1/3] spi: atmel-quadspi: Simplify probe() with local 'dev' variable Alexander Dahl
2026-07-06 11:14   ` Krzysztof Kozlowski
2026-07-14 11:51 ` Mark Brown

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

all inboxes | Powered by JetHome®