linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code
@ 2024-08-26 12:14 Jinjie Ruan
  2024-08-26 12:14 ` [PATCH -next 1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host() Jinjie Ruan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jinjie Ruan @ 2024-08-26 12:14 UTC (permalink / raw)
  To: broonie, michal.simek, linux-spi, linux-arm-kernel, linux-kernel
  Cc: ruanjinjie

Use devm_spi_alloc_host() and dev_err_probe() to simplfy code.

Jinjie Ruan (2):
  spi: zynqmp-gqspi: Use devm_spi_alloc_host()
  spi: zynqmp-gqspi: Simplify with dev_err_probe()

 drivers/spi/spi-zynqmp-gqspi.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

-- 
2.34.1



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

* [PATCH -next 1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host()
  2024-08-26 12:14 [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Jinjie Ruan
@ 2024-08-26 12:14 ` Jinjie Ruan
  2024-08-26 12:14 ` [PATCH -next 2/2] spi: zynqmp-gqspi: Simplify with dev_err_probe() Jinjie Ruan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jinjie Ruan @ 2024-08-26 12:14 UTC (permalink / raw)
  To: broonie, michal.simek, linux-spi, linux-arm-kernel, linux-kernel
  Cc: ruanjinjie

Use devm_spi_alloc_host() so that there's no need to call
spi_controller_put() in the error path.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/spi/spi-zynqmp-gqspi.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 558c466135a5..597fcc7fce82 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -1242,7 +1242,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
 	u32 num_cs;
 	const struct qspi_platform_data *p_data;
 
-	ctlr = spi_alloc_host(&pdev->dev, sizeof(*xqspi));
+	ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*xqspi));
 	if (!ctlr)
 		return -ENOMEM;
 
@@ -1256,29 +1256,25 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
 		xqspi->has_tapdelay = true;
 
 	xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(xqspi->regs)) {
-		ret = PTR_ERR(xqspi->regs);
-		goto remove_ctlr;
-	}
+	if (IS_ERR(xqspi->regs))
+		return PTR_ERR(xqspi->regs);
 
 	xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
 	if (IS_ERR(xqspi->pclk)) {
 		dev_err(dev, "pclk clock not found.\n");
-		ret = PTR_ERR(xqspi->pclk);
-		goto remove_ctlr;
+		return PTR_ERR(xqspi->pclk);
 	}
 
 	xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
 	if (IS_ERR(xqspi->refclk)) {
 		dev_err(dev, "ref_clk clock not found.\n");
-		ret = PTR_ERR(xqspi->refclk);
-		goto remove_ctlr;
+		return PTR_ERR(xqspi->refclk);
 	}
 
 	ret = clk_prepare_enable(xqspi->pclk);
 	if (ret) {
 		dev_err(dev, "Unable to enable APB clock.\n");
-		goto remove_ctlr;
+		return ret;
 	}
 
 	ret = clk_prepare_enable(xqspi->refclk);
@@ -1364,8 +1360,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
 	clk_disable_unprepare(xqspi->refclk);
 clk_dis_pclk:
 	clk_disable_unprepare(xqspi->pclk);
-remove_ctlr:
-	spi_controller_put(ctlr);
 
 	return ret;
 }
-- 
2.34.1



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

* [PATCH -next 2/2] spi: zynqmp-gqspi: Simplify with dev_err_probe()
  2024-08-26 12:14 [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Jinjie Ruan
  2024-08-26 12:14 ` [PATCH -next 1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host() Jinjie Ruan
@ 2024-08-26 12:14 ` Jinjie Ruan
  2024-08-30 13:42 ` [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Michal Simek
  2024-08-30 18:44 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Jinjie Ruan @ 2024-08-26 12:14 UTC (permalink / raw)
  To: broonie, michal.simek, linux-spi, linux-arm-kernel, linux-kernel
  Cc: ruanjinjie

Use the dev_err_probe() helper to simplify error handling during probe.
This also handle scenario, when EDEFER is returned and useless error
is printed.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/spi/spi-zynqmp-gqspi.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 597fcc7fce82..fcd0ca996684 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -1260,22 +1260,18 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
 		return PTR_ERR(xqspi->regs);
 
 	xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
-	if (IS_ERR(xqspi->pclk)) {
-		dev_err(dev, "pclk clock not found.\n");
-		return PTR_ERR(xqspi->pclk);
-	}
+	if (IS_ERR(xqspi->pclk))
+		return dev_err_probe(dev, PTR_ERR(xqspi->pclk),
+				     "pclk clock not found.\n");
 
 	xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
-	if (IS_ERR(xqspi->refclk)) {
-		dev_err(dev, "ref_clk clock not found.\n");
-		return PTR_ERR(xqspi->refclk);
-	}
+	if (IS_ERR(xqspi->refclk))
+		return dev_err_probe(dev, PTR_ERR(xqspi->refclk),
+				     "ref_clk clock not found.\n");
 
 	ret = clk_prepare_enable(xqspi->pclk);
-	if (ret) {
-		dev_err(dev, "Unable to enable APB clock.\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Unable to enable APB clock.\n");
 
 	ret = clk_prepare_enable(xqspi->refclk);
 	if (ret) {
-- 
2.34.1



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

* Re: [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code
  2024-08-26 12:14 [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Jinjie Ruan
  2024-08-26 12:14 ` [PATCH -next 1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host() Jinjie Ruan
  2024-08-26 12:14 ` [PATCH -next 2/2] spi: zynqmp-gqspi: Simplify with dev_err_probe() Jinjie Ruan
@ 2024-08-30 13:42 ` Michal Simek
  2024-08-30 18:44 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2024-08-30 13:42 UTC (permalink / raw)
  To: Jinjie Ruan, broonie, linux-spi, linux-arm-kernel, linux-kernel



On 8/26/24 14:14, Jinjie Ruan wrote:
> Use devm_spi_alloc_host() and dev_err_probe() to simplfy code.
> 
> Jinjie Ruan (2):
>    spi: zynqmp-gqspi: Use devm_spi_alloc_host()
>    spi: zynqmp-gqspi: Simplify with dev_err_probe()
> 
>   drivers/spi/spi-zynqmp-gqspi.c | 32 +++++++++++---------------------
>   1 file changed, 11 insertions(+), 21 deletions(-)
> 

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal


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

* Re: [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code
  2024-08-26 12:14 [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Jinjie Ruan
                   ` (2 preceding siblings ...)
  2024-08-30 13:42 ` [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Michal Simek
@ 2024-08-30 18:44 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2024-08-30 18:44 UTC (permalink / raw)
  To: michal.simek, linux-spi, linux-arm-kernel, linux-kernel,
	Jinjie Ruan

On Mon, 26 Aug 2024 20:14:19 +0800, Jinjie Ruan wrote:
> Use devm_spi_alloc_host() and dev_err_probe() to simplfy code.
> 
> Jinjie Ruan (2):
>   spi: zynqmp-gqspi: Use devm_spi_alloc_host()
>   spi: zynqmp-gqspi: Simplify with dev_err_probe()
> 
> drivers/spi/spi-zynqmp-gqspi.c | 32 +++++++++++---------------------
>  1 file changed, 11 insertions(+), 21 deletions(-)
> 
> [...]

Applied to

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

Thanks!

[1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host()
      commit: 64640f6c972e80f52196416a8d4dc3c0ffcbc82d
[2/2] spi: zynqmp-gqspi: Simplify with dev_err_probe()
      commit: d814fd0f046c2a6b1a919e1a529550bdfe9f9f9b

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

end of thread, other threads:[~2024-08-30 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 12:14 [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Jinjie Ruan
2024-08-26 12:14 ` [PATCH -next 1/2] spi: zynqmp-gqspi: Use devm_spi_alloc_host() Jinjie Ruan
2024-08-26 12:14 ` [PATCH -next 2/2] spi: zynqmp-gqspi: Simplify with dev_err_probe() Jinjie Ruan
2024-08-30 13:42 ` [PATCH -next 0/2] Use devm_spi_alloc_host() to simplfy code Michal Simek
2024-08-30 18:44 ` 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).