2020-08-10 04:40:23

by Michał Mirosław

[permalink] [raw]
Subject: [PATCH 0/3] regulator: unexport regulator_lock/unlock()

This removes regulator_lock/unlock() calls around
regulator_notifier_call_chain() as they are redundant - drivers
already have to guarantee regulator_dev's existence during the call.

This should make reasoing about the lock easier, as this was the only
use outside regulator core code.

The only client that needed recursive locking from the notifier chain
was drivers/usb/host/ohci-da8xx.c, which responds to over-current
notification by calling regulator_disable().

Michał Mirosław (3):
regulator: don't require mutex for regulator_notifier_call_chain()
regulator: remove locking around regulator_notifier_call_chain()
regulator: unexport regulator_lock/unlock()

drivers/regulator/core.c | 11 +++--------
drivers/regulator/da9055-regulator.c | 2 --
drivers/regulator/da9062-regulator.c | 2 --
drivers/regulator/da9063-regulator.c | 2 --
drivers/regulator/da9210-regulator.c | 4 ----
drivers/regulator/da9211-regulator.c | 4 ----
drivers/regulator/lp8755.c | 6 ------
drivers/regulator/ltc3589.c | 10 ++--------
drivers/regulator/ltc3676.c | 10 ++--------
drivers/regulator/pv88060-regulator.c | 10 ++--------
drivers/regulator/pv88080-regulator.c | 10 ++--------
drivers/regulator/pv88090-regulator.c | 10 ++--------
drivers/regulator/slg51000-regulator.c | 4 ----
drivers/regulator/stpmic1_regulator.c | 4 ----
drivers/regulator/wm831x-dcdc.c | 4 ----
drivers/regulator/wm831x-isink.c | 2 --
drivers/regulator/wm831x-ldo.c | 2 --
drivers/regulator/wm8350-regulator.c | 2 --
include/linux/regulator/driver.h | 3 ---
19 files changed, 13 insertions(+), 89 deletions(-)

--
2.20.1


2020-09-06 00:14:10

by Michał Mirosław

[permalink] [raw]
Subject: Re: [PATCH 0/3] regulator: unexport regulator_lock/unlock()

On Mon, Aug 10, 2020 at 06:33:30AM +0200, Micha? Miros?aw wrote:
> This removes regulator_lock/unlock() calls around
> regulator_notifier_call_chain() as they are redundant - drivers
> already have to guarantee regulator_dev's existence during the call.
>
> This should make reasoing about the lock easier, as this was the only
> use outside regulator core code.
>
> The only client that needed recursive locking from the notifier chain
> was drivers/usb/host/ohci-da8xx.c, which responds to over-current
> notification by calling regulator_disable().

I can't see the series in regulator/for-next and got no comments.
Should I resend?

As a side note: this is a step towards fixing regulator-coupling-related
locking issues.

Best Regards,
Micha??Miros?aw

2020-09-15 18:57:22

by Michał Mirosław

[permalink] [raw]
Subject: Re: [PATCH 0/3] regulator: unexport regulator_lock/unlock()

On Mon, Sep 07, 2020 at 07:05:49PM +0100, Mark Brown wrote:
> On Mon, 10 Aug 2020 06:33:30 +0200, Micha? Miros?aw wrote:
> > This removes regulator_lock/unlock() calls around
> > regulator_notifier_call_chain() as they are redundant - drivers
> > already have to guarantee regulator_dev's existence during the call.
> >
> > This should make reasoing about the lock easier, as this was the only
> > use outside regulator core code.
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
>
> Thanks!
>
> [1/3] regulator: don't require mutex for regulator_notifier_call_chain()
> commit: 3bca239d6184df61a619d78764e0481242d844b4
> [2/3] regulator: remove locking around regulator_notifier_call_chain()
> commit: e9c142b0d2c08178a9e146d47d8fe397373bda3e
> [3/3] regulator: unexport regulator_lock/unlock()
> (no commit info)
[...]

It looks like the third one didn't get in? (Can't see it in the
for-next branch).

Best Regards
Micha? Miros?aw

2020-09-16 19:56:25

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 0/3] regulator: unexport regulator_lock/unlock()

On Tue, Sep 15, 2020 at 08:55:06PM +0200, Michał Mirosław wrote:
> On Mon, Sep 07, 2020 at 07:05:49PM +0100, Mark Brown wrote:

> > [3/3] regulator: unexport regulator_lock/unlock()
> > (no commit info)

> It looks like the third one didn't get in? (Can't see it in the
> for-next branch).

It probably didn't apply, please check and resend.


Attachments:
(No filename) (360.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-19 21:47:24

by Michał Mirosław

[permalink] [raw]
Subject: [PATCH v2] regulator: unexport regulator_lock/unlock()

regulator_lock/unlock() was used only to guard
regulator_notifier_call_chain(). As no users remain, make the functions
internal.

Signed-off-by: Michał Mirosław <[email protected]>
---
drivers/regulator/core.c | 6 ++----
include/linux/regulator/driver.h | 3 ---
2 files changed, 2 insertions(+), 7 deletions(-)
---
v2: rebased on current regulator/for-linus

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7ff507ec875a..8da37e0d1100 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -190,11 +190,10 @@ static inline int regulator_lock_nested(struct regulator_dev *rdev,
* than the one, which initially locked the mutex, it will
* wait on mutex.
*/
-void regulator_lock(struct regulator_dev *rdev)
+static void regulator_lock(struct regulator_dev *rdev)
{
regulator_lock_nested(rdev, NULL);
}
-EXPORT_SYMBOL_GPL(regulator_lock);

/**
* regulator_unlock - unlock a single regulator
@@ -203,7 +202,7 @@ EXPORT_SYMBOL_GPL(regulator_lock);
* This function unlocks the mutex when the
* reference counter reaches 0.
*/
-void regulator_unlock(struct regulator_dev *rdev)
+static void regulator_unlock(struct regulator_dev *rdev)
{
mutex_lock(&regulator_nesting_mutex);

@@ -216,7 +215,6 @@ void regulator_unlock(struct regulator_dev *rdev)

mutex_unlock(&regulator_nesting_mutex);
}
-EXPORT_SYMBOL_GPL(regulator_unlock);

static bool regulator_supply_is_couple(struct regulator_dev *rdev)
{
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 8539f34ae42b..11cade73726c 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -533,9 +533,6 @@ int regulator_set_current_limit_regmap(struct regulator_dev *rdev,
int regulator_get_current_limit_regmap(struct regulator_dev *rdev);
void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);

-void regulator_lock(struct regulator_dev *rdev);
-void regulator_unlock(struct regulator_dev *rdev);
-
/*
* Helper functions intended to be used by regulator drivers prior registering
* their regulators.
--
2.20.1