There are many regulator consumers who - before using the regulator bulk functions - set the supply names in regulator_bulk_data using a for loop. Let's provide a simple helper in the consumer API that allows users to do the same with a single function call.
Unified · Split
| @@ -860,3 +860,24 @@ int regulator_get_current_limit_regmap(struct regulator_dev *rdev) · 859 unmodified lines | |||
| 860 | return -EINVAL; | 860 | return -EINVAL; |
| 861 | } | 861 | } |
| 862 | EXPORT_SYMBOL_GPL(regulator_get_current_limit_regmap); | 862 | EXPORT_SYMBOL_GPL(regulator_get_current_limit_regmap); |
| 863 | |||
| 864 | /** | ||
| 865 | * regulator_bulk_set_supply_names - initialize the 'supply' fields in an array | ||
| 866 | * of regulator_bulk_data structs | ||
| 867 | * | ||
| 868 | * @consumers: array of regulator_bulk_data entries to initialize | ||
| 869 | * @supply_names: array of supply name strings | ||
| 870 | * @num_supplies: number of supply names to initialize | ||
| 871 | * | ||
| 872 | * Note: the 'consumers' array must be the size of 'num_supplies'. | ||
| 873 | */ | ||
| 874 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | ||
| 875 | const char *const *supply_names, | ||
| 876 | unsigned int num_supplies) | ||
| 877 | { | ||
| 878 | unsigned int i; | ||
| 879 | |||
| 880 | for (i = 0; i < num_supplies; i++) | ||
| 881 | consumers[i].supply = supply_names[i]; | ||
| 882 | } | ||
| 883 | EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names); | ||
| @@ -281,6 +281,12 @@ void devm_regulator_unregister_notifier(struct regulator *regulator, · 280 unmodified lines | |||
| 281 | void *regulator_get_drvdata(struct regulator *regulator); | 281 | void *regulator_get_drvdata(struct regulator *regulator); |
| 282 | void regulator_set_drvdata(struct regulator *regulator, void *data); | 282 | void regulator_set_drvdata(struct regulator *regulator, void *data); |
| 283 | 283 | ||
| 284 | /* misc helpers */ | ||
| 285 | |||
| 286 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | ||
| 287 | const char *const *supply_names, | ||
| 288 | unsigned int num_supplies); | ||
| 289 | |||
| 284 | #else | 290 | #else |
| 285 | 291 | ||
| 286 | /* | 292 | /* |
| @@ -580,6 +586,12 @@ static inline int regulator_list_voltage(struct regulator *regulator, unsigned s · 293 unmodified lines | |||
| 580 | return -EINVAL; | 586 | return -EINVAL; |
| 581 | } | 587 | } |
| 582 | 588 | ||
| 589 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | ||
| 590 | const char *const *supply_names, | ||
| 591 | unsigned int num_supplies) | ||
| 592 | { | ||
| 593 | } | ||
| 594 | |||
| 583 | #endif | 595 | #endif |
| 584 | 596 | ||
| 585 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, | 597 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, |