From: Felix Gu <ustc.gu@gmail.com>
To: CL Wang <cl634@andestech.com>, Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH 2/2] spi: atcspi200: switch to devm functions
Date: Fri, 17 Apr 2026 00:27:55 +0800 [thread overview]
Message-ID: <20260417-atcspi-v1-2-854831667d63@gmail.com> (raw)
In-Reply-To: <20260417-atcspi-v1-0-854831667d63@gmail.com>
Switch to use devm_spi_alloc_host and devm_mutex_init to make code clean.
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/spi/spi-atcspi200.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/spi-atcspi200.c b/drivers/spi/spi-atcspi200.c
index c5cf1aa2d674..6d4b6aeb3f5b 100644
--- a/drivers/spi/spi-atcspi200.c
+++ b/drivers/spi/spi-atcspi200.c
@@ -550,7 +550,7 @@ static int atcspi_probe(struct platform_device *pdev)
struct resource *mem_res;
int ret;
- host = spi_alloc_host(&pdev->dev, sizeof(*spi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
if (!host)
return -ENOMEM;
@@ -559,21 +559,23 @@ static int atcspi_probe(struct platform_device *pdev)
spi->dev = &pdev->dev;
dev_set_drvdata(&pdev->dev, host);
- mutex_init(&spi->mutex_lock);
+ ret = devm_mutex_init(&pdev->dev, &spi->mutex_lock);
+ if (ret)
+ return ret;
ret = atcspi_init_resources(pdev, spi, &mem_res);
if (ret)
- goto free_controller;
+ return ret;
ret = atcspi_enable_clk(spi);
if (ret)
- goto free_controller;
+ return ret;
atcspi_init_controller(pdev, spi, host, mem_res);
ret = atcspi_setup(spi);
if (ret)
- goto free_controller;
+ return ret;
spi->use_dma = false;
if (ATCSPI_DMA_SUPPORT) {
@@ -586,18 +588,11 @@ static int atcspi_probe(struct platform_device *pdev)
}
ret = devm_spi_register_controller(&pdev->dev, host);
- if (ret) {
- dev_err_probe(spi->dev, ret,
- "Failed to register SPI controller\n");
- goto free_controller;
- }
+ if (ret)
+ return dev_err_probe(spi->dev, ret,
+ "Failed to register SPI controller\n");
return 0;
-
-free_controller:
- mutex_destroy(&spi->mutex_lock);
- spi_controller_put(host);
- return ret;
}
static int atcspi_suspend(struct device *dev)
--
2.43.0
next prev parent reply other threads:[~2026-04-16 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 16:27 [PATCH 0/2] spi: atcspi200: two cleanup Felix Gu
2026-04-16 16:27 ` [PATCH 1/2] spi: atcspi200: fix use-after-free when driver unbind Felix Gu
2026-04-16 16:27 ` Felix Gu [this message]
2026-04-26 23:33 ` [PATCH 0/2] spi: atcspi200: two cleanup Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260417-atcspi-v1-2-854831667d63@gmail.com \
--to=ustc.gu@gmail.com \
--cc=broonie@kernel.org \
--cc=cl634@andestech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®