On Thu, Dec 14, 2023 at 09:14:41PM +0100, Tobias Waldekranz wrote: > Pickup the LEDs from the state in which the hardware reset or > bootloader left them, but also support further configuration via > device tree. This is primarily needed because the electrical polarity > and drive behavior is software controlled and not possible to set via > hardware strapping. > > Trigger support: > - "none" > - "timer": Map 60-100 ms periods to the fast rate (81ms) and 1000-1600 > ms periods to the slow rate (1300ms). Defer everything else to > software blinking > - "netdev": Offload link or duplex information to the solid behavior; > tx and/or rx activity to blink behavior. > > Signed-off-by: Tobias Waldekranz <tobias@xxxxxxxxxxxxxx> ... > +static int mv3310_leds_probe(struct phy_device *phydev) > +{ > + struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); > + struct device_node *node = phydev->mdio.dev.of_node; > + struct device_node *pnp, *np; > + int err, val, index; > + > + /* Save the config left by HW reset or bootloader, to make > + * sure that we do not loose any polarity config made by > + * firmware. This will be overridden by info from DT, if > + * available. > + */ > + for (index = 0; index < MV3310_N_LEDS; index++) { > + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, > + MV_V2_LED0_CONTROL + index); > + if (val < 0) > + return val; > + > + priv->led[index] = (struct mv3310_led) { > + .index = index, > + .fw_ctrl = val, > + }; > + } > + > + if (!node) > + return 0; > + > + pnp = of_get_child_by_name(node, "leds"); > + if (!pnp) > + return 0; > + > + for_each_available_child_of_node(pnp, np) { > + err = mv3310_led_probe_of(phydev, np); > + if (err) Hi Tobias, I think a call to of_node_put(np) is required here to avoid leaking a reference. Flagged by Coccinelle. > + return err; > + } > + > + return 0; > +} ...