From patchwork Mon Apr 6 23:34:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 6166391 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B4E6E9F2E9 for ; Mon, 6 Apr 2015 23:34:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C96FA202E5 for ; Mon, 6 Apr 2015 23:34:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3C4C20357 for ; Mon, 6 Apr 2015 23:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbbDFXeX (ORCPT ); Mon, 6 Apr 2015 19:34:23 -0400 Received: from seldrel01.sonyericsson.com ([212.209.106.2]:3637 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753109AbbDFXeR (ORCPT ); Mon, 6 Apr 2015 19:34:17 -0400 From: Bjorn Andersson To: Liam Girdwood , Mark Brown CC: Stephen Boyd , Andy Gross , Srinivas Kandagatla , , Subject: [PATCH v3 5/5] regulator: qcom: Tidy up probe() Date: Mon, 6 Apr 2015 16:34:00 -0700 Message-ID: <1428363240-2027-6-git-send-email-bjorn.andersson@sonymobile.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1428363240-2027-1-git-send-email-bjorn.andersson@sonymobile.com> References: <1428363240-2027-1-git-send-email-bjorn.andersson@sonymobile.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tidy up error reporting and move rpm reference retrieval out of the for loop for improved readability. Signed-off-by: Bjorn Andersson Reviewed-by: Stephen Boyd --- 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); } }