Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbbDBXCc (ORCPT ); Thu, 2 Apr 2015 19:02:32 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41429 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbbDBXCa (ORCPT ); Thu, 2 Apr 2015 19:02:30 -0400 Message-ID: <551DCA84.5050500@codeaurora.org> Date: Thu, 02 Apr 2015 16:02:28 -0700 From: Stephen Boyd User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bjorn Andersson , Liam Girdwood , Mark Brown CC: Andy Gross , Srinivas Kandagatla , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2 5/5] regulator: qcom: Rework to single platform device References: <1427928946-31291-1-git-send-email-bjorn.andersson@sonymobile.com> <1427928946-31291-6-git-send-email-bjorn.andersson@sonymobile.com> In-Reply-To: <1427928946-31291-6-git-send-email-bjorn.andersson@sonymobile.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2242 Lines: 67 On 04/01/15 15:55, Bjorn Andersson wrote: > +static int rpm_reg_probe(struct platform_device *pdev) > +{ > + const struct rpm_regulator_data *reg; > + const struct of_device_id *match; > + struct regulator_config config = { }; > + struct regulator_dev *rdev; > + struct qcom_rpm_reg *vreg; > > - ret = rpm_reg_of_parse(pdev->dev.of_node, &vreg->desc, &config); > - if (ret) > - return ret; > + 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"); Please remove useless error message on allocation failures. > + return -ENOMEM; > + } > + memcpy(vreg, reg->template, sizeof(*vreg)); > + mutex_init(&vreg->lock); > + > + vreg->dev = &pdev->dev; > + vreg->resource = reg->resource; > + > + vreg->desc.id = -1; > + vreg->desc.owner = THIS_MODULE; > + vreg->desc.type = REGULATOR_VOLTAGE; > + vreg->desc.name = reg->name; > + vreg->desc.supply_name = reg->supply; > + 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; > + } Was there going to be a patch to lift this out of the loop (although I hope the compiler can hoist it out). > > - rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config); > - if (IS_ERR(rdev)) { > - dev_err(&pdev->dev, "can't register regulator\n"); > - return PTR_ERR(rdev); > + 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"); It'd be nice to know which regulator failed to register. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/