mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@sonymobile.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>,
	Andy Gross <agross@codeaurora.org>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>
Subject: [PATCH v3 5/5] regulator: qcom: Tidy up probe()
Date: Mon, 6 Apr 2015 16:34:00 -0700	[thread overview]
Message-ID: <1428363240-2027-6-git-send-email-bjorn.andersson@sonymobile.com> (raw)
In-Reply-To: <1428363240-2027-1-git-send-email-bjorn.andersson@sonymobile.com>

Tidy up error reporting and move rpm reference retrieval out of the for
loop for improved readability.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---

Patch added to series since v2.

 drivers/regulator/qcom_rpm-regulator.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 40cf6ff..e254272 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -884,19 +884,26 @@ static int rpm_reg_probe(struct platform_device *pdev)
 	struct regulator_config config = { };
 	struct regulator_dev *rdev;
 	struct qcom_rpm_reg *vreg;
+	struct qcom_rpm *rpm;
+
+	rpm = dev_get_drvdata(pdev->dev.parent);
+	if (!rpm) {
+		dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
+		return -ENODEV;
+	}
 
 	match = of_match_device(rpm_of_match, &pdev->dev);
 	for (reg = match->data; reg->name; reg++) {
 		vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
-		if (!vreg) {
-			dev_err(&pdev->dev, "failed to allocate vreg\n");
+		if (!vreg)
 			return -ENOMEM;
-		}
+
 		memcpy(vreg, reg->template, sizeof(*vreg));
 		mutex_init(&vreg->lock);
 
 		vreg->dev = &pdev->dev;
 		vreg->resource = reg->resource;
+		vreg->rpm = rpm;
 
 		vreg->desc.id = -1;
 		vreg->desc.owner = THIS_MODULE;
@@ -906,17 +913,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
 		vreg->desc.of_match = reg->name;
 		vreg->desc.of_parse_cb = rpm_reg_of_parse;
 
-		vreg->rpm = dev_get_drvdata(pdev->dev.parent);
-		if (!vreg->rpm) {
-			dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
-			return -ENODEV;
-		}
-
 		config.dev = &pdev->dev;
 		config.driver_data = vreg;
 		rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config);
 		if (IS_ERR(rdev)) {
-			dev_err(&pdev->dev, "can't register regulator\n");
+			dev_err(&pdev->dev, "failed to register %s\n", reg->name);
 			return PTR_ERR(rdev);
 		}
 	}
-- 
1.8.2.2


  parent reply	other threads:[~2015-04-06 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-06 23:33 [PATCH v3 0/5] Refactor Qualcomm RPM regulator to single platform_device Bjorn Andersson
2015-04-06 23:33 ` [PATCH v3 1/5] mfd: devicetree: bindings: Add Qualcomm RPM regulator subnodes Bjorn Andersson
2015-04-07  6:39   ` Lee Jones
2015-04-06 23:33 ` [PATCH v3 2/5] regulator: qcom: Don't enable DRMS in driver Bjorn Andersson
2015-04-07 11:11   ` Mark Brown
2015-04-07 13:45     ` Bjorn Andersson
2015-04-06 23:33 ` [PATCH v3 3/5] regulator: qcom: Refactor of-parsing code Bjorn Andersson
2015-04-06 23:33 ` [PATCH v3 4/5] regulator: qcom: Rework to single platform device Bjorn Andersson
2015-04-06 23:40   ` Stephen Boyd
2015-04-06 23:34 ` Bjorn Andersson [this message]
2015-04-06 23:40   ` [PATCH v3 5/5] regulator: qcom: Tidy up probe() Stephen Boyd
2015-04-08 11:23 ` [PATCH v3 0/5] Refactor Qualcomm RPM regulator to single platform_device 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=1428363240-2027-6-git-send-email-bjorn.andersson@sonymobile.com \
    --to=bjorn.andersson@sonymobile.com \
    --cc=agross@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.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®