Thread (16 messages) flat view 16 messages, 5 authors, 5d ago

Re: [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies

From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Date: 2026-08-06 15:56:56
Also in: linux-devicetree, lkml

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:
quoted
On Thu, Aug 06, 2026 at 04:12:44PM +0200, Andrew Lunn wrote:
quoted
quoted
+static const char *const rtl8365mb_supplies[] = {
+	"avddh", "avddl", "dvddio", "dvddio1", "dvddl", "pllvddl", NULL,
+};
+
quoted
+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 |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help