Skip to content

Commit 4c7d83e

Browse files
committed
Merge remote-tracking branches 'regulator/fix/88pm800', 'regulator/fix/max8973', 'regulator/fix/s2mps11' and 'regulator/fix/supply' into regulator-linus
5 parents 7055a31 + 322dfa6 + 127e106 + 32c848e + 36a1f1b commit 4c7d83e

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

drivers/regulator/88pm800.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct pm800_regulators {
130130
.owner = THIS_MODULE, \
131131
.n_voltages = ARRAY_SIZE(ldo_volt_table), \
132132
.vsel_reg = PM800_##vreg##_VOUT, \
133-
.vsel_mask = 0x1f, \
133+
.vsel_mask = 0xf, \
134134
.enable_reg = PM800_##ereg, \
135135
.enable_mask = 1 << (ebit), \
136136
.volt_table = ldo_volt_table, \

drivers/regulator/core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
109109
static struct regulator *create_regulator(struct regulator_dev *rdev,
110110
struct device *dev,
111111
const char *supply_name);
112+
static void _regulator_put(struct regulator *regulator);
112113

113114
static const char *rdev_get_name(struct regulator_dev *rdev)
114115
{
@@ -1105,6 +1106,9 @@ static int set_supply(struct regulator_dev *rdev,
11051106

11061107
rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev));
11071108

1109+
if (!try_module_get(supply_rdev->owner))
1110+
return -ENODEV;
1111+
11081112
rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
11091113
if (rdev->supply == NULL) {
11101114
err = -ENOMEM;
@@ -1402,8 +1406,11 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
14021406
/* Cascade always-on state to supply */
14031407
if (_regulator_is_enabled(rdev)) {
14041408
ret = regulator_enable(rdev->supply);
1405-
if (ret < 0)
1409+
if (ret < 0) {
1410+
if (rdev->supply)
1411+
_regulator_put(rdev->supply);
14061412
return ret;
1413+
}
14071414
}
14081415

14091416
return 0;

drivers/regulator/max8973-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
450450
pdata->control_flags |= MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE;
451451

452452
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;
454454

455455
return pdata;
456456
}

drivers/regulator/s2mps11.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <linux/mfd/samsung/s2mps14.h>
3535
#include <linux/mfd/samsung/s2mpu02.h>
3636

37+
/* The highest number of possible regulators for supported devices. */
38+
#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
3739
struct s2mps11_info {
3840
unsigned int rdev_num;
3941
int ramp_delay2;
@@ -49,7 +51,7 @@ struct s2mps11_info {
4951
* One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
5052
* the suspend mode was enabled.
5153
*/
52-
unsigned long long s2mps14_suspend_state:50;
54+
DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX);
5355

5456
/* Array of size rdev_num with GPIO-s for external sleep control */
5557
int *ext_control_gpio;
@@ -500,15 +502,15 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
500502
switch (s2mps11->dev_type) {
501503
case S2MPS13X:
502504
case S2MPS14X:
503-
if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
505+
if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
504506
val = S2MPS14_ENABLE_SUSPEND;
505507
else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
506508
val = S2MPS14_ENABLE_EXT_CONTROL;
507509
else
508510
val = rdev->desc->enable_mask;
509511
break;
510512
case S2MPU02:
511-
if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
513+
if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
512514
val = S2MPU02_ENABLE_SUSPEND;
513515
else
514516
val = rdev->desc->enable_mask;
@@ -562,7 +564,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
562564
if (ret < 0)
563565
return ret;
564566

565-
s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev));
567+
set_bit(rdev_get_id(rdev), s2mps11->suspend_state);
566568
/*
567569
* Don't enable suspend mode if regulator is already disabled because
568570
* 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)
960962
case S2MPS11X:
961963
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
962964
regulators = s2mps11_regulators;
965+
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
963966
break;
964967
case S2MPS13X:
965968
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
966969
regulators = s2mps13_regulators;
970+
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
967971
break;
968972
case S2MPS14X:
969973
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
970974
regulators = s2mps14_regulators;
975+
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
971976
break;
972977
case S2MPU02:
973978
s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
974979
regulators = s2mpu02_regulators;
980+
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
975981
break;
976982
default:
977983
dev_err(&pdev->dev, "Invalid device type: %u\n",

0 commit comments

Comments
 (0)