Netdev List
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Andrew Lunn <andrew@lunn.ch>, Oleksij Rempel <o.rempel@pengutronix.de>
Cc: "Linus Walleij" <linusw@kernel.org>,
	"Luiz Angelo Daros de Luca" <luizluca@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	"Alvin Šipraga" <alvin.sipraga@analog.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>
Subject: Re: [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies
Date: Thu, 6 Aug 2026 17:56:15 +0200	[thread overview]
Message-ID: <02a51eff-3782-4012-8475-1047a9be4dd3@pengutronix.de> (raw)
In-Reply-To: <f2260b02-621f-4b92-aade-85c403a8839d@lunn.ch>

Hello Andrew,

[Cc += regulator maintainers]

On 8/6/26 17:35, Andrew Lunn wrote:
> On Thu, Aug 06, 2026 at 05:10:23PM +0200, Oleksij Rempel wrote:
>> On Thu, Aug 06, 2026 at 04:12:44PM +0200, Andrew Lunn wrote:
>>>> +static const char *const rtl8365mb_supplies[] = {
>>>> +	"avddh", "avddl", "dvddio", "dvddio1", "dvddl", "pllvddl", NULL,
>>>> +};
>>>> +
>>>
>>>> +static int rtl83xx_enable_supplies(struct device *dev,
>>>> +				   const char *const *supplies)
>>>> +{
>>>> +	int i, ret, count = 0;
>>>> +
>>>> +	for (i = 0; supplies && supplies[i]; i++) {
>>>> +		ret = devm_regulator_get_enable_optional(dev, supplies[i]);
>>>> +		if (ret == -ENODEV)
>>>> +			continue;
>>>> +		if (ret)
>>>> +			return dev_err_probe(dev, ret, "failed to enable %s supply\n",
>>>> +					     supplies[i]);
>>>> +		count++;
>>>> +	}
>>>> +
>>>
>>> I've never used it, i've no idea if it is applicable, but there does
>>> appear to be _bulk_ calls in the regulator API, maybe which is similar
>>> to the clk _bulk_ API?
>>
>> Ack, in the first iteration of this patch we was using
>> devm_regulator_bulk_get_enable(). But it would print warnings on
>> existing boards without regulators in devicetree. Currently there are no
>> bulk helpers with _optional regulators, so I reworked it to hand made
>> optional bulk support.
> 
> static inline int __must_check clk_bulk_get_optional(struct device *dev,
> static inline int __must_check devm_clk_bulk_get_optional(struct device *dev,
> static inline int __must_check devm_clk_bulk_get_optional_enable(struct device *dev,
> 
> If clk has them, maybe regulators should as well?

clk and regulator have different interpretations of _optional
when encountering a non-existent resource:

clk_get                 return error
clk_get_optional        return NULL
regulator_get           return handle dummy regulator
regulator_get_optional  return error code

So devm_regulator_bulk_get() is already the "optional" variant, but it causes
all existing users to get dummy supply warnings.

I don't know if there's a strong case for a devm_regulator_bulk_get_nowarn(),
maybe Mark or Liam have an opinion on that.

Cheers,
Ahmad

> 
>    Andrew
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2026-08-06 15:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 14:02 [PATCH net-next v1 0/2] net: dsa: realtek: enable RTL8365MB power supplies Oleksij Rempel
2026-08-06 14:02 ` [PATCH net-next v1 1/2] dt-bindings: net: dsa: realtek: add " Oleksij Rempel
2026-08-06 14:02 ` [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies Oleksij Rempel
2026-08-06 14:12   ` Andrew Lunn
2026-08-06 15:10     ` Oleksij Rempel
2026-08-06 15:35       ` Andrew Lunn
2026-08-06 15:56         ` Ahmad Fatoum [this message]
2026-08-06 17:40           ` Linus Walleij
2026-08-07  4:26             ` Oleksij Rempel
2026-08-07  6:51               ` Linus Walleij
2026-08-07  7:10                 ` Oleksij Rempel
2026-08-07  7:49                   ` Ahmad Fatoum
2026-08-07  8:20                     ` Linus Walleij
2026-08-07  8:27                       ` Ahmad Fatoum
2026-08-07 12:19                         ` Mark Brown
2026-08-07 14:05                           ` Ahmad Fatoum

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=02a51eff-3782-4012-8475-1047a9be4dd3@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=alsi@bang-olufsen.dk \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    /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