aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-07-24 16:14:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-24 16:14:06 -0400
commitafdf0b91bdf04bc66ee64e1ac44f0979c55749b1 (patch)
tree995486dc2835b982264e329d702e1fe3a513b608
parent365c83c3f56e5c7b161c041a487170f9a4840523 (diff)
parent4c7d83e8a8106d90d4eff971c8d070f718ac4f9c (diff)
Merge tag 'regulator-fix-v4.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "As well as some driver specific fixes there's several fixes here for the core support for regulators supplying other regulators fixing both an issue with ACPI support (which had never been tested before) and some error handling and device removal issues that Javier noticed" * tag 'regulator-fix-v4.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: core: Fix memory leak in regulator_resolve_supply() regulator: core: Increase refcount for regulator supply's module regulator: core: Handle full constraints systems when resolving supplies regulator: 88pm800: fix LDO vsel_mask value regulator: max8973: Fix up control flag option for bias control regulator: s2mps11: Fix GPIO suspend enable shift wrapping bug
-rw-r--r--drivers/regulator/88pm800.c2
-rw-r--r--drivers/regulator/core.c19
-rw-r--r--drivers/regulator/max8973-regulator.c2
-rw-r--r--drivers/regulator/s2mps11.c14
4 files changed, 27 insertions, 10 deletions
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index 832932bdc977..7fd4f511d78f 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -130,7 +130,7 @@ struct pm800_regulators {
130 .owner = THIS_MODULE, \ 130 .owner = THIS_MODULE, \
131 .n_voltages = ARRAY_SIZE(ldo_volt_table), \ 131 .n_voltages = ARRAY_SIZE(ldo_volt_table), \
132 .vsel_reg = PM800_##vreg##_VOUT, \ 132 .vsel_reg = PM800_##vreg##_VOUT, \
133 .vsel_mask = 0x1f, \ 133 .vsel_mask = 0xf, \
134 .enable_reg = PM800_##ereg, \ 134 .enable_reg = PM800_##ereg, \
135 .enable_mask = 1 << (ebit), \ 135 .enable_mask = 1 << (ebit), \
136 .volt_table = ldo_volt_table, \ 136 .volt_table = ldo_volt_table, \
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c9f72019bd68..78387a6cbae5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -109,6 +109,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
109static struct regulator *create_regulator(struct regulator_dev *rdev, 109static struct regulator *create_regulator(struct regulator_dev *rdev,
110 struct device *dev, 110 struct device *dev,
111 const char *supply_name); 111 const char *supply_name);
112static void _regulator_put(struct regulator *regulator);
112 113
113static const char *rdev_get_name(struct regulator_dev *rdev) 114static const char *rdev_get_name(struct regulator_dev *rdev)
114{ 115{
@@ -1105,6 +1106,9 @@ static int set_supply(struct regulator_dev *rdev,
1105 1106
1106 rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); 1107 rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev));
1107 1108
1109 if (!try_module_get(supply_rdev->owner))
1110 return -ENODEV;
1111
1108 rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY"); 1112 rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
1109 if (rdev->supply == NULL) { 1113 if (rdev->supply == NULL) {
1110 err = -ENOMEM; 1114 err = -ENOMEM;
@@ -1381,9 +1385,13 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
1381 } 1385 }
1382 1386
1383 if (!r) { 1387 if (!r) {
1384 dev_err(dev, "Failed to resolve %s-supply for %s\n", 1388 if (have_full_constraints()) {
1385 rdev->supply_name, rdev->desc->name); 1389 r = dummy_regulator_rdev;
1386 return -EPROBE_DEFER; 1390 } else {
1391 dev_err(dev, "Failed to resolve %s-supply for %s\n",
1392 rdev->supply_name, rdev->desc->name);
1393 return -EPROBE_DEFER;
1394 }
1387 } 1395 }
1388 1396
1389 /* Recursively resolve the supply of the supply */ 1397 /* Recursively resolve the supply of the supply */
@@ -1398,8 +1406,11 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
1398 /* Cascade always-on state to supply */ 1406 /* Cascade always-on state to supply */
1399 if (_regulator_is_enabled(rdev)) { 1407 if (_regulator_is_enabled(rdev)) {
1400 ret = regulator_enable(rdev->supply); 1408 ret = regulator_enable(rdev->supply);
1401 if (ret < 0) 1409 if (ret < 0) {
1410 if (rdev->supply)
1411 _regulator_put(rdev->supply);
1402 return ret; 1412 return ret;
1413 }
1403 } 1414 }
1404 1415
1405 return 0; 1416 return 0;
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index 6f2bdad8b4d8..e94ddcf97722 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -450,7 +450,7 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
450 pdata->control_flags |= MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE; 450 pdata->control_flags |= MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE;
451 451
452 if (of_property_read_bool(np, "maxim,enable-bias-control")) 452 if (of_property_read_bool(np, "maxim,enable-bias-control"))
453 pdata->control_flags |= MAX8973_BIAS_ENABLE; 453 pdata->control_flags |= MAX8973_CONTROL_BIAS_ENABLE;
454 454
455 return pdata; 455 return pdata;
456} 456}
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 326ffb553371..72fc3c32db49 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -34,6 +34,8 @@
34#include <linux/mfd/samsung/s2mps14.h> 34#include <linux/mfd/samsung/s2mps14.h>
35#include <linux/mfd/samsung/s2mpu02.h> 35#include <linux/mfd/samsung/s2mpu02.h>
36 36
37/* The highest number of possible regulators for supported devices. */
38#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
37struct s2mps11_info { 39struct s2mps11_info {
38 unsigned int rdev_num; 40 unsigned int rdev_num;
39 int ramp_delay2; 41 int ramp_delay2;
@@ -49,7 +51,7 @@ struct s2mps11_info {
49 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether 51 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
50 * the suspend mode was enabled. 52 * the suspend mode was enabled.
51 */ 53 */
52 unsigned long long s2mps14_suspend_state:50; 54 DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX);
53 55
54 /* Array of size rdev_num with GPIO-s for external sleep control */ 56 /* Array of size rdev_num with GPIO-s for external sleep control */
55 int *ext_control_gpio; 57 int *ext_control_gpio;
@@ -500,7 +502,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
500 switch (s2mps11->dev_type) { 502 switch (s2mps11->dev_type) {
501 case S2MPS13X: 503 case S2MPS13X:
502 case S2MPS14X: 504 case S2MPS14X:
503 if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 505 if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
504 val = S2MPS14_ENABLE_SUSPEND; 506 val = S2MPS14_ENABLE_SUSPEND;
505 else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) 507 else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
506 val = S2MPS14_ENABLE_EXT_CONTROL; 508 val = S2MPS14_ENABLE_EXT_CONTROL;
@@ -508,7 +510,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
508 val = rdev->desc->enable_mask; 510 val = rdev->desc->enable_mask;
509 break; 511 break;
510 case S2MPU02: 512 case S2MPU02:
511 if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 513 if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
512 val = S2MPU02_ENABLE_SUSPEND; 514 val = S2MPU02_ENABLE_SUSPEND;
513 else 515 else
514 val = rdev->desc->enable_mask; 516 val = rdev->desc->enable_mask;
@@ -562,7 +564,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
562 if (ret < 0) 564 if (ret < 0)
563 return ret; 565 return ret;
564 566
565 s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev)); 567 set_bit(rdev_get_id(rdev), s2mps11->suspend_state);
566 /* 568 /*
567 * Don't enable suspend mode if regulator is already disabled because 569 * Don't enable suspend mode if regulator is already disabled because
568 * this would effectively for a short time turn on the regulator after 570 * this would effectively for a short time turn on the regulator after
@@ -960,18 +962,22 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
960 case S2MPS11X: 962 case S2MPS11X:
961 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); 963 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
962 regulators = s2mps11_regulators; 964 regulators = s2mps11_regulators;
965 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
963 break; 966 break;
964 case S2MPS13X: 967 case S2MPS13X:
965 s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); 968 s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
966 regulators = s2mps13_regulators; 969 regulators = s2mps13_regulators;
970 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
967 break; 971 break;
968 case S2MPS14X: 972 case S2MPS14X:
969 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); 973 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
970 regulators = s2mps14_regulators; 974 regulators = s2mps14_regulators;
975 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
971 break; 976 break;
972 case S2MPU02: 977 case S2MPU02:
973 s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); 978 s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
974 regulators = s2mpu02_regulators; 979 regulators = s2mpu02_regulators;
980 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
975 break; 981 break;
976 default: 982 default:
977 dev_err(&pdev->dev, "Invalid device type: %u\n", 983 dev_err(&pdev->dev, "Invalid device type: %u\n",