From: Naresh Solanki <naresh.solanki@9elements.com>
To: Zev Weiss <zev@bewilderbeest.net>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] regulator: userspace-consumer: Multiple regulators
Date: Thu, 20 Apr 2023 17:57:51 +0530 [thread overview]
Message-ID: <6848572f-ec5c-39d9-4193-f72fa52f5e81@9elements.com> (raw)
In-Reply-To: <0e8f4068-70c2-4609-961e-34b5ef9d0113@hatter.bewilderbeest.net>
Hi Zev,
On 20-04-2023 04:27 pm, Zev Weiss wrote:
> On Thu, Apr 20, 2023 at 01:46:14AM PDT, Naresh Solanki wrote:
>> Hi Zev,
>>
>> On 20-04-2023 05:32 am, Zev Weiss wrote:
>>> On Tue, Apr 18, 2023 at 07:50:51AM PDT, Naresh Solanki wrote:
>>>> Use property regulator-supplies to determine all regulator
>>>> supplies.
>>>> This is useful in case of a connector having 2 or more supplies.
>>>> Example: PCIe connector on mainboard can be powered by 12V & 3.3V
>>>> suplies.
>>>>
>>>> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
>>>> ---
>>>> drivers/regulator/userspace-consumer.c | 19 +++++++++++++++----
>>>> 1 file changed, 15 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/regulator/userspace-consumer.c
>>>> b/drivers/regulator/userspace-consumer.c
>>>> index 97f075ed68c9..0bb49547b926 100644
>>>> --- a/drivers/regulator/userspace-consumer.c
>>>> +++ b/drivers/regulator/userspace-consumer.c
>>>> @@ -120,7 +120,10 @@ static int
>>>> regulator_userspace_consumer_probe(struct platform_device *pdev)
>>>> struct regulator_userspace_consumer_data tmpdata;
>>>> struct regulator_userspace_consumer_data *pdata;
>>>> struct userspace_consumer_data *drvdata;
>>>> - int ret;
>>>> + struct device_node *np = pdev->dev.of_node;
>>>> + struct property *prop;
>>>> + const char *supply;
>>>> + int ret, count = 0;
>>>>
>>>> pdata = dev_get_platdata(&pdev->dev);
>>>> if (!pdata) {
>>>> @@ -131,11 +134,19 @@ static int
>>>> regulator_userspace_consumer_probe(struct platform_device *pdev)
>>>> memset(pdata, 0, sizeof(*pdata));
>>>>
>>>> pdata->no_autoswitch = true;
>>>> - pdata->num_supplies = 1;
>>>> - pdata->supplies = devm_kzalloc(&pdev->dev,
>>>> sizeof(*pdata->supplies), GFP_KERNEL);
>>>> + pdata->num_supplies = of_property_count_strings(np,
>>>> "regulator-supplies");
>>>> + if (pdata->num_supplies < 0) {
>>>> + dev_err(&pdev->dev, "could not parse property
>>>> regulator-supplies");
>>>> + return -EINVAL;
>>>> + }
>>>> + pdata->supplies = devm_kzalloc(&pdev->dev,
>>>> + sizeof(*pdata->supplies) *
>>>> pdata->num_supplies,
>>>> + GFP_KERNEL);
>>>
>>> AFAICT this doesn't appear to implement the "vout" default specified
>>> in the dt-binding patch?
>> The "regulator-supplies" property will hold the default value of
>> "vout" unless specified otherwise. As a result, the string enumeration
>> retrieves the value of "vout" by default, and the "vout-supply"
>> property is utilized for the regulator.
>>
>
> With the disclaimer that I'm not a DT expert, that's not my
> understanding of how DT works. I don't think the 'default' value
> specified in the binding forces the fdt to always include that value if
> it's not present in the dts (since I'm pretty sure dtc doesn't even look
> at the binding to know that a default exists when compiling the dts);
> rather, it's information meant to be used by the software implementing
> support for that device (e.g. a driver for it) about what value to
> assume if the property isn't present in the fdt.
I apologize for the oversight on my part. Upon further testing, I have
discovered that the default did not reflect in the debug prints. I will
address this issue and include the proper fix in the next patchset.
Thank you for bringing this to my attention
>
>>>
>>> Also, since the core of the userspace-consumer driver itself already
>>> supports multiple regulators, it might be nice for the subject line
>>> to mention DT supplies or something a bit more specifically.
>> Sure. How about 'Support multiple supplies' ?
>
> I meant that it should explicitly mention "DT" (or perhaps "OF"). The
> driver's structure has supported multiple supplies since it was first
> introduced in 2009, so "Support multiple supplies" sounds like this
> commit is adding functionality that was already there. What this patch
> is doing is connecting that existing support to the OF support logic so
> that it can be used in a device-tree context.
Sure. Will make it something like "Support multiple supplies in DT".
>
>>>
>>>> if (!pdata->supplies)
>>>> return -ENOMEM;
>>>> - pdata->supplies[0].supply = "vout";
>>>> +
>>>> + of_property_for_each_string(np, "regulator-supplies", prop,
>>>> supply)
>>>> + pdata->supplies[count++].supply = supply;
>>>> }
>>>>
>>>> if (pdata->num_supplies < 1) {
>>>> --
>>>> 2.39.1
>>>>
>>>>
>> Regards,
>> Naresh
Regards,
Naresh
next prev parent reply other threads:[~2023-04-20 12:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 14:50 [PATCH 1/2] dt-bindings: regulator: Add dt property Naresh Solanki
2023-04-18 14:50 ` [PATCH 2/2] regulator: userspace-consumer: Multiple regulators Naresh Solanki
2023-04-20 0:02 ` Zev Weiss
2023-04-20 8:46 ` Naresh Solanki
2023-04-20 10:57 ` Zev Weiss
2023-04-20 12:27 ` Naresh Solanki [this message]
2023-04-20 0:01 ` [PATCH 1/2] dt-bindings: regulator: Add dt property Zev Weiss
2023-04-20 8:22 ` Naresh Solanki
2023-04-20 10:41 ` Zev Weiss
2023-04-20 11:32 ` Naresh Solanki
2023-04-21 18:10 ` Rob Herring
2023-04-24 7:49 ` Naresh Solanki
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=6848572f-ec5c-39d9-4193-f72fa52f5e81@9elements.com \
--to=naresh.solanki@9elements.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zev@bewilderbeest.net \
/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®