Message ID | cover.1613042245.git.matti.vaittinen@fi.rohmeurope.com |
---|---|
Headers | show |
Series | Extend regulator notification support | expand |
On Thu, 2021-02-11 at 14:35 +0200, Matti Vaittinen wrote: > Add DT property parsing code and setting callback for regulator > over/under > voltage, over-current and temperature error limits. > > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> > --- > drivers/regulator/core.c | 122 > +++++++++++++++++++++- > drivers/regulator/of_regulator.c | 58 ++++++++++ > drivers/regulator/qcom-labibb-regulator.c | 10 +- > drivers/regulator/stpmic1_regulator.c | 17 ++- > include/linux/regulator/driver.h | 41 +++++++- > include/linux/regulator/machine.h | 26 +++++ > 6 files changed, 267 insertions(+), 7 deletions(-) Just a note. I did somehow miss the qcom_spmi-regulator.c which also uses the .set_over_current_protection. I will include that file in next version if the idea is still seen worthy. Sorry for the incompleteness. Best Regards Matti Vaittinen
On Thu, 2021-02-11 at 14:35 +0200, Matti Vaittinen wrote: > Provide helper function for IC's implementing regulator notifications > when an IRQ fires. The helper also works for IRQs which can not be > acked. > Helper can be set to disable the IRQ at handler and then re-enabling > it > on delayed work later. The helper also adds > regulator_get_error_flags() > errors in cache for the duration of IRQ disabling. > > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> > --- > > This patch has gone through only a very limited amount of testing. > All > reviews / suggestions / testing is highly appreciated. > /* SNIP */ > + > +static void dev_delayed_work_drop(struct device *dev, void *res) > +{ > + cancel_delayed_work_sync(*(struct delayed_work **)res); > +} > + > +int dev_delayed_work_autocancel(struct device *dev, struct > delayed_work *w, > + void (*worker)(struct work_struct > *work)) > +{ > + struct delayed_work **ptr; > + > + ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr), > GFP_KERNEL); > + if (!ptr) > + return -ENOMEM; > + > + INIT_DELAYED_WORK(w, worker); > + *ptr = w; > + devres_add(dev, ptr); > + > + return 0; > +} > + I got mail from build-bot. Sparse warning. Bot suggested staticizing the dev_delayed_work_autocancel(). I should've been more careful. It how ever made me wonder if this would actually be worth exporting? There seems to be few drivers which need delayed wq and which implement .remove() just to call the cancel_delayed_work_sync(). I think this might help cleaning up those(?) Or am I completely off here? I just did: git grep -A15 remove |grep -B10 -A10 cancel_delayed_work_sync in drivers directory and spotted couple of candidates like watchdog/retu_wdt.c (should also use devm_watchdog_register_device) regulator/qcom_spmi-regulator.c power/supply/sbs-charger.c power/supply/sbs-battery.c power/supply/ltc2941-battery-gauge.c ... And no. I am not offering to go through _all_ drivers, but I guess I could go through at least few of them :) And sorry for noise if this has been suggested and rejected before - I didn't spot something like this from mail lists. (Maybe I am missing something?) Best Regards Matti Vaittinen -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. "non cogito me" dixit Rene Descarte, deinde evanescavit (Thanks for the translation Simon)
On Fri, Feb 12, 2021 at 09:33:44AM +0000, Vaittinen, Matti wrote: > There seems to be few drivers which need delayed wq and which implement > .remove() just to call the cancel_delayed_work_sync(). > I think this might help cleaning up those(?) Or am I completely off > here? I can see it being useful, yes.
On Thu, 2021-02-11 at 14:35 +0200, Matti Vaittinen wrote: > Provide helper function for IC's implementing regulator notifications > when an IRQ fires. The helper also works for IRQs which can not be > acked. > Helper can be set to disable the IRQ at handler and then re-enabling > it > on delayed work later. The helper also adds > regulator_get_error_flags() > errors in cache for the duration of IRQ disabling. > > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> > --- > > This patch has gone through only a very limited amount of testing. > All > reviews / suggestions / testing is highly appreciated. > // Snip > + > +static void dev_delayed_work_drop(struct device *dev, void *res) > +{ > + cancel_delayed_work_sync(*(struct delayed_work **)res); > +} > + > +int dev_delayed_work_autocancel(struct device *dev, struct > delayed_work *w, > + void (*worker)(struct work_struct > *work)) > +{ > + struct delayed_work **ptr; > + > + ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr), > GFP_KERNEL); > + if (!ptr) > + return -ENOMEM; > + > + INIT_DELAYED_WORK(w, worker); > + *ptr = w; > + devres_add(dev, ptr); > + > + return 0; > +} I sent this dev_delayed_work_autocancel() + few cleanup patches as own series. Discussion that series created made me realize that we don't want to force use of devm by hiding the WQ init here. We should introduce also non devm variant + manual cancellation routine for those who don't use devm to register rdevs. And as I see that Greg was strongly opposing the devm based delayed work cancellation - I guess that if we want to proceed with this one we'd better first implement the 'non devm' variant which uses manual wq cancellation + manual IRQ deregistering and use that cancellation to build a devm one... I'll try to cook v2 still this week. Best Regards Matti Vaittinen