From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759652AbbCDTfs (ORCPT ); Wed, 4 Mar 2015 14:35:48 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:45711 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758905AbbCDTfq (ORCPT ); Wed, 4 Mar 2015 14:35:46 -0500 Message-ID: <54F75E8F.2070900@codeaurora.org> Date: Wed, 04 Mar 2015 11:35:43 -0800 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 , Ian Campbell , Kumar Gala , Lee Jones , Liam Girdwood , Mark Brown , Mark Rutland , Pawel Moll , Rob Herring , Andy Gross CC: Chanwoo Choi , Krzysztof Kozlowski , Srinivas Kandagatla , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 4/4] regulator: qcom: Rework to single platform device References: <1425356740-26285-1-git-send-email-bjorn.andersson@sonymobile.com> <1425356740-26285-5-git-send-email-bjorn.andersson@sonymobile.com> In-Reply-To: <1425356740-26285-5-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 On 03/02/15 20:25, Bjorn Andersson wrote: > + 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"); > + 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; > + } > > - 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"); > + return PTR_ERR(rdev); > + } > } > > return 0; There's another problem with this of_parse_cb design. The regulator framework requires supplies to be registered before consumers of the supplies are registered. So when we register L23 we need to make sure it's supply is already registered (S8 for example). If we used of_regulator_match() we could sort the array by hand so that we always register the supplies first. Or we could modify the regulator framework to have a concept of "orphaned" supplies like the clock framework has so that when a regulator is registered it waits until its supply is registered. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project