On Fri, May 10, 2024 at 09:40:12PM +0200, Hans de Goede wrote: > Add an activate() callback to the power-supply LED triggers so that > the LED being activated will properly reflect the current power-supply > state for power-supply devices which are already fully registered > when the trigger gets activated. > > This fixes e.g. wrong LED state (1) when the LED gets registered > after the power-supply device. > > 1) Until the psy driver has a reason to call power_supply_changed() > which may take quite a while ... > +static int power_supply_led_trigger_activate(struct led_classdev *led_cdev) > +{ > + struct power_supply_led_trigger *psy_trig = > + container_of(led_cdev->trigger, struct power_supply_led_trigger, trig); Second time same container_of(), perhaps a helper [macro]? > + /* Sync current power-supply state to LED being activated */ > + power_supply_update_leds(psy_trig->psy); > + return 0; > +} -- With Best Regards, Andy Shevchenko