Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: consumer.rst: document bulk operations

The current consumer documentation does not include bulk operations,
providing an example of how to acquire multiple regulators by calling
regulator_get() multiple times. That solution is valid and slightly
simpler for a small amount of regulators, but it does not scale well.

Document the bulk operations to get, enable and disable regulators.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20250819-reg_consumer_doc-v1-1-b631fc0d35a3@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Javier Carrasco and committed by
Mark Brown
ec0be3cd f7f80463

+26 -4
+26 -4
Documentation/power/regulator/consumer.rst
··· 23 23 regulator_put(regulator); 24 24 25 25 Consumers can be supplied by more than one regulator e.g. codec consumer with 26 - analog and digital supplies :: 26 + analog and digital supplies by means of bulk operations :: 27 27 28 - digital = regulator_get(dev, "Vcc"); /* digital core */ 29 - analog = regulator_get(dev, "Avdd"); /* analog */ 28 + struct regulator_bulk_data supplies[2]; 29 + 30 + supplies[0].supply = "Vcc"; /* digital core */ 31 + supplies[1].supply = "Avdd"; /* analog */ 32 + 33 + ret = regulator_bulk_get(dev, ARRAY_SIZE(supplies), supplies); 34 + 35 + // convenience helper to call regulator_put() on multiple regulators 36 + regulator_bulk_free(ARRAY_SIZE(supplies), supplies); 37 + 30 38 31 39 The regulator access functions regulator_get() and regulator_put() will 32 40 usually be called in your device drivers probe() and remove() respectively. ··· 59 51 60 52 This will return > zero when the regulator is enabled. 61 53 54 + A set of regulators can be enabled with a single bulk operation :: 55 + 56 + int regulator_bulk_enable(int num_consumers, 57 + struct regulator_bulk_data *consumers); 58 + 62 59 63 60 A consumer can disable its supply when no longer needed by calling:: 64 61 65 62 int regulator_disable(regulator); 63 + 64 + Or a number of them :: 65 + 66 + int regulator_bulk_disable(int num_consumers, 67 + struct regulator_bulk_data *consumers); 66 68 67 69 NOTE: 68 70 This may not disable the supply if it's shared with other consumers. The ··· 82 64 83 65 int regulator_force_disable(regulator); 84 66 67 + This operation is also supported for multiple regulators :: 68 + 69 + int regulator_bulk_force_disable(int num_consumers, 70 + struct regulator_bulk_data *consumers); 71 + 85 72 NOTE: 86 73 this will immediately and forcefully shutdown the regulator output. All 87 74 consumers will be powered off. 88 - 89 75 90 76 3. Regulator Voltage Control & Status (dynamic drivers) 91 77 =======================================================