From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: broonie@kernel.org
Cc: matthias.bgg@gmail.com, linux-spi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
nfraprado@collabora.com, kernel@collabora.com,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: [PATCH v2 1/8] spi: mt65xx: Simplify probe function with devm_spi_alloc_master
Date: Thu, 7 Apr 2022 13:44:21 +0200 [thread overview]
Message-ID: <20220407114428.167091-2-angelogioacchino.delregno@collabora.com> (raw)
In-Reply-To: <20220407114428.167091-1-angelogioacchino.delregno@collabora.com>
Switch to the devm variant of spi_alloc_master() to save some gotos.
This patch is a cleanup that brings no functional changes.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/spi/spi-mt65xx.c | 43 +++++++++++++++-------------------------
1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 99ce570a88a7..4c84b67ac85c 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -1087,7 +1087,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
const struct of_device_id *of_id;
int i, irq, ret, addr_bits;
- master = spi_alloc_master(&pdev->dev, sizeof(*mdata));
+ master = devm_spi_alloc_master(&pdev->dev, sizeof(*mdata));
if (!master) {
dev_err(&pdev->dev, "failed to alloc spi master\n");
return -ENOMEM;
@@ -1108,8 +1108,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
of_id = of_match_node(mtk_spi_of_match, pdev->dev.of_node);
if (!of_id) {
dev_err(&pdev->dev, "failed to probe of_node\n");
- ret = -EINVAL;
- goto err_put_master;
+ return -EINVAL;
}
mdata = spi_master_get_devdata(master);
@@ -1136,16 +1135,13 @@ static int mtk_spi_probe(struct platform_device *pdev)
if (mdata->pad_num < 0) {
dev_err(&pdev->dev,
"No 'mediatek,pad-select' property\n");
- ret = -EINVAL;
- goto err_put_master;
+ return -EINVAL;
}
mdata->pad_sel = devm_kmalloc_array(&pdev->dev, mdata->pad_num,
sizeof(u32), GFP_KERNEL);
- if (!mdata->pad_sel) {
- ret = -ENOMEM;
- goto err_put_master;
- }
+ if (!mdata->pad_sel)
+ return -ENOMEM;
for (i = 0; i < mdata->pad_num; i++) {
of_property_read_u32_index(pdev->dev.of_node,
@@ -1154,24 +1150,19 @@ static int mtk_spi_probe(struct platform_device *pdev)
if (mdata->pad_sel[i] > MT8173_SPI_MAX_PAD_SEL) {
dev_err(&pdev->dev, "wrong pad-sel[%d]: %u\n",
i, mdata->pad_sel[i]);
- ret = -EINVAL;
- goto err_put_master;
+ return -EINVAL;
}
}
}
platform_set_drvdata(pdev, master);
mdata->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(mdata->base)) {
- ret = PTR_ERR(mdata->base);
- goto err_put_master;
- }
+ if (IS_ERR(mdata->base))
+ return PTR_ERR(mdata->base);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto err_put_master;
- }
+ if (irq < 0)
+ return irq;
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
@@ -1180,41 +1171,41 @@ static int mtk_spi_probe(struct platform_device *pdev)
IRQF_TRIGGER_NONE, dev_name(&pdev->dev), master);
if (ret) {
dev_err(&pdev->dev, "failed to register irq (%d)\n", ret);
- goto err_put_master;
+ return ret;
}
mdata->parent_clk = devm_clk_get(&pdev->dev, "parent-clk");
if (IS_ERR(mdata->parent_clk)) {
ret = PTR_ERR(mdata->parent_clk);
dev_err(&pdev->dev, "failed to get parent-clk: %d\n", ret);
- goto err_put_master;
+ return ret;
}
mdata->sel_clk = devm_clk_get(&pdev->dev, "sel-clk");
if (IS_ERR(mdata->sel_clk)) {
ret = PTR_ERR(mdata->sel_clk);
dev_err(&pdev->dev, "failed to get sel-clk: %d\n", ret);
- goto err_put_master;
+ return ret;
}
mdata->spi_clk = devm_clk_get(&pdev->dev, "spi-clk");
if (IS_ERR(mdata->spi_clk)) {
ret = PTR_ERR(mdata->spi_clk);
dev_err(&pdev->dev, "failed to get spi-clk: %d\n", ret);
- goto err_put_master;
+ return ret;
}
mdata->spi_hclk = devm_clk_get_optional(&pdev->dev, "hclk");
if (IS_ERR(mdata->spi_hclk)) {
ret = PTR_ERR(mdata->spi_hclk);
dev_err(&pdev->dev, "failed to get hclk: %d\n", ret);
- goto err_put_master;
+ return ret;
}
ret = clk_prepare_enable(mdata->spi_hclk);
if (ret < 0) {
dev_err(&pdev->dev, "failed to enable hclk (%d)\n", ret);
- goto err_put_master;
+ return ret;
}
ret = clk_prepare_enable(mdata->spi_clk);
@@ -1281,8 +1272,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
clk_disable_unprepare(mdata->spi_clk);
err_disable_spi_hclk:
clk_disable_unprepare(mdata->spi_hclk);
-err_put_master:
- spi_master_put(master);
return ret;
}
--
2.35.1
next prev parent reply other threads:[~2022-04-07 11:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 11:44 [PATCH v2 0/8] MediaTek SPI controller cleanups and documentation AngeloGioacchino Del Regno
2022-04-07 11:44 ` AngeloGioacchino Del Regno [this message]
2022-04-07 11:44 ` [PATCH v2 2/8] spi: mt65xx: Switch to device_get_match_data() AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 3/8] spi: mt65xx: Add and use pointer to struct device in mtk_spi_probe() AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 4/8] spi: mt65xx: Move clock parent setting to remove clock disable gotos AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 5/8] spi: mt65xx: Move pm_runtime_enable() call to remove all gotos AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 6/8] spi: mt65xx: Simplify probe function with dev_err_probe() AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 7/8] spi: mt65xx: Add kerneldoc for driver structures AngeloGioacchino Del Regno
2022-04-07 11:44 ` [PATCH v2 8/8] spi: mt65xx: Fix definitions indentation AngeloGioacchino Del Regno
2022-04-20 21:41 ` [PATCH v2 0/8] MediaTek SPI controller cleanups and documentation 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=20220407114428.167091-2-angelogioacchino.delregno@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nfraprado@collabora.com \
/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;
as well as URLs for NNTP newsgroup(s).