All of lore.kernel.org
 help / color / mirror / Atom feed
From: cy_huang <u0084500@gmail.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, lee@kernel.org, matthias.bgg@gmail.com,
	yangyingliang@huawei.com, chiaen_wu@richtek.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	ChiYuan Huang <cy_huang@richtek.com>
Subject: [PATCH 2/2] regulator: mt6370: Switch to use dev_err_probe() helper
Date: Wed, 30 Nov 2022 16:37:43 +0800	[thread overview]
Message-ID: <1669797463-24887-2-git-send-email-u0084500@gmail.com> (raw)
In-Reply-To: <1669797463-24887-1-git-send-email-u0084500@gmail.com>

From: ChiYuan Huang <cy_huang@richtek.com>

Use dev_err_probe helper to simplify the probe function.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
 drivers/regulator/mt6370-regulator.c | 39 +++++++++++++-----------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/regulator/mt6370-regulator.c b/drivers/regulator/mt6370-regulator.c
index c2b589a..e090fbe 100644
--- a/drivers/regulator/mt6370-regulator.c
+++ b/drivers/regulator/mt6370-regulator.c
@@ -303,11 +303,9 @@ static int mt6370_regulator_irq_register(struct mt6370_priv *priv)
 		ret = devm_request_threaded_irq(priv->dev, irq, NULL,
 						mt6370_irqs[i].handler, 0,
 						mt6370_irqs[i].name, rdev);
-		if (ret) {
-			dev_err(priv->dev,
-				"Failed to register (%d) interrupt\n", i);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(priv->dev, ret,
+					     "Failed to register (%d) interrupt\n", i);
 	}
 
 	return 0;
@@ -329,20 +327,16 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv)
 	int i, ret;
 
 	regulator_np = of_get_child_by_name(parent->of_node, "regulators");
-	if (!regulator_np) {
-		dev_err(dev, "Could not find parent 'regulators' node\n");
-		return -ENODEV;
-	}
+	if (!regulator_np)
+		return dev_err_probe(dev, -ENODEV, "Could not find parent 'regulators' node\n");
 
 	ret = of_regulator_match(dev, regulator_np, mt6370_regulator_match,
 				 ARRAY_SIZE(mt6370_regulator_match));
 
 	of_node_put(regulator_np);
 
-	if (ret < 0) {
-		dev_err(dev, "Error parsing regulator init data: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Error parsing regulator init data\n");
 
 	for (i = 0; i < MT6370_MAX_IDX; i++) {
 		const struct regulator_desc *desc = mt6370_regulator_descs + i;
@@ -355,17 +349,14 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv)
 
 		if (cfg.of_node && desc->of_parse_cb) {
 			ret = desc->of_parse_cb(cfg.of_node, desc, &cfg);
-			if (ret) {
-				dev_err(dev, "Failed in of_parse_cb\n");
-				return ret;
-			}
+			if (ret)
+				return dev_err_probe(dev, ret, "Failed in of_parse_cb\n");
 		}
 
 		rdev = devm_regulator_register(dev, desc, &cfg);
-		if (IS_ERR(rdev)) {
-			dev_err(dev, "Failed to register (%d) regulator\n", i);
-			return PTR_ERR(rdev);
-		}
+		if (IS_ERR(rdev))
+			return dev_err_probe(dev, PTR_ERR(rdev),
+					     "Failed to register (%d) regulator\n", i);
 
 		priv->rdev[i] = rdev;
 	}
@@ -385,10 +376,8 @@ static int mt6370_regulator_probe(struct platform_device *pdev)
 	priv->dev = &pdev->dev;
 
 	priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
-	if (!priv->regmap) {
-		dev_err(&pdev->dev, "Failed to init regmap\n");
-		return -ENODEV;
-	}
+	if (!priv->regmap)
+		return dev_err_probe(&pdev->dev, -ENODEV, "Failed to init regmap\n");
 
 	ret = mt6370_regualtor_register(priv);
 	if (ret)
-- 
2.7.4



WARNING: multiple messages have this Message-ID (diff)
From: cy_huang <u0084500@gmail.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, lee@kernel.org, matthias.bgg@gmail.com,
	yangyingliang@huawei.com, chiaen_wu@richtek.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	ChiYuan Huang <cy_huang@richtek.com>
Subject: [PATCH 2/2] regulator: mt6370: Switch to use dev_err_probe() helper
Date: Wed, 30 Nov 2022 16:37:43 +0800	[thread overview]
Message-ID: <1669797463-24887-2-git-send-email-u0084500@gmail.com> (raw)
In-Reply-To: <1669797463-24887-1-git-send-email-u0084500@gmail.com>

From: ChiYuan Huang <cy_huang@richtek.com>

Use dev_err_probe helper to simplify the probe function.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
 drivers/regulator/mt6370-regulator.c | 39 +++++++++++++-----------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/regulator/mt6370-regulator.c b/drivers/regulator/mt6370-regulator.c
index c2b589a..e090fbe 100644
--- a/drivers/regulator/mt6370-regulator.c
+++ b/drivers/regulator/mt6370-regulator.c
@@ -303,11 +303,9 @@ static int mt6370_regulator_irq_register(struct mt6370_priv *priv)
 		ret = devm_request_threaded_irq(priv->dev, irq, NULL,
 						mt6370_irqs[i].handler, 0,
 						mt6370_irqs[i].name, rdev);
-		if (ret) {
-			dev_err(priv->dev,
-				"Failed to register (%d) interrupt\n", i);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(priv->dev, ret,
+					     "Failed to register (%d) interrupt\n", i);
 	}
 
 	return 0;
@@ -329,20 +327,16 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv)
 	int i, ret;
 
 	regulator_np = of_get_child_by_name(parent->of_node, "regulators");
-	if (!regulator_np) {
-		dev_err(dev, "Could not find parent 'regulators' node\n");
-		return -ENODEV;
-	}
+	if (!regulator_np)
+		return dev_err_probe(dev, -ENODEV, "Could not find parent 'regulators' node\n");
 
 	ret = of_regulator_match(dev, regulator_np, mt6370_regulator_match,
 				 ARRAY_SIZE(mt6370_regulator_match));
 
 	of_node_put(regulator_np);
 
-	if (ret < 0) {
-		dev_err(dev, "Error parsing regulator init data: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Error parsing regulator init data\n");
 
 	for (i = 0; i < MT6370_MAX_IDX; i++) {
 		const struct regulator_desc *desc = mt6370_regulator_descs + i;
@@ -355,17 +349,14 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv)
 
 		if (cfg.of_node && desc->of_parse_cb) {
 			ret = desc->of_parse_cb(cfg.of_node, desc, &cfg);
-			if (ret) {
-				dev_err(dev, "Failed in of_parse_cb\n");
-				return ret;
-			}
+			if (ret)
+				return dev_err_probe(dev, ret, "Failed in of_parse_cb\n");
 		}
 
 		rdev = devm_regulator_register(dev, desc, &cfg);
-		if (IS_ERR(rdev)) {
-			dev_err(dev, "Failed to register (%d) regulator\n", i);
-			return PTR_ERR(rdev);
-		}
+		if (IS_ERR(rdev))
+			return dev_err_probe(dev, PTR_ERR(rdev),
+					     "Failed to register (%d) regulator\n", i);
 
 		priv->rdev[i] = rdev;
 	}
@@ -385,10 +376,8 @@ static int mt6370_regulator_probe(struct platform_device *pdev)
 	priv->dev = &pdev->dev;
 
 	priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
-	if (!priv->regmap) {
-		dev_err(&pdev->dev, "Failed to init regmap\n");
-		return -ENODEV;
-	}
+	if (!priv->regmap)
+		return dev_err_probe(&pdev->dev, -ENODEV, "Failed to init regmap\n");
 
 	ret = mt6370_regualtor_register(priv);
 	if (ret)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-11-30  8:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  8:37 [PATCH 1/2] regulator: mt6370: Fix potential UAF issue cy_huang
2022-11-30  8:37 ` cy_huang
2022-11-30  8:37 ` cy_huang [this message]
2022-11-30  8:37   ` [PATCH 2/2] regulator: mt6370: Switch to use dev_err_probe() helper cy_huang
2022-12-01 11:43 ` [PATCH 1/2] regulator: mt6370: Fix potential UAF issue Mark Brown
2022-12-01 11:43   ` Mark Brown
2022-12-02  3:35   ` ChiYuan Huang
2022-12-02  3:35     ` ChiYuan Huang
2022-12-02 12:08     ` Mark Brown
2022-12-02 12:08       ` 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=1669797463-24887-2-git-send-email-u0084500@gmail.com \
    --to=u0084500@gmail.com \
    --cc=broonie@kernel.org \
    --cc=chiaen_wu@richtek.com \
    --cc=cy_huang@richtek.com \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=yangyingliang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.