diff options
-rw-r--r-- | drivers/regulator/fixed-helper.c | 14 | ||||
-rw-r--r-- | include/linux/regulator/fixed.h | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c index cacd33c9d042..3aa268dfdb1d 100644 --- a/drivers/regulator/fixed-helper.c +++ b/drivers/regulator/fixed-helper.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/slab.h> | 1 | #include <linux/slab.h> |
2 | #include <linux/string.h> | ||
2 | #include <linux/platform_device.h> | 3 | #include <linux/platform_device.h> |
3 | #include <linux/regulator/machine.h> | 4 | #include <linux/regulator/machine.h> |
4 | #include <linux/regulator/fixed.h> | 5 | #include <linux/regulator/fixed.h> |
@@ -13,16 +14,18 @@ static void regulator_fixed_release(struct device *dev) | |||
13 | { | 14 | { |
14 | struct fixed_regulator_data *data = container_of(dev, | 15 | struct fixed_regulator_data *data = container_of(dev, |
15 | struct fixed_regulator_data, pdev.dev); | 16 | struct fixed_regulator_data, pdev.dev); |
17 | kfree(data->cfg.supply_name); | ||
16 | kfree(data); | 18 | kfree(data); |
17 | } | 19 | } |
18 | 20 | ||
19 | /** | 21 | /** |
20 | * regulator_register_fixed - register a no-op fixed regulator | 22 | * regulator_register_fixed_name - register a no-op fixed regulator |
21 | * @id: platform device id | 23 | * @id: platform device id |
24 | * @name: name to be used for the regulator | ||
22 | * @supplies: consumers for this regulator | 25 | * @supplies: consumers for this regulator |
23 | * @num_supplies: number of consumers | 26 | * @num_supplies: number of consumers |
24 | */ | 27 | */ |
25 | struct platform_device *regulator_register_fixed(int id, | 28 | struct platform_device *regulator_register_always_on(int id, const char *name, |
26 | struct regulator_consumer_supply *supplies, int num_supplies) | 29 | struct regulator_consumer_supply *supplies, int num_supplies) |
27 | { | 30 | { |
28 | struct fixed_regulator_data *data; | 31 | struct fixed_regulator_data *data; |
@@ -31,7 +34,12 @@ struct platform_device *regulator_register_fixed(int id, | |||
31 | if (!data) | 34 | if (!data) |
32 | return NULL; | 35 | return NULL; |
33 | 36 | ||
34 | data->cfg.supply_name = "fixed-dummy"; | 37 | data->cfg.supply_name = kstrdup(name, GFP_KERNEL); |
38 | if (!data->cfg.supply_name) { | ||
39 | kfree(data); | ||
40 | return NULL; | ||
41 | } | ||
42 | |||
35 | data->cfg.microvolts = 0; | 43 | data->cfg.microvolts = 0; |
36 | data->cfg.gpio = -EINVAL; | 44 | data->cfg.gpio = -EINVAL; |
37 | data->cfg.enabled_at_boot = 1; | 45 | data->cfg.enabled_at_boot = 1; |
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index f83f7440b488..6b9325b5e371 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h | |||
@@ -58,14 +58,17 @@ struct fixed_voltage_config { | |||
58 | struct regulator_consumer_supply; | 58 | struct regulator_consumer_supply; |
59 | 59 | ||
60 | #if IS_ENABLED(CONFIG_REGULATOR) | 60 | #if IS_ENABLED(CONFIG_REGULATOR) |
61 | struct platform_device *regulator_register_fixed(int id, | 61 | struct platform_device *regulator_register_always_on(int id, const char *name, |
62 | struct regulator_consumer_supply *supplies, int num_supplies); | 62 | struct regulator_consumer_supply *supplies, int num_supplies); |
63 | #else | 63 | #else |
64 | static inline struct platform_device *regulator_register_fixed(int id, | 64 | static inline struct platform_device *regulator_register_always_on(int id, const char *name, |
65 | struct regulator_consumer_supply *supplies, int num_supplies) | 65 | struct regulator_consumer_supply *supplies, int num_supplies) |
66 | { | 66 | { |
67 | return NULL; | 67 | return NULL; |
68 | } | 68 | } |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #define regulator_register_fixed(id, s, ns) regulator_register_always_on(id, \ | ||
72 | "fixed-dummy", s, ns) | ||
73 | |||
71 | #endif | 74 | #endif |