Skip to content

Commit 7cccbec

Browse files
committed
Merge tag 'regulator-fix-v6.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "Two things here, one is an improved fix for issues around freeing devices when registration fails which replaces a half baked fix with a more complete one which uses the device model release() function properly. The other fix is a device specific fix for mt6358, the driver said that the LDOs supported mode configuration but this is not actually the case and could cause issues" * tag 'regulator-fix-v6.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator/core: Revert "fix kobject release warning and memory leak in regulator_register()" regulator/core: regulator_register: set device->class earlier regulator: mt6358: split ops for buck and linear range LDO regulators
2 parents cdcb5d1 + 6e80096 commit 7cccbec

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

drivers/regulator/core.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5542,6 +5542,8 @@ regulator_register(struct device *dev,
55425542
goto rinse;
55435543
}
55445544
device_initialize(&rdev->dev);
5545+
dev_set_drvdata(&rdev->dev, rdev);
5546+
rdev->dev.class = &regulator_class;
55455547
spin_lock_init(&rdev->err_lock);
55465548

55475549
/*
@@ -5603,11 +5605,9 @@ regulator_register(struct device *dev,
56035605
rdev->supply_name = regulator_desc->supply_name;
56045606

56055607
/* register with sysfs */
5606-
rdev->dev.class = &regulator_class;
56075608
rdev->dev.parent = config->dev;
56085609
dev_set_name(&rdev->dev, "regulator.%lu",
56095610
(unsigned long) atomic_inc_return(&regulator_no));
5610-
dev_set_drvdata(&rdev->dev, rdev);
56115611

56125612
/* set regulator constraints */
56135613
if (init_data)
@@ -5724,15 +5724,11 @@ regulator_register(struct device *dev,
57245724
mutex_lock(&regulator_list_mutex);
57255725
regulator_ena_gpio_free(rdev);
57265726
mutex_unlock(&regulator_list_mutex);
5727-
put_device(&rdev->dev);
5728-
rdev = NULL;
57295727
clean:
57305728
if (dangling_of_gpiod)
57315729
gpiod_put(config->ena_gpiod);
5732-
if (rdev && rdev->dev.of_node)
5733-
of_node_put(rdev->dev.of_node);
5734-
kfree(rdev);
57355730
kfree(config);
5731+
put_device(&rdev->dev);
57365732
rinse:
57375733
if (dangling_cfg_gpiod)
57385734
gpiod_put(cfg->ena_gpiod);

drivers/regulator/mt6358-regulator.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct mt6358_regulator_info {
4343
.desc = { \
4444
.name = #vreg, \
4545
.of_match = of_match_ptr(match), \
46-
.ops = &mt6358_volt_range_ops, \
46+
.ops = &mt6358_buck_ops, \
4747
.type = REGULATOR_VOLTAGE, \
4848
.id = MT6358_ID_##vreg, \
4949
.owner = THIS_MODULE, \
@@ -139,7 +139,7 @@ struct mt6358_regulator_info {
139139
.desc = { \
140140
.name = #vreg, \
141141
.of_match = of_match_ptr(match), \
142-
.ops = &mt6358_volt_range_ops, \
142+
.ops = &mt6358_buck_ops, \
143143
.type = REGULATOR_VOLTAGE, \
144144
.id = MT6366_ID_##vreg, \
145145
.owner = THIS_MODULE, \
@@ -450,7 +450,7 @@ static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev)
450450
}
451451
}
452452

453-
static const struct regulator_ops mt6358_volt_range_ops = {
453+
static const struct regulator_ops mt6358_buck_ops = {
454454
.list_voltage = regulator_list_voltage_linear,
455455
.map_voltage = regulator_map_voltage_linear,
456456
.set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -464,6 +464,18 @@ static const struct regulator_ops mt6358_volt_range_ops = {
464464
.get_mode = mt6358_regulator_get_mode,
465465
};
466466

467+
static const struct regulator_ops mt6358_volt_range_ops = {
468+
.list_voltage = regulator_list_voltage_linear,
469+
.map_voltage = regulator_map_voltage_linear,
470+
.set_voltage_sel = regulator_set_voltage_sel_regmap,
471+
.get_voltage_sel = mt6358_get_buck_voltage_sel,
472+
.set_voltage_time_sel = regulator_set_voltage_time_sel,
473+
.enable = regulator_enable_regmap,
474+
.disable = regulator_disable_regmap,
475+
.is_enabled = regulator_is_enabled_regmap,
476+
.get_status = mt6358_get_status,
477+
};
478+
467479
static const struct regulator_ops mt6358_volt_table_ops = {
468480
.list_voltage = regulator_list_voltage_table,
469481
.map_voltage = regulator_map_voltage_iterate,

0 commit comments

Comments
 (0)