You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
regulator: core: Use ww_mutex for regulators locking
Wait/wound mutex shall be used in order to avoid lockups on locking of coupled regulators. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Suggested-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
6303f3e78b
commit
f8702f9e4a
File diff suppressed because it is too large
Load Diff
@@ -131,7 +131,7 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
|
||||
if (error < 0)
|
||||
goto error_i2c;
|
||||
|
||||
mutex_lock(&chip->rdev->mutex);
|
||||
regulator_lock(chip->rdev);
|
||||
|
||||
if (val & DA9210_E_OVCURR) {
|
||||
regulator_notifier_call_chain(chip->rdev,
|
||||
@@ -157,7 +157,7 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
|
||||
handled |= DA9210_E_VMAX;
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->rdev->mutex);
|
||||
regulator_unlock(chip->rdev);
|
||||
|
||||
if (handled) {
|
||||
/* Clear handled events */
|
||||
|
||||
@@ -489,14 +489,14 @@ static irqreturn_t stpmic1_curlim_irq_handler(int irq, void *data)
|
||||
{
|
||||
struct regulator_dev *rdev = (struct regulator_dev *)data;
|
||||
|
||||
mutex_lock(&rdev->mutex);
|
||||
regulator_lock(rdev, NULL);
|
||||
|
||||
/* Send an overcurrent notification */
|
||||
regulator_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_OVER_CURRENT,
|
||||
NULL);
|
||||
|
||||
mutex_unlock(&rdev->mutex);
|
||||
regulator_unlock(rdev);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -1153,7 +1153,7 @@ static irqreturn_t pmic_uv_handler(int irq, void *data)
|
||||
{
|
||||
struct regulator_dev *rdev = (struct regulator_dev *)data;
|
||||
|
||||
mutex_lock(&rdev->mutex);
|
||||
regulator_lock(rdev);
|
||||
if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2)
|
||||
regulator_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_REGULATION_OUT,
|
||||
@@ -1162,7 +1162,7 @@ static irqreturn_t pmic_uv_handler(int irq, void *data)
|
||||
regulator_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_UNDER_VOLTAGE,
|
||||
NULL);
|
||||
mutex_unlock(&rdev->mutex);
|
||||
regulator_unlock(rdev);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/ww_mutex.h>
|
||||
|
||||
struct gpio_desc;
|
||||
struct regmap;
|
||||
@@ -462,7 +463,7 @@ struct regulator_dev {
|
||||
struct coupling_desc coupling_desc;
|
||||
|
||||
struct blocking_notifier_head notifier;
|
||||
struct mutex mutex; /* consumer lock */
|
||||
struct ww_mutex mutex; /* consumer lock */
|
||||
struct task_struct *mutex_owner;
|
||||
int ref_cnt;
|
||||
struct module *owner;
|
||||
@@ -545,4 +546,7 @@ int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
|
||||
bool enable);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user