Skip to content

Commit 2ac1e66

Browse files
committed
Merge tag 'regulator-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "A few fixes for the regulator subsystems, a few driver specific things plus a fix for the interaction between regultor_can_change_voltage() and continuous voltage ranges both of which were added for this release." * tag 'regulator-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: max8998: Ensure enough delay time for max8998_set_voltage_buck_time_sel regulator: max8998: Use uV in voltage_map_desc regulator: max8997: Use uV in voltage_map_desc regulator: core: Fix comment for regulator_register() regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage regulator: s5m8767: Fix probe failure due to stack corruption
2 parents 3152ba0 + e3d5b2f commit 2ac1e66

File tree

4 files changed

+52
-47
lines changed

4 files changed

+52
-47
lines changed

drivers/regulator/core.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)
18851885
struct regulator_dev *rdev = regulator->rdev;
18861886

18871887
if (rdev->constraints &&
1888-
rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE &&
1889-
(rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1)
1890-
return 1;
1888+
(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
1889+
if (rdev->desc->n_voltages - rdev->desc->linear_min_sel > 1)
1890+
return 1;
1891+
1892+
if (rdev->desc->continuous_voltage_range &&
1893+
rdev->constraints->min_uV && rdev->constraints->max_uV &&
1894+
rdev->constraints->min_uV != rdev->constraints->max_uV)
1895+
return 1;
1896+
}
18911897

18921898
return 0;
18931899
}
@@ -3315,7 +3321,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
33153321
* @config: runtime configuration for regulator
33163322
*
33173323
* Called by regulator drivers to register a regulator.
3318-
* Returns 0 on success.
3324+
* Returns a valid pointer to struct regulator_dev on success
3325+
* or an ERR_PTR() on error.
33193326
*/
33203327
struct regulator_dev *
33213328
regulator_register(const struct regulator_desc *regulator_desc,

drivers/regulator/max8997.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,26 @@ struct voltage_map_desc {
7171
int step;
7272
};
7373

74-
/* Voltage maps in mV */
74+
/* Voltage maps in uV */
7575
static const struct voltage_map_desc ldo_voltage_map_desc = {
76-
.min = 800, .max = 3950, .step = 50,
76+
.min = 800000, .max = 3950000, .step = 50000,
7777
}; /* LDO1 ~ 18, 21 all */
7878

7979
static const struct voltage_map_desc buck1245_voltage_map_desc = {
80-
.min = 650, .max = 2225, .step = 25,
80+
.min = 650000, .max = 2225000, .step = 25000,
8181
}; /* Buck1, 2, 4, 5 */
8282

8383
static const struct voltage_map_desc buck37_voltage_map_desc = {
84-
.min = 750, .max = 3900, .step = 50,
84+
.min = 750000, .max = 3900000, .step = 50000,
8585
}; /* Buck3, 7 */
8686

87-
/* current map in mA */
87+
/* current map in uA */
8888
static const struct voltage_map_desc charger_current_map_desc = {
89-
.min = 200, .max = 950, .step = 50,
89+
.min = 200000, .max = 950000, .step = 50000,
9090
};
9191

9292
static const struct voltage_map_desc topoff_current_map_desc = {
93-
.min = 50, .max = 200, .step = 10,
93+
.min = 50000, .max = 200000, .step = 10000,
9494
};
9595

9696
static const struct voltage_map_desc *reg_voltage_map[] = {
@@ -194,7 +194,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev,
194194
if (val > desc->max)
195195
return -EINVAL;
196196

197-
return val * 1000;
197+
return val;
198198
}
199199

200200
static int max8997_get_enable_register(struct regulator_dev *rdev,
@@ -485,7 +485,6 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
485485
{
486486
struct max8997_data *max8997 = rdev_get_drvdata(rdev);
487487
struct i2c_client *i2c = max8997->iodev->i2c;
488-
int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
489488
const struct voltage_map_desc *desc;
490489
int rid = rdev_get_id(rdev);
491490
int i, reg, shift, mask, ret;
@@ -509,7 +508,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
509508

510509
desc = reg_voltage_map[rid];
511510

512-
i = max8997_get_voltage_proper_val(desc, min_vol, max_vol);
511+
i = max8997_get_voltage_proper_val(desc, min_uV, max_uV);
513512
if (i < 0)
514513
return i;
515514

@@ -557,7 +556,7 @@ static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev,
557556
case MAX8997_BUCK4:
558557
case MAX8997_BUCK5:
559558
return DIV_ROUND_UP(desc->step * (new_selector - old_selector),
560-
max8997->ramp_delay);
559+
max8997->ramp_delay * 1000);
561560
}
562561

563562
return 0;
@@ -656,7 +655,6 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
656655
const struct voltage_map_desc *desc;
657656
int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg;
658657
bool gpio_dvs_mode = false;
659-
int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
660658

661659
if (rid < MAX8997_BUCK1 || rid > MAX8997_BUCK7)
662660
return -EINVAL;
@@ -681,7 +679,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
681679
selector);
682680

683681
desc = reg_voltage_map[rid];
684-
new_val = max8997_get_voltage_proper_val(desc, min_vol, max_vol);
682+
new_val = max8997_get_voltage_proper_val(desc, min_uV, max_uV);
685683
if (new_val < 0)
686684
return new_val;
687685

@@ -1123,26 +1121,26 @@ static int max8997_pmic_probe(struct platform_device *pdev)
11231121
max8997->buck1_vol[i] = ret =
11241122
max8997_get_voltage_proper_val(
11251123
&buck1245_voltage_map_desc,
1126-
pdata->buck1_voltage[i] / 1000,
1127-
pdata->buck1_voltage[i] / 1000 +
1124+
pdata->buck1_voltage[i],
1125+
pdata->buck1_voltage[i] +
11281126
buck1245_voltage_map_desc.step);
11291127
if (ret < 0)
11301128
goto err_out;
11311129

11321130
max8997->buck2_vol[i] = ret =
11331131
max8997_get_voltage_proper_val(
11341132
&buck1245_voltage_map_desc,
1135-
pdata->buck2_voltage[i] / 1000,
1136-
pdata->buck2_voltage[i] / 1000 +
1133+
pdata->buck2_voltage[i],
1134+
pdata->buck2_voltage[i] +
11371135
buck1245_voltage_map_desc.step);
11381136
if (ret < 0)
11391137
goto err_out;
11401138

11411139
max8997->buck5_vol[i] = ret =
11421140
max8997_get_voltage_proper_val(
11431141
&buck1245_voltage_map_desc,
1144-
pdata->buck5_voltage[i] / 1000,
1145-
pdata->buck5_voltage[i] / 1000 +
1142+
pdata->buck5_voltage[i],
1143+
pdata->buck5_voltage[i] +
11461144
buck1245_voltage_map_desc.step);
11471145
if (ret < 0)
11481146
goto err_out;

drivers/regulator/max8998.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,39 @@ struct voltage_map_desc {
5151
int step;
5252
};
5353

54-
/* Voltage maps */
54+
/* Voltage maps in uV*/
5555
static const struct voltage_map_desc ldo23_voltage_map_desc = {
56-
.min = 800, .step = 50, .max = 1300,
56+
.min = 800000, .step = 50000, .max = 1300000,
5757
};
5858
static const struct voltage_map_desc ldo456711_voltage_map_desc = {
59-
.min = 1600, .step = 100, .max = 3600,
59+
.min = 1600000, .step = 100000, .max = 3600000,
6060
};
6161
static const struct voltage_map_desc ldo8_voltage_map_desc = {
62-
.min = 3000, .step = 100, .max = 3600,
62+
.min = 3000000, .step = 100000, .max = 3600000,
6363
};
6464
static const struct voltage_map_desc ldo9_voltage_map_desc = {
65-
.min = 2800, .step = 100, .max = 3100,
65+
.min = 2800000, .step = 100000, .max = 3100000,
6666
};
6767
static const struct voltage_map_desc ldo10_voltage_map_desc = {
68-
.min = 950, .step = 50, .max = 1300,
68+
.min = 95000, .step = 50000, .max = 1300000,
6969
};
7070
static const struct voltage_map_desc ldo1213_voltage_map_desc = {
71-
.min = 800, .step = 100, .max = 3300,
71+
.min = 800000, .step = 100000, .max = 3300000,
7272
};
7373
static const struct voltage_map_desc ldo1415_voltage_map_desc = {
74-
.min = 1200, .step = 100, .max = 3300,
74+
.min = 1200000, .step = 100000, .max = 3300000,
7575
};
7676
static const struct voltage_map_desc ldo1617_voltage_map_desc = {
77-
.min = 1600, .step = 100, .max = 3600,
77+
.min = 1600000, .step = 100000, .max = 3600000,
7878
};
7979
static const struct voltage_map_desc buck12_voltage_map_desc = {
80-
.min = 750, .step = 25, .max = 1525,
80+
.min = 750000, .step = 25000, .max = 1525000,
8181
};
8282
static const struct voltage_map_desc buck3_voltage_map_desc = {
83-
.min = 1600, .step = 100, .max = 3600,
83+
.min = 1600000, .step = 100000, .max = 3600000,
8484
};
8585
static const struct voltage_map_desc buck4_voltage_map_desc = {
86-
.min = 800, .step = 100, .max = 2300,
86+
.min = 800000, .step = 100000, .max = 2300000,
8787
};
8888

8989
static const struct voltage_map_desc *ldo_voltage_map[] = {
@@ -445,9 +445,9 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,
445445
if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
446446
return 0;
447447

448-
difference = (new_selector - old_selector) * desc->step;
448+
difference = (new_selector - old_selector) * desc->step / 1000;
449449
if (difference > 0)
450-
return difference / ((val & 0x0f) + 1);
450+
return DIV_ROUND_UP(difference, (val & 0x0f) + 1);
451451

452452
return 0;
453453
}
@@ -702,7 +702,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
702702
i = 0;
703703
while (buck12_voltage_map_desc.min +
704704
buck12_voltage_map_desc.step*i
705-
< (pdata->buck1_voltage1 / 1000))
705+
< pdata->buck1_voltage1)
706706
i++;
707707
max8998->buck1_vol[0] = i;
708708
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
@@ -713,7 +713,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
713713
i = 0;
714714
while (buck12_voltage_map_desc.min +
715715
buck12_voltage_map_desc.step*i
716-
< (pdata->buck1_voltage2 / 1000))
716+
< pdata->buck1_voltage2)
717717
i++;
718718

719719
max8998->buck1_vol[1] = i;
@@ -725,7 +725,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
725725
i = 0;
726726
while (buck12_voltage_map_desc.min +
727727
buck12_voltage_map_desc.step*i
728-
< (pdata->buck1_voltage3 / 1000))
728+
< pdata->buck1_voltage3)
729729
i++;
730730

731731
max8998->buck1_vol[2] = i;
@@ -737,7 +737,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
737737
i = 0;
738738
while (buck12_voltage_map_desc.min +
739739
buck12_voltage_map_desc.step*i
740-
< (pdata->buck1_voltage4 / 1000))
740+
< pdata->buck1_voltage4)
741741
i++;
742742

743743
max8998->buck1_vol[3] = i;
@@ -763,7 +763,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
763763
i = 0;
764764
while (buck12_voltage_map_desc.min +
765765
buck12_voltage_map_desc.step*i
766-
< (pdata->buck2_voltage1 / 1000))
766+
< pdata->buck2_voltage1)
767767
i++;
768768
max8998->buck2_vol[0] = i;
769769
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
@@ -774,7 +774,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
774774
i = 0;
775775
while (buck12_voltage_map_desc.min +
776776
buck12_voltage_map_desc.step*i
777-
< (pdata->buck2_voltage2 / 1000))
777+
< pdata->buck2_voltage2)
778778
i++;
779779
max8998->buck2_vol[1] = i;
780780
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
@@ -792,8 +792,8 @@ static int max8998_pmic_probe(struct platform_device *pdev)
792792
int count = (desc->max - desc->min) / desc->step + 1;
793793

794794
regulators[index].n_voltages = count;
795-
regulators[index].min_uV = desc->min * 1000;
796-
regulators[index].uV_step = desc->step * 1000;
795+
regulators[index].min_uV = desc->min;
796+
regulators[index].uV_step = desc->step;
797797
}
798798

799799
config.dev = max8998->dev;

drivers/regulator/s5m8767.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev)
214214
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
215215
int ret, reg;
216216
int mask = 0xc0, enable_ctrl;
217-
u8 val;
217+
unsigned int val;
218218

219219
ret = s5m8767_get_register(rdev, &reg, &enable_ctrl);
220220
if (ret == -EINVAL)
@@ -306,7 +306,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
306306
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
307307
int reg, mask, ret;
308308
int reg_id = rdev_get_id(rdev);
309-
u8 val;
309+
unsigned int val;
310310

311311
ret = s5m8767_get_voltage_register(rdev, &reg);
312312
if (ret)

0 commit comments

Comments
 (0)