Skip to contentSkip to conversation

pwm: core: Do not create device link for same consumer & supplier

PATCH In review Naresh Solanki 3 participants 3 messages Nov 17, 2022 PWM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pwm: core: Do not create device link for same consumer & supplier

If the PWM consumer is the child DT device of PWM supplier, i.e., the same 'struct device' then do not create device link.

---
 drivers/pwm/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pwm/core.c +6 -0
index ebb2c53ac7a7..7acc87316626 100644
@@ -704,6 +704,12 @@ static struct device_link *pwm_device_link_add(struct device *dev,
 		return NULL;
 	}
 
+	/*
+	 * Do not create device link if consumer & supplier are the same.
+	 */
+	if (dev == pwm->chip->dev)
+		return 0;
+
 	dl = device_link_add(dev, pwm->chip->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
 	if (!dl) {
 		dev_err(dev, "failed to create device link to %s\n",

base-commit: bf22908680cca3dd9f575335b5d7716d7b97f0d8

Signature · 1 line
2.37.3
#1 lore raw

Hello,

Quoted 4 lines · Naresh Solanki

If the PWM consumer is the child DT device of PWM supplier, i.e., the same 'struct device' then do not create device link.

In a private conversation I learned that this is needed for
https://lore.kernel.org/all/[email protected]/

Given the series above is broken without this patch, I suggest to discuss these in a single series.

I still think the provider shouldn't consume it's own PWM. Either the PWM is usable for other purposes, then it should be a proper device on its own, or it isn't and then please don't expose it.

Both options make this patch redundant.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw
Quoted 12 lines · Uwe Kleine-König

Hello,

Quoted 4 lines · Naresh Solanki

If the PWM consumer is the child DT device of PWM supplier, i.e., the same 'struct device' then do not create device link.

In a private conversation I learned that this is needed for
https://lore.kernel.org/all/[email protected]/

Quoted 6 lines

Given the series above is broken without this patch, I suggest to discuss these in a single series.

I still think the provider shouldn't consume it's own PWM. Either the PWM is usable for other purposes, then it should be a proper device on its own, or it isn't and then please don't expose it.

TBC, none of this should affect the binding because this is all kernel implementation decisions. In the binding, the consumer is a proper device (node).

Unless there's some automatic h/w feedback controlling the pwm, the fan controller needs to do normal PWM control like any other client. Not exposing as a PWM means reimplementing everything the PWM subsystem does including parsing the pwms properties itself. That doesn't seem great. Long term, perhaps there should be fan driver(s) separate from a fan controller.

Rob