lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 6 Apr 2015 16:34:00 -0700
From:	Bjorn Andersson <bjorn.andersson@...ymobile.com>
To:	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>
CC:	Stephen Boyd <sboyd@...eaurora.org>,
	Andy Gross <agross@...eaurora.org>,
	Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
	<linux-kernel@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>
Subject: [PATCH v3 5/5] regulator: qcom: Tidy up probe()

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

Signed-off-by: Bjorn Andersson <bjorn.andersson@...ymobile.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ