1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // helpers.c -- Voltage/Current Regulator framework helper functions.
5 // Copyright 2007, 2008 Wolfson Microelectronics PLC.
6 // Copyright 2008 SlimLogic Ltd.
8 #include <linux/kernel.h>
10 #include <linux/delay.h>
11 #include <linux/regmap.h>
12 #include <linux/regulator/consumer.h>
13 #include <linux/regulator/driver.h>
14 #include <linux/module.h>
19 * regulator_is_enabled_regmap - standard is_enabled() for regmap users
21 * @rdev: regulator to operate on
23 * Regulators that use regmap for their register I/O can set the
24 * enable_reg and enable_mask fields in their descriptor and then use
25 * this as their is_enabled operation, saving some code.
27 int regulator_is_enabled_regmap(struct regulator_dev
*rdev
)
32 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->enable_reg
, &val
);
36 val
&= rdev
->desc
->enable_mask
;
38 if (rdev
->desc
->enable_is_inverted
) {
39 if (rdev
->desc
->enable_val
)
40 return val
!= rdev
->desc
->enable_val
;
43 if (rdev
->desc
->enable_val
)
44 return val
== rdev
->desc
->enable_val
;
48 EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap
);
51 * regulator_enable_regmap - standard enable() for regmap users
53 * @rdev: regulator to operate on
55 * Regulators that use regmap for their register I/O can set the
56 * enable_reg and enable_mask fields in their descriptor and then use
57 * this as their enable() operation, saving some code.
59 int regulator_enable_regmap(struct regulator_dev
*rdev
)
63 if (rdev
->desc
->enable_is_inverted
) {
64 val
= rdev
->desc
->disable_val
;
66 val
= rdev
->desc
->enable_val
;
68 val
= rdev
->desc
->enable_mask
;
71 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->enable_reg
,
72 rdev
->desc
->enable_mask
, val
);
74 EXPORT_SYMBOL_GPL(regulator_enable_regmap
);
77 * regulator_disable_regmap - standard disable() for regmap users
79 * @rdev: regulator to operate on
81 * Regulators that use regmap for their register I/O can set the
82 * enable_reg and enable_mask fields in their descriptor and then use
83 * this as their disable() operation, saving some code.
85 int regulator_disable_regmap(struct regulator_dev
*rdev
)
89 if (rdev
->desc
->enable_is_inverted
) {
90 val
= rdev
->desc
->enable_val
;
92 val
= rdev
->desc
->enable_mask
;
94 val
= rdev
->desc
->disable_val
;
97 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->enable_reg
,
98 rdev
->desc
->enable_mask
, val
);
100 EXPORT_SYMBOL_GPL(regulator_disable_regmap
);
102 static int regulator_range_selector_to_index(struct regulator_dev
*rdev
,
107 if (!rdev
->desc
->linear_range_selectors
)
110 rval
&= rdev
->desc
->vsel_range_mask
;
112 for (i
= 0; i
< rdev
->desc
->n_linear_ranges
; i
++) {
113 if (rdev
->desc
->linear_range_selectors
[i
] == rval
)
120 * regulator_get_voltage_sel_pickable_regmap - pickable range get_voltage_sel
122 * @rdev: regulator to operate on
124 * Regulators that use regmap for their register I/O and use pickable
125 * ranges can set the vsel_reg, vsel_mask, vsel_range_reg and vsel_range_mask
126 * fields in their descriptor and then use this as their get_voltage_vsel
127 * operation, saving some code.
129 int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev
*rdev
)
135 unsigned int voltages
= 0;
136 const struct linear_range
*r
= rdev
->desc
->linear_ranges
;
141 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_reg
, &val
);
145 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_range_reg
, &r_val
);
149 val
&= rdev
->desc
->vsel_mask
;
150 val
>>= ffs(rdev
->desc
->vsel_mask
) - 1;
152 range
= regulator_range_selector_to_index(rdev
, r_val
);
156 voltages
= linear_range_values_in_range_array(r
, range
);
158 return val
+ voltages
;
160 EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_pickable_regmap
);
163 * regulator_set_voltage_sel_pickable_regmap - pickable range set_voltage_sel
165 * @rdev: regulator to operate on
166 * @sel: Selector to set
168 * Regulators that use regmap for their register I/O and use pickable
169 * ranges can set the vsel_reg, vsel_mask, vsel_range_reg and vsel_range_mask
170 * fields in their descriptor and then use this as their set_voltage_vsel
171 * operation, saving some code.
173 int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev
*rdev
,
178 unsigned int voltages_in_range
= 0;
180 for (i
= 0; i
< rdev
->desc
->n_linear_ranges
; i
++) {
181 const struct linear_range
*r
;
183 r
= &rdev
->desc
->linear_ranges
[i
];
184 voltages_in_range
= linear_range_values_in_range(r
);
186 if (sel
< voltages_in_range
)
188 sel
-= voltages_in_range
;
191 if (i
== rdev
->desc
->n_linear_ranges
)
194 sel
<<= ffs(rdev
->desc
->vsel_mask
) - 1;
195 sel
+= rdev
->desc
->linear_ranges
[i
].min_sel
;
197 range
= rdev
->desc
->linear_range_selectors
[i
];
199 if (rdev
->desc
->vsel_reg
== rdev
->desc
->vsel_range_reg
) {
200 ret
= regmap_update_bits(rdev
->regmap
,
201 rdev
->desc
->vsel_reg
,
202 rdev
->desc
->vsel_range_mask
|
203 rdev
->desc
->vsel_mask
, sel
| range
);
205 ret
= regmap_update_bits(rdev
->regmap
,
206 rdev
->desc
->vsel_range_reg
,
207 rdev
->desc
->vsel_range_mask
, range
);
211 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->vsel_reg
,
212 rdev
->desc
->vsel_mask
, sel
);
218 if (rdev
->desc
->apply_bit
)
219 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->apply_reg
,
220 rdev
->desc
->apply_bit
,
221 rdev
->desc
->apply_bit
);
224 EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_pickable_regmap
);
227 * regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users
229 * @rdev: regulator to operate on
231 * Regulators that use regmap for their register I/O can set the
232 * vsel_reg and vsel_mask fields in their descriptor and then use this
233 * as their get_voltage_vsel operation, saving some code.
235 int regulator_get_voltage_sel_regmap(struct regulator_dev
*rdev
)
240 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_reg
, &val
);
244 val
&= rdev
->desc
->vsel_mask
;
245 val
>>= ffs(rdev
->desc
->vsel_mask
) - 1;
249 EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_regmap
);
252 * regulator_set_voltage_sel_regmap - standard set_voltage_sel for regmap users
254 * @rdev: regulator to operate on
255 * @sel: Selector to set
257 * Regulators that use regmap for their register I/O can set the
258 * vsel_reg and vsel_mask fields in their descriptor and then use this
259 * as their set_voltage_vsel operation, saving some code.
261 int regulator_set_voltage_sel_regmap(struct regulator_dev
*rdev
, unsigned sel
)
265 sel
<<= ffs(rdev
->desc
->vsel_mask
) - 1;
267 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->vsel_reg
,
268 rdev
->desc
->vsel_mask
, sel
);
272 if (rdev
->desc
->apply_bit
)
273 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->apply_reg
,
274 rdev
->desc
->apply_bit
,
275 rdev
->desc
->apply_bit
);
278 EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_regmap
);
281 * regulator_map_voltage_iterate - map_voltage() based on list_voltage()
283 * @rdev: Regulator to operate on
284 * @min_uV: Lower bound for voltage
285 * @max_uV: Upper bound for voltage
287 * Drivers implementing set_voltage_sel() and list_voltage() can use
288 * this as their map_voltage() operation. It will find a suitable
289 * voltage by calling list_voltage() until it gets something in bounds
290 * for the requested voltages.
292 int regulator_map_voltage_iterate(struct regulator_dev
*rdev
,
293 int min_uV
, int max_uV
)
295 int best_val
= INT_MAX
;
299 /* Find the smallest voltage that falls within the specified
302 for (i
= 0; i
< rdev
->desc
->n_voltages
; i
++) {
303 ret
= rdev
->desc
->ops
->list_voltage(rdev
, i
);
307 if (ret
< best_val
&& ret
>= min_uV
&& ret
<= max_uV
) {
313 if (best_val
!= INT_MAX
)
318 EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate
);
321 * regulator_map_voltage_ascend - map_voltage() for ascendant voltage list
323 * @rdev: Regulator to operate on
324 * @min_uV: Lower bound for voltage
325 * @max_uV: Upper bound for voltage
327 * Drivers that have ascendant voltage list can use this as their
328 * map_voltage() operation.
330 int regulator_map_voltage_ascend(struct regulator_dev
*rdev
,
331 int min_uV
, int max_uV
)
335 for (i
= 0; i
< rdev
->desc
->n_voltages
; i
++) {
336 ret
= rdev
->desc
->ops
->list_voltage(rdev
, i
);
343 if (ret
>= min_uV
&& ret
<= max_uV
)
349 EXPORT_SYMBOL_GPL(regulator_map_voltage_ascend
);
352 * regulator_map_voltage_linear - map_voltage() for simple linear mappings
354 * @rdev: Regulator to operate on
355 * @min_uV: Lower bound for voltage
356 * @max_uV: Upper bound for voltage
358 * Drivers providing min_uV and uV_step in their regulator_desc can
359 * use this as their map_voltage() operation.
361 int regulator_map_voltage_linear(struct regulator_dev
*rdev
,
362 int min_uV
, int max_uV
)
366 /* Allow uV_step to be 0 for fixed voltage */
367 if (rdev
->desc
->n_voltages
== 1 && rdev
->desc
->uV_step
== 0) {
368 if (min_uV
<= rdev
->desc
->min_uV
&& rdev
->desc
->min_uV
<= max_uV
)
374 if (!rdev
->desc
->uV_step
) {
375 BUG_ON(!rdev
->desc
->uV_step
);
379 if (min_uV
< rdev
->desc
->min_uV
)
380 min_uV
= rdev
->desc
->min_uV
;
382 ret
= DIV_ROUND_UP(min_uV
- rdev
->desc
->min_uV
, rdev
->desc
->uV_step
);
386 ret
+= rdev
->desc
->linear_min_sel
;
388 /* Map back into a voltage to verify we're still in bounds */
389 voltage
= rdev
->desc
->ops
->list_voltage(rdev
, ret
);
390 if (voltage
< min_uV
|| voltage
> max_uV
)
395 EXPORT_SYMBOL_GPL(regulator_map_voltage_linear
);
398 * regulator_map_voltage_linear_range - map_voltage() for multiple linear ranges
400 * @rdev: Regulator to operate on
401 * @min_uV: Lower bound for voltage
402 * @max_uV: Upper bound for voltage
404 * Drivers providing linear_ranges in their descriptor can use this as
405 * their map_voltage() callback.
407 int regulator_map_voltage_linear_range(struct regulator_dev
*rdev
,
408 int min_uV
, int max_uV
)
410 const struct linear_range
*range
;
416 if (!rdev
->desc
->n_linear_ranges
) {
417 BUG_ON(!rdev
->desc
->n_linear_ranges
);
421 for (i
= 0; i
< rdev
->desc
->n_linear_ranges
; i
++) {
422 range
= &rdev
->desc
->linear_ranges
[i
];
424 ret
= linear_range_get_selector_high(range
, min_uV
, &sel
,
431 * Map back into a voltage to verify we're still in bounds.
432 * If we are not, then continue checking rest of the ranges.
434 voltage
= rdev
->desc
->ops
->list_voltage(rdev
, sel
);
435 if (voltage
>= min_uV
&& voltage
<= max_uV
)
439 if (i
== rdev
->desc
->n_linear_ranges
)
444 EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range
);
447 * regulator_map_voltage_pickable_linear_range - map_voltage, pickable ranges
449 * @rdev: Regulator to operate on
450 * @min_uV: Lower bound for voltage
451 * @max_uV: Upper bound for voltage
453 * Drivers providing pickable linear_ranges in their descriptor can use
454 * this as their map_voltage() callback.
456 int regulator_map_voltage_pickable_linear_range(struct regulator_dev
*rdev
,
457 int min_uV
, int max_uV
)
459 const struct linear_range
*range
;
462 unsigned int selector
= 0;
464 if (!rdev
->desc
->n_linear_ranges
) {
465 BUG_ON(!rdev
->desc
->n_linear_ranges
);
469 for (i
= 0; i
< rdev
->desc
->n_linear_ranges
; i
++) {
474 range
= &rdev
->desc
->linear_ranges
[i
];
475 linear_max_uV
= linear_range_get_max_value(range
);
477 if (!(min_uV
<= linear_max_uV
&& max_uV
>= range
->min
)) {
478 selector
+= linear_range_values_in_range(range
);
482 ret
= linear_range_get_selector_high(range
, min_uV
, &sel
,
485 selector
+= linear_range_values_in_range(range
);
489 ret
= selector
+ sel
- range
->min_sel
;
491 voltage
= rdev
->desc
->ops
->list_voltage(rdev
, ret
);
494 * Map back into a voltage to verify we're still in bounds.
495 * We may have overlapping voltage ranges. Hence we don't
496 * exit but retry until we have checked all ranges.
498 if (voltage
< min_uV
|| voltage
> max_uV
)
499 selector
+= linear_range_values_in_range(range
);
504 if (i
== rdev
->desc
->n_linear_ranges
)
509 EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range
);
512 * regulator_list_voltage_linear - List voltages with simple calculation
514 * @rdev: Regulator device
515 * @selector: Selector to convert into a voltage
517 * Regulators with a simple linear mapping between voltages and
518 * selectors can set min_uV and uV_step in the regulator descriptor
519 * and then use this function as their list_voltage() operation,
521 int regulator_list_voltage_linear(struct regulator_dev
*rdev
,
522 unsigned int selector
)
524 if (selector
>= rdev
->desc
->n_voltages
)
526 if (selector
< rdev
->desc
->linear_min_sel
)
529 selector
-= rdev
->desc
->linear_min_sel
;
531 return rdev
->desc
->min_uV
+ (rdev
->desc
->uV_step
* selector
);
533 EXPORT_SYMBOL_GPL(regulator_list_voltage_linear
);
536 * regulator_list_voltage_pickable_linear_range - pickable range list voltages
538 * @rdev: Regulator device
539 * @selector: Selector to convert into a voltage
541 * list_voltage() operation, intended to be used by drivers utilizing pickable
544 int regulator_list_voltage_pickable_linear_range(struct regulator_dev
*rdev
,
545 unsigned int selector
)
547 const struct linear_range
*range
;
549 unsigned int all_sels
= 0;
551 if (!rdev
->desc
->n_linear_ranges
) {
552 BUG_ON(!rdev
->desc
->n_linear_ranges
);
556 for (i
= 0; i
< rdev
->desc
->n_linear_ranges
; i
++) {
557 unsigned int sel_indexes
;
559 range
= &rdev
->desc
->linear_ranges
[i
];
561 sel_indexes
= linear_range_values_in_range(range
) - 1;
563 if (all_sels
+ sel_indexes
>= selector
) {
564 selector
-= all_sels
;
566 * As we see here, pickable ranges work only as
567 * long as the first selector for each pickable
568 * range is 0, and the each subsequent range for
569 * this 'pick' follow immediately at next unused
570 * selector (Eg. there is no gaps between ranges).
571 * I think this is fine but it probably should be
572 * documented. OTOH, whole pickable range stuff
573 * might benefit from some documentation
575 return range
->min
+ (range
->step
* selector
);
578 all_sels
+= (sel_indexes
+ 1);
583 EXPORT_SYMBOL_GPL(regulator_list_voltage_pickable_linear_range
);
586 * regulator_desc_list_voltage_linear_range - List voltages for linear ranges
588 * @desc: Regulator desc for regulator which volatges are to be listed
589 * @selector: Selector to convert into a voltage
591 * Regulators with a series of simple linear mappings between voltages
592 * and selectors who have set linear_ranges in the regulator descriptor
593 * can use this function prior regulator registration to list voltages.
594 * This is useful when voltages need to be listed during device-tree
597 int regulator_desc_list_voltage_linear_range(const struct regulator_desc
*desc
,
598 unsigned int selector
)
603 BUG_ON(!desc
->n_linear_ranges
);
605 ret
= linear_range_get_value_array(desc
->linear_ranges
,
606 desc
->n_linear_ranges
, selector
,
613 EXPORT_SYMBOL_GPL(regulator_desc_list_voltage_linear_range
);
616 * regulator_list_voltage_linear_range - List voltages for linear ranges
618 * @rdev: Regulator device
619 * @selector: Selector to convert into a voltage
621 * Regulators with a series of simple linear mappings between voltages
622 * and selectors can set linear_ranges in the regulator descriptor and
623 * then use this function as their list_voltage() operation,
625 int regulator_list_voltage_linear_range(struct regulator_dev
*rdev
,
626 unsigned int selector
)
628 return regulator_desc_list_voltage_linear_range(rdev
->desc
, selector
);
630 EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range
);
633 * regulator_list_voltage_table - List voltages with table based mapping
635 * @rdev: Regulator device
636 * @selector: Selector to convert into a voltage
638 * Regulators with table based mapping between voltages and
639 * selectors can set volt_table in the regulator descriptor
640 * and then use this function as their list_voltage() operation.
642 int regulator_list_voltage_table(struct regulator_dev
*rdev
,
643 unsigned int selector
)
645 if (!rdev
->desc
->volt_table
) {
646 BUG_ON(!rdev
->desc
->volt_table
);
650 if (selector
>= rdev
->desc
->n_voltages
)
652 if (selector
< rdev
->desc
->linear_min_sel
)
655 return rdev
->desc
->volt_table
[selector
];
657 EXPORT_SYMBOL_GPL(regulator_list_voltage_table
);
660 * regulator_set_bypass_regmap - Default set_bypass() using regmap
662 * @rdev: device to operate on.
663 * @enable: state to set.
665 int regulator_set_bypass_regmap(struct regulator_dev
*rdev
, bool enable
)
670 val
= rdev
->desc
->bypass_val_on
;
672 val
= rdev
->desc
->bypass_mask
;
674 val
= rdev
->desc
->bypass_val_off
;
677 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->bypass_reg
,
678 rdev
->desc
->bypass_mask
, val
);
680 EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap
);
683 * regulator_set_soft_start_regmap - Default set_soft_start() using regmap
685 * @rdev: device to operate on.
687 int regulator_set_soft_start_regmap(struct regulator_dev
*rdev
)
691 val
= rdev
->desc
->soft_start_val_on
;
693 val
= rdev
->desc
->soft_start_mask
;
695 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->soft_start_reg
,
696 rdev
->desc
->soft_start_mask
, val
);
698 EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap
);
701 * regulator_set_pull_down_regmap - Default set_pull_down() using regmap
703 * @rdev: device to operate on.
705 int regulator_set_pull_down_regmap(struct regulator_dev
*rdev
)
709 val
= rdev
->desc
->pull_down_val_on
;
711 val
= rdev
->desc
->pull_down_mask
;
713 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->pull_down_reg
,
714 rdev
->desc
->pull_down_mask
, val
);
716 EXPORT_SYMBOL_GPL(regulator_set_pull_down_regmap
);
719 * regulator_get_bypass_regmap - Default get_bypass() using regmap
721 * @rdev: device to operate on.
722 * @enable: current state.
724 int regulator_get_bypass_regmap(struct regulator_dev
*rdev
, bool *enable
)
727 unsigned int val_on
= rdev
->desc
->bypass_val_on
;
730 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->bypass_reg
, &val
);
735 val_on
= rdev
->desc
->bypass_mask
;
737 *enable
= (val
& rdev
->desc
->bypass_mask
) == val_on
;
741 EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap
);
744 * regulator_set_active_discharge_regmap - Default set_active_discharge()
747 * @rdev: device to operate on.
748 * @enable: state to set, 0 to disable and 1 to enable.
750 int regulator_set_active_discharge_regmap(struct regulator_dev
*rdev
,
756 val
= rdev
->desc
->active_discharge_on
;
758 val
= rdev
->desc
->active_discharge_off
;
760 return regmap_update_bits(rdev
->regmap
,
761 rdev
->desc
->active_discharge_reg
,
762 rdev
->desc
->active_discharge_mask
, val
);
764 EXPORT_SYMBOL_GPL(regulator_set_active_discharge_regmap
);
767 * regulator_set_current_limit_regmap - set_current_limit for regmap users
769 * @rdev: regulator to operate on
770 * @min_uA: Lower bound for current limit
771 * @max_uA: Upper bound for current limit
773 * Regulators that use regmap for their register I/O can set curr_table,
774 * csel_reg and csel_mask fields in their descriptor and then use this
775 * as their set_current_limit operation, saving some code.
777 int regulator_set_current_limit_regmap(struct regulator_dev
*rdev
,
778 int min_uA
, int max_uA
)
780 unsigned int n_currents
= rdev
->desc
->n_current_limits
;
786 if (rdev
->desc
->curr_table
) {
787 const unsigned int *curr_table
= rdev
->desc
->curr_table
;
788 bool ascend
= curr_table
[n_currents
- 1] > curr_table
[0];
790 /* search for closest to maximum */
792 for (i
= n_currents
- 1; i
>= 0; i
--) {
793 if (min_uA
<= curr_table
[i
] &&
794 curr_table
[i
] <= max_uA
) {
800 for (i
= 0; i
< n_currents
; i
++) {
801 if (min_uA
<= curr_table
[i
] &&
802 curr_table
[i
] <= max_uA
) {
813 sel
<<= ffs(rdev
->desc
->csel_mask
) - 1;
815 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->csel_reg
,
816 rdev
->desc
->csel_mask
, sel
);
818 EXPORT_SYMBOL_GPL(regulator_set_current_limit_regmap
);
821 * regulator_get_current_limit_regmap - get_current_limit for regmap users
823 * @rdev: regulator to operate on
825 * Regulators that use regmap for their register I/O can set the
826 * csel_reg and csel_mask fields in their descriptor and then use this
827 * as their get_current_limit operation, saving some code.
829 int regulator_get_current_limit_regmap(struct regulator_dev
*rdev
)
834 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->csel_reg
, &val
);
838 val
&= rdev
->desc
->csel_mask
;
839 val
>>= ffs(rdev
->desc
->csel_mask
) - 1;
841 if (rdev
->desc
->curr_table
) {
842 if (val
>= rdev
->desc
->n_current_limits
)
845 return rdev
->desc
->curr_table
[val
];
850 EXPORT_SYMBOL_GPL(regulator_get_current_limit_regmap
);
853 * regulator_bulk_set_supply_names - initialize the 'supply' fields in an array
854 * of regulator_bulk_data structs
856 * @consumers: array of regulator_bulk_data entries to initialize
857 * @supply_names: array of supply name strings
858 * @num_supplies: number of supply names to initialize
860 * Note: the 'consumers' array must be the size of 'num_supplies'.
862 void regulator_bulk_set_supply_names(struct regulator_bulk_data
*consumers
,
863 const char *const *supply_names
,
864 unsigned int num_supplies
)
868 for (i
= 0; i
< num_supplies
; i
++)
869 consumers
[i
].supply
= supply_names
[i
];
871 EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names
);
874 * regulator_is_equal - test whether two regulators are the same
876 * @reg1: first regulator to operate on
877 * @reg2: second regulator to operate on
879 bool regulator_is_equal(struct regulator
*reg1
, struct regulator
*reg2
)
881 return reg1
->rdev
== reg2
->rdev
;
883 EXPORT_SYMBOL_GPL(regulator_is_equal
);