From b12a1e29af595d05612153bcb85258193bbf9382 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Tue, 2 Nov 2010 14:55:34 +0100 Subject: regulator: regulator disable supply fix This patch fixes a disable failure when regulator supply is used. A while loop in regulator disable checks for supply pointer != NULL but the pointer is not always updated, resulting in the while loop running too many times causing a disable failure. Signed-off-by: Mattias Wallin Acked-by: Linus Walleij Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index f1d10c974cd4..c62563322969 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1359,6 +1359,7 @@ static int _regulator_disable(struct regulator_dev *rdev, struct regulator_dev **supply_rdev_ptr) { int ret = 0; + *supply_rdev_ptr = NULL; if (WARN(rdev->use_count <= 0, "unbalanced disables for %s\n", -- cgit v1.2.3 From 59c700cf20a6eefb68187df3468ffa0b11d5e9a4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 3 Nov 2010 00:08:04 -0400 Subject: regulator: Staticise mc13783_powermisc_rmw() It is not used outside this driver so no need to make the symbol global. Signed-off-by: Mark Brown Acked-by: Alberto Panizzo Signed-off-by: Liam Girdwood --- drivers/regulator/mc13783-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 4597d508a229..ecd99f59dba8 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c @@ -465,8 +465,8 @@ static struct regulator_ops mc13783_fixed_regulator_ops = { .get_voltage = mc13783_fixed_regulator_get_voltage, }; -int mc13783_powermisc_rmw(struct mc13783_regulator_priv *priv, u32 mask, - u32 val) +static int mc13783_powermisc_rmw(struct mc13783_regulator_priv *priv, u32 mask, + u32 val) { struct mc13783 *mc13783 = priv->mc13783; int ret; -- cgit v1.2.3 From aa7a74040a989eeb7a9265550a2538863e842a93 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Nov 2010 15:25:12 +0800 Subject: regulator: Remove a redundant device_remove_file call in create_regulator We already have device_remove_file() in error path, no need to call it before goto link_name_err. Signed-off-by: Axel Lin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c62563322969..c3f93b401e90 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1052,7 +1052,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, printk(KERN_WARNING "%s: could not add device link %s err %d\n", __func__, dev->kobj.name, err); - device_remove_file(dev, ®ulator->dev_attr); goto link_name_err; } } -- cgit v1.2.3 From e36c1df8e18183ba2c691fe766a52c94020cdc5e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Nov 2010 21:51:32 +0800 Subject: regulator: Ensure enough delay time for enabling regulator Integer division will truncate the result, this patch ensures we have enough delay time for enabling regulator. Signed-off-by: Axel Lin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c3f93b401e90..9da85bc21db4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1312,10 +1312,12 @@ static int _regulator_enable(struct regulator_dev *rdev) if (ret < 0) return ret; - if (delay >= 1000) + if (delay >= 1000) { mdelay(delay / 1000); - else if (delay) + udelay(delay % 1000); + } else if (delay) { udelay(delay); + } } else if (ret < 0) { printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n", -- cgit v1.2.3 From 7727da22e820a96ab394db2fc0ab58f7f7ecb323 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Nov 2010 15:27:17 +0800 Subject: regulator: Return proper error for regulator_register() Signed-off-by: Axel Lin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9da85bc21db4..711fa1722bce 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2348,6 +2348,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, if (init_data->supply_regulator && init_data->supply_regulator_dev) { dev_err(dev, "Supply regulator specified by both name and dev\n"); + ret = -EINVAL; goto scrub; } @@ -2366,6 +2367,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, if (!found) { dev_err(dev, "Failed to find supply %s\n", init_data->supply_regulator); + ret = -ENODEV; goto scrub; } -- cgit v1.2.3 From 3aa713e76e8f562c0d28faf18873c4f1836b17c9 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 4 Nov 2010 11:01:31 +0100 Subject: regulator: lock supply in regulator enable This patch add locks around regulator supply enable. Signed-off-by: Mattias Wallin Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 711fa1722bce..27d062e1395c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1269,7 +1269,9 @@ static int _regulator_enable(struct regulator_dev *rdev) /* do we need to enable the supply regulator first */ if (rdev->supply) { + mutex_lock(&rdev->supply->mutex); ret = _regulator_enable(rdev->supply); + mutex_unlock(&rdev->supply->mutex); if (ret < 0) { printk(KERN_ERR "%s: failed to enable %s: %d\n", __func__, rdev_get_name(rdev), ret); -- cgit v1.2.3 From b9e26bc804e611d879353cd953cb17db1c52d307 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 22 Oct 2010 16:38:22 +0800 Subject: regulator: twl-regulator - fix twlreg_set_mode The Singular Message is 16 bits: DEV_GRP[15:13] MT[12] RES_ID[11:4] RES_STATE[3:0] Current implementation return immedially after sucessfuly write MSB part. To properly set mode, we need to write the complete message ( MSB and LSB ). In twl.h, now we have defines for PM Master module register offsets, use it instead of hard coded 0x15/0x16. Use "message & 0xff" to ensure we send correct value for LSB. Signed-off-by: Axel Lin Acked-by: Mark Brown Tested-by: Lesly Arackal Manuel Signed-off-by: Liam Girdwood --- drivers/regulator/twl-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 7e5892efc437..a57262a4fa6c 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -219,12 +219,12 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) return -EACCES; status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, - message >> 8, 0x15 /* PB_WORD_MSB */ ); - if (status >= 0) + message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB); + if (status < 0) return status; return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, - message, 0x16 /* PB_WORD_LSB */ ); + message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); } /*----------------------------------------------------------------------*/ -- cgit v1.2.3 From f3c18a87f3ddcfd31b16f689d01eb6adcc99de74 Mon Sep 17 00:00:00 2001 From: Bengt Jonsson Date: Wed, 10 Nov 2010 11:06:22 +0100 Subject: regulator: enable supply regulator only when use count is zero Supply regulators are disabled only when the last reference count is removed on the child regulator (the use count goes from 1 to 0). This patch changes the behaviour of enable so the supply regulator is enabled only when the use count of the child regulator goes from 0 to 1. Signed-off-by: Bengt Jonsson Acked-by: Linus Walleij Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 27d062e1395c..c577c6d344ac 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1267,15 +1267,17 @@ static int _regulator_enable(struct regulator_dev *rdev) { int ret, delay; - /* do we need to enable the supply regulator first */ - if (rdev->supply) { - mutex_lock(&rdev->supply->mutex); - ret = _regulator_enable(rdev->supply); - mutex_unlock(&rdev->supply->mutex); - if (ret < 0) { - printk(KERN_ERR "%s: failed to enable %s: %d\n", - __func__, rdev_get_name(rdev), ret); - return ret; + if (rdev->use_count == 0) { + /* do we need to enable the supply regulator first */ + if (rdev->supply) { + mutex_lock(&rdev->supply->mutex); + ret = _regulator_enable(rdev->supply); + mutex_unlock(&rdev->supply->mutex); + if (ret < 0) { + printk(KERN_ERR "%s: failed to enable %s: %d\n", + __func__, rdev_get_name(rdev), ret); + return ret; + } } } -- cgit v1.2.3 From 06c63f9396133f312c5a49c2285c2c8015e80934 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Thu, 18 Nov 2010 15:02:26 -0800 Subject: regulator: fix kernel-doc for set_consumer_device_supply Fix kernel-doc warning for set_consumer_device_supply(): Warning(drivers/regulator/core.c:912): missing initial short description on line: * set_consumer_device_supply: Bind a regulator to a symbolic supply Signed-off-by: Randy Dunlap Cc: Liam Girdwood Cc: Mark Brown Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c577c6d344ac..ba521f0f0fac 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -911,7 +911,7 @@ out: } /** - * set_consumer_device_supply: Bind a regulator to a symbolic supply + * set_consumer_device_supply - Bind a regulator to a symbolic supply * @rdev: regulator source * @consumer_dev: device the supply applies to * @consumer_dev_name: dev_name() string for device supply applies to -- cgit v1.2.3