Hi, On Tue, Oct 10, 2023 at 01:19:36PM +0100, Mark Brown wrote: > On Tue, Oct 10, 2023 at 10:59:06AM +0200, Oleksij Rempel wrote: > > Add handler to forward under-voltage events. > > On systems for more or less complicated regulator chains we need to > > forward under-voltage events to actual driver which need to react on > > them. > > It isn't clear to me why this would be implemented in one specific > driver, nor why this would be done unconditionally. Could you provide > some information on the problem you're trying to solve here? The hardware I am working with has an under-voltage sensor on the 24V supply regulator and some backup capacitors to run SoC for 100ms. I want to forward under-voltage events across a chain of different regulators to a designated consumer. For instance, to the mmc driver, enabling it to initiate shutdown before power loss occurs. Additionally, a bit can be set in the volatile memory of a scratch pad in an RTC clock to record sudden power loss, which can be checked on the next system start. > This feels like something that should be a core feature. Agreed. I am relatively new to the regulator framework and am uncertain about the optimal location for registering the event forwarding. Could you advise on this? > > +static int reg_fixed_regulator_notifier(struct notifier_block *nb, > > + unsigned long event, void *data) > > +{ > > + struct fixed_voltage_data *priv = > > + container_of(nb, struct fixed_voltage_data, nb); > > + struct regulator_dev *rdev = priv->dev; > > + > > + if (event != REGULATOR_EVENT_UNDER_VOLTAGE_WARN && > > + event != REGULATOR_EVENT_UNDER_VOLTAGE) > > + return NOTIFY_OK; > > + > > + regulator_notifier_call_chain(rdev, event, NULL); > > This would be better written as a switch statement for extensibility, ack. > and it's not clear why the filtering? I started with a conservative approach because I'm not sure about the possible effects of forwarding all events. If forwarding all events is a good idea, I can do it. Regards, Oleksij -- 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 |