[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANhBUQ2XWAJBgfzbiiffaJ60wnoP__kDPHOF4d+Z_1b1HzSpPQ@mail.gmail.com>
Date: Mon, 12 Aug 2019 20:51:25 +0800
From: Chuhong Yuan <hslester96@...il.com>
To: Mark Brown <broonie@...nel.org>
Cc: Liam Girdwood <lgirdwood@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] regulator: core: Add devres versions of regulator_enable/disable
On Mon, Aug 12, 2019 at 7:07 PM Mark Brown <broonie@...nel.org> wrote:
>
> On Sat, Aug 10, 2019 at 09:44:45AM +0800, Chuhong Yuan wrote:
> > On Fri, Aug 9, 2019 at 11:11 PM Mark Brown <broonie@...nel.org> wrote:
>
> > > I'm not super keen on managed versions of these functions since they're
> > > very likely to cause reference counting issues between the probe/remove
> > > path and the suspend/resume path which aren't obvious from the code, I'm
> > > especially worried about double frees on release.
>
> > I find that 29 of 31 cases I found call regulator_disable() only when encounter
> > probe failure or in .remove.
> > So I think the devm versions of regulator_enable/disable() will not cause big
> > problems.
>
> There's way more drivers using regulators than that...
>
I wrote a new coccinelle script to detect all regulator_disable() in .remove,
101 drivers are found in total.
Within them, 25 drivers cannot benefit from devres version of regulator_enable()
since they have additional non-devm operations after
regulator_disable() in .remove.
Within the left 76 cases, 60 drivers (79%) only use
regulator_disable() when encounter
probe failure or in .remove.
The left 16 cases mostly use regulator_disable() in _suspend().
Furthermore, 3 cases of 76 are found to forget to disable regulator
when fail in probe.
So I think a devres version of regulator_enable/disable() has more
benefits than potential
risk.
> > I even found a driver to forget to disable regulator when encounter
> > probe failure,
> > which is drivers/iio/adc/ti-adc128s052.c.
> > And a devm version of regulator_enable() can prevent such mistakes.
>
> Yes, it's useful for that.
Powered by blists - more mailing lists