linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: s3c64xx: Cleanups
@ 2023-06-06  1:20 Andi Shyti
  2023-06-06  1:20 ` [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function Andi Shyti
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andi Shyti @ 2023-06-06  1:20 UTC (permalink / raw)
  To: Mark Brown
  Cc: Krzysztof Kozlowski, Alim Akhtar, linux-spi, linux-samsung-soc,
	Andi Shyti

Hi,

two small cleanups in the probe function. The first puts in use
the managed spi master allocation while the second implements the
dev_err_probe() function.

Thanks,
Andi

Andi Shyti (2):
  spi: s3c64xx: Use the managed spi master allocation function
  spi: s3c64xx: Use dev_err_probe()

 drivers/spi/spi-s3c64xx.c | 81 +++++++++++++++------------------------
 1 file changed, 30 insertions(+), 51 deletions(-)

-- 
2.40.1


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

* [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function
  2023-06-06  1:20 [PATCH 0/2] spi: s3c64xx: Cleanups Andi Shyti
@ 2023-06-06  1:20 ` Andi Shyti
  2023-06-06  1:20 ` [PATCH 2/2] spi: s3c64xx: Use dev_err_probe() Andi Shyti
  2023-06-07 17:24 ` [PATCH 0/2] spi: s3c64xx: Cleanups Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Andi Shyti @ 2023-06-06  1:20 UTC (permalink / raw)
  To: Mark Brown
  Cc: Krzysztof Kozlowski, Alim Akhtar, linux-spi, linux-samsung-soc,
	Andi Shyti

Use devm_spi_alloc_master() and get rid of one goto error path

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/spi/spi-s3c64xx.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index d5ec32bda1587..787a89c046860 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1177,8 +1177,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 		return irq;
 	}
 
-	master = spi_alloc_master(&pdev->dev,
-				sizeof(struct s3c64xx_spi_driver_data));
+	master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd));
 	if (master == NULL) {
 		dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
 		return -ENOMEM;
@@ -1197,7 +1196,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
 				ret);
-			goto err_deref_master;
+			return ret;
 		}
 		sdd->port_id = ret;
 	} else {
@@ -1232,23 +1231,19 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 		master->can_dma = s3c64xx_spi_can_dma;
 
 	sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
-	if (IS_ERR(sdd->regs)) {
-		ret = PTR_ERR(sdd->regs);
-		goto err_deref_master;
-	}
+	if (IS_ERR(sdd->regs))
+		return PTR_ERR(sdd->regs);
 
 	if (sci->cfg_gpio && sci->cfg_gpio()) {
 		dev_err(&pdev->dev, "Unable to config gpio\n");
-		ret = -EBUSY;
-		goto err_deref_master;
+		return -EBUSY;
 	}
 
 	/* Setup clocks */
 	sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi");
 	if (IS_ERR(sdd->clk)) {
 		dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
-		ret = PTR_ERR(sdd->clk);
-		goto err_deref_master;
+		return PTR_ERR(sdd->clk);
 	}
 
 	sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
@@ -1256,16 +1251,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 	if (IS_ERR(sdd->src_clk)) {
 		dev_err(&pdev->dev,
 			"Unable to acquire clock '%s'\n", clk_name);
-		ret = PTR_ERR(sdd->src_clk);
-		goto err_deref_master;
+		return PTR_ERR(sdd->src_clk);
 	}
 
 	if (sdd->port_conf->clk_ioclk) {
 		sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk");
 		if (IS_ERR(sdd->ioclk)) {
 			dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n");
-			ret = PTR_ERR(sdd->ioclk);
-			goto err_deref_master;
+			return PTR_ERR(sdd->ioclk);
 		}
 	}
 
@@ -1314,9 +1307,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_set_suspended(&pdev->dev);
 
-err_deref_master:
-	spi_master_put(master);
-
 	return ret;
 }
 
-- 
2.40.1


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

* [PATCH 2/2] spi: s3c64xx: Use dev_err_probe()
  2023-06-06  1:20 [PATCH 0/2] spi: s3c64xx: Cleanups Andi Shyti
  2023-06-06  1:20 ` [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function Andi Shyti
@ 2023-06-06  1:20 ` Andi Shyti
  2023-06-07 17:24 ` [PATCH 0/2] spi: s3c64xx: Cleanups Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Andi Shyti @ 2023-06-06  1:20 UTC (permalink / raw)
  To: Mark Brown
  Cc: Krzysztof Kozlowski, Alim Akhtar, linux-spi, linux-samsung-soc,
	Andi Shyti

Simplify the code by using dev_err_probe() instead of dev_err()
and 'return'.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/spi/spi-s3c64xx.c | 65 ++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 38 deletions(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 787a89c046860..fd55697144cc2 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1160,28 +1160,23 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 			return PTR_ERR(sci);
 	}
 
-	if (!sci) {
-		dev_err(&pdev->dev, "platform_data missing!\n");
-		return -ENODEV;
-	}
+	if (!sci)
+		return dev_err_probe(&pdev->dev, -ENODEV,
+				     "Platform_data missing!\n");
 
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (mem_res == NULL) {
-		dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
-		return -ENXIO;
-	}
+	if (!mem_res)
+		return dev_err_probe(&pdev->dev, -ENXIO,
+				     "Unable to get SPI MEM resource\n");
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0) {
-		dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
-		return irq;
-	}
+	if (irq < 0)
+		return dev_err_probe(&pdev->dev, irq, "Failed to get IRQ\n");
 
 	master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd));
-	if (master == NULL) {
-		dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
-		return -ENOMEM;
-	}
+	if (!master)
+		return dev_err_probe(&pdev->dev, -ENOMEM,
+				     "Unable to allocate SPI Master\n");
 
 	platform_set_drvdata(pdev, master);
 
@@ -1193,11 +1188,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 	sdd->sfr_start = mem_res->start;
 	if (pdev->dev.of_node) {
 		ret = of_alias_get_id(pdev->dev.of_node, "spi");
-		if (ret < 0) {
-			dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
-				ret);
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(&pdev->dev, ret,
+					     "Failed to get alias id\n");
 		sdd->port_id = ret;
 	} else {
 		sdd->port_id = pdev->id;
@@ -1234,32 +1227,28 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 	if (IS_ERR(sdd->regs))
 		return PTR_ERR(sdd->regs);
 
-	if (sci->cfg_gpio && sci->cfg_gpio()) {
-		dev_err(&pdev->dev, "Unable to config gpio\n");
-		return -EBUSY;
-	}
+	if (sci->cfg_gpio && sci->cfg_gpio())
+		return dev_err_probe(&pdev->dev, -EBUSY,
+				     "Unable to config gpio\n");
 
 	/* Setup clocks */
 	sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi");
-	if (IS_ERR(sdd->clk)) {
-		dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
-		return PTR_ERR(sdd->clk);
-	}
+	if (IS_ERR(sdd->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(sdd->clk),
+				     "Unable to acquire clock 'spi'\n");
 
 	sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
 	sdd->src_clk = devm_clk_get_enabled(&pdev->dev, clk_name);
-	if (IS_ERR(sdd->src_clk)) {
-		dev_err(&pdev->dev,
-			"Unable to acquire clock '%s'\n", clk_name);
-		return PTR_ERR(sdd->src_clk);
-	}
+	if (IS_ERR(sdd->src_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(sdd->src_clk),
+				     "Unable to acquire clock '%s'\n",
+				     clk_name);
 
 	if (sdd->port_conf->clk_ioclk) {
 		sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk");
-		if (IS_ERR(sdd->ioclk)) {
-			dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n");
-			return PTR_ERR(sdd->ioclk);
-		}
+		if (IS_ERR(sdd->ioclk))
+			return dev_err_probe(&pdev->dev, PTR_ERR(sdd->ioclk),
+					     "Unable to acquire 'ioclk'\n");
 	}
 
 	pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
-- 
2.40.1


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

* Re: [PATCH 0/2] spi: s3c64xx: Cleanups
  2023-06-06  1:20 [PATCH 0/2] spi: s3c64xx: Cleanups Andi Shyti
  2023-06-06  1:20 ` [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function Andi Shyti
  2023-06-06  1:20 ` [PATCH 2/2] spi: s3c64xx: Use dev_err_probe() Andi Shyti
@ 2023-06-07 17:24 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-06-07 17:24 UTC (permalink / raw)
  To: Andi Shyti; +Cc: Krzysztof Kozlowski, Alim Akhtar, linux-spi, linux-samsung-soc

On Tue, 06 Jun 2023 03:20:49 +0200, Andi Shyti wrote:
> two small cleanups in the probe function. The first puts in use
> the managed spi master allocation while the second implements the
> dev_err_probe() function.
> 
> Thanks,
> Andi
> 
> [...]

Applied to

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

Thanks!

[1/2] spi: s3c64xx: Use the managed spi master allocation function
      commit: 76fbad410c0fed0c203c22e7e5ef8455725f3338
[2/2] spi: s3c64xx: Use dev_err_probe()
      commit: b4f273774c8b2b7c6f5e0cb9b18a234a8ca322b4

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] 4+ messages in thread

end of thread, other threads:[~2023-06-07 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06  1:20 [PATCH 0/2] spi: s3c64xx: Cleanups Andi Shyti
2023-06-06  1:20 ` [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function Andi Shyti
2023-06-06  1:20 ` [PATCH 2/2] spi: s3c64xx: Use dev_err_probe() Andi Shyti
2023-06-07 17:24 ` [PATCH 0/2] spi: s3c64xx: Cleanups Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).