From 0f48eedacf1914c000c7bebdc44de15412baa6f1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 12 Jan 2016 18:28:51 +0100 Subject: regulator: da9210: fix lockdep warning Commit 70cfef26267474 ("regulator: Add lockdep asserts to help detecting locking misuse") successfully created this WARN, let's fix it: [ 1.218660] WARNING: CPU: 0 PID: 553 at drivers/regulator/core.c:3646 regulator_notifier_call_chain+0x5c/0x88() ... [ 1.220278] [] (regulator_notifier_call_chain) from [] (da9210_irq_handler+0x74/0x10c) [ 1.220412] r7:c0080cac r6:eb1daa00 r5:e64bbf10 r4:00000002 [ 1.220547] [] (da9210_irq_handler) from [] (irq_thread_fn+0x2c/0x44) ... Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- drivers/regulator/da9210-regulator.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index b3517830edb6..cfd6e8af67ec 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c @@ -132,6 +132,8 @@ static irqreturn_t da9210_irq_handler(int irq, void *data) if (error < 0) goto error_i2c; + mutex_lock(&chip->rdev->mutex); + if (val & DA9210_E_OVCURR) { regulator_notifier_call_chain(chip->rdev, REGULATOR_EVENT_OVER_CURRENT, @@ -155,6 +157,9 @@ static irqreturn_t da9210_irq_handler(int irq, void *data) NULL); handled |= DA9210_E_VMAX; } + + mutex_unlock(&chip->rdev->mutex); + if (handled) { /* Clear handled events */ error = regmap_write(chip->regmap, DA9210_REG_EVENT_B, handled); -- cgit v1.2.3 From 4434cee9b6e9d70c8afea0d46bb211f132039d19 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 11 Feb 2016 18:17:03 +0800 Subject: regulator: ad5398: Fix return value of ad5398_write_reg i2c_master_send() returns the number of bytes written on success. So current code returns 2 if ad5398_write_reg() success. This return value is propagated to .set_current_limit, .enable and .disable callbacks of regulator_ops. This can be a problem, for example, if the users test if the return value of regulator_set_current_limit() is 0. Fix it by making ad5398_write_reg() return 0 on success. Signed-off-by: Axel Lin Acked-by: Michael Hennerich Signed-off-by: Mark Brown --- drivers/regulator/ad5398.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index ea50a886ba63..8b0f788a9bbb 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c @@ -58,10 +58,12 @@ static int ad5398_write_reg(struct i2c_client *client, const unsigned short data val = cpu_to_be16(data); ret = i2c_master_send(client, (char *)&val, 2); - if (ret < 0) + if (ret != 2) { dev_err(&client->dev, "I2C write error\n"); + return ret < 0 ? ret : -EIO; + } - return ret; + return 0; } static int ad5398_get_current_limit(struct regulator_dev *rdev) -- cgit v1.2.3 From 623f7b933968b159081559baca56d98ed4b60e33 Mon Sep 17 00:00:00 2001 From: James Ban Date: Mon, 7 Mar 2016 16:08:20 +0900 Subject: regulator: pv88090: fix incorrect clear of event register This is a patch to fix incorrect clear of event register. Signed-off-by: James Ban Signed-off-by: Mark Brown --- drivers/regulator/pv88090-regulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c index ac15f31b5fe0..0057c6740d6f 100644 --- a/drivers/regulator/pv88090-regulator.c +++ b/drivers/regulator/pv88090-regulator.c @@ -283,8 +283,8 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) } } - err = regmap_update_bits(chip->regmap, PV88090_REG_EVENT_A, - PV88090_E_VDD_FLT, PV88090_E_VDD_FLT); + err = regmap_write(chip->regmap, PV88090_REG_EVENT_A, + PV88090_E_VDD_FLT); if (err < 0) goto error_i2c; @@ -300,8 +300,8 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) } } - err = regmap_update_bits(chip->regmap, PV88090_REG_EVENT_A, - PV88090_E_OVER_TEMP, PV88090_E_OVER_TEMP); + err = regmap_write(chip->regmap, PV88090_REG_EVENT_A, + PV88090_E_OVER_TEMP); if (err < 0) goto error_i2c; -- cgit v1.2.3