[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220103101855.17350-2-angelogioacchino.delregno@collabora.com>
Date: Mon, 3 Jan 2022 11:18:54 +0100
From: AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
To: sean.wang@...nel.org
Cc: linus.walleij@...aro.org, matthias.bgg@...il.com,
linux-mediatek@...ts.infradead.org, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
kernel@...labora.com,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
Subject: [PATCH 2/3] pinctrl: mediatek: pinctrl-paris: Simplify with dev_err_probe()
Use the dev_err_probe() helper to simplify error handling during probe.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
---
drivers/pinctrl/mediatek/pinctrl-paris.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index 4c6f6d967b18..70849d393917 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -956,6 +956,7 @@ static int mtk_pctrl_build_state(struct platform_device *pdev)
int mtk_paris_pinctrl_probe(struct platform_device *pdev,
const struct mtk_pin_soc *soc)
{
+ struct device *dev = &pdev->dev;
struct pinctrl_pin_desc *pins;
struct mtk_pinctrl *hw;
int err, i;
@@ -968,11 +969,9 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
hw->soc = soc;
hw->dev = &pdev->dev;
- if (!hw->soc->nbase_names) {
- dev_err(&pdev->dev,
+ if (!hw->soc->nbase_names)
+ return dev_err_probe(dev, -EINVAL,
"SoC should be assigned at least one register base\n");
- return -EINVAL;
- }
hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
sizeof(*hw->base), GFP_KERNEL);
@@ -997,10 +996,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
spin_lock_init(&hw->lock);
err = mtk_pctrl_build_state(pdev);
- if (err) {
- dev_err(&pdev->dev, "build state failed: %d\n", err);
- return -EINVAL;
- }
+ if (err)
+ return dev_err_probe(dev, err, "build state failed\n");
/* Copy from internal struct mtk_pin_desc to register to the core */
pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
@@ -1038,10 +1035,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
/* Build gpiochip should be after pinctrl_enable is done */
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
- if (err) {
- dev_err(&pdev->dev, "Failed to add gpio_chip\n");
- return err;
- }
+ if (err)
+ return dev_err_probe(dev, err, "Failed to add gpio_chip\n");
platform_set_drvdata(pdev, hw);
--
2.33.1
Powered by blists - more mailing lists