| Sascha Hauer | 613330a | 2012-03-03 12:40:02 +0100 | [diff] [blame] | 1 | #include <linux/slab.h> | 
 | 2 | #include <linux/platform_device.h> | 
 | 3 | #include <linux/regulator/machine.h> | 
 | 4 | #include <linux/regulator/fixed.h> | 
 | 5 |  | 
 | 6 | struct fixed_regulator_data { | 
 | 7 | 	struct fixed_voltage_config cfg; | 
 | 8 | 	struct regulator_init_data init_data; | 
 | 9 | 	struct platform_device pdev; | 
 | 10 | }; | 
 | 11 |  | 
 | 12 | static void regulator_fixed_release(struct device *dev) | 
 | 13 | { | 
 | 14 | 	struct fixed_regulator_data *data = container_of(dev, | 
 | 15 | 			struct fixed_regulator_data, pdev.dev); | 
 | 16 | 	kfree(data); | 
 | 17 | } | 
 | 18 |  | 
 | 19 | /** | 
 | 20 |  * regulator_register_fixed - register a no-op fixed regulator | 
| Sascha Hauer | 613330a | 2012-03-03 12:40:02 +0100 | [diff] [blame] | 21 |  * @id: platform device id | 
 | 22 |  * @supplies: consumers for this regulator | 
 | 23 |  * @num_supplies: number of consumers | 
 | 24 |  */ | 
 | 25 | struct platform_device *regulator_register_fixed(int id, | 
 | 26 | 		struct regulator_consumer_supply *supplies, int num_supplies) | 
 | 27 | { | 
 | 28 | 	struct fixed_regulator_data *data; | 
 | 29 |  | 
 | 30 | 	data = kzalloc(sizeof(*data), GFP_KERNEL); | 
 | 31 | 	if (!data) | 
 | 32 | 		return NULL; | 
 | 33 |  | 
| Shawn Guo | 5f12760 | 2012-03-31 16:33:31 +0800 | [diff] [blame] | 34 | 	data->cfg.supply_name = "fixed-dummy"; | 
| Sascha Hauer | 613330a | 2012-03-03 12:40:02 +0100 | [diff] [blame] | 35 | 	data->cfg.microvolts = 0; | 
 | 36 | 	data->cfg.gpio = -EINVAL; | 
 | 37 | 	data->cfg.enabled_at_boot = 1; | 
 | 38 | 	data->cfg.init_data = &data->init_data; | 
 | 39 |  | 
 | 40 | 	data->init_data.constraints.always_on = 1; | 
 | 41 | 	data->init_data.consumer_supplies = supplies; | 
 | 42 | 	data->init_data.num_consumer_supplies = num_supplies; | 
 | 43 |  | 
 | 44 | 	data->pdev.name = "reg-fixed-voltage"; | 
 | 45 | 	data->pdev.id = id; | 
 | 46 | 	data->pdev.dev.platform_data = &data->cfg; | 
 | 47 | 	data->pdev.dev.release = regulator_fixed_release; | 
 | 48 |  | 
 | 49 | 	platform_device_register(&data->pdev); | 
 | 50 |  | 
 | 51 | 	return &data->pdev; | 
 | 52 | } |