Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 001d62d4 authored by Justin Paupore's avatar Justin Paupore Committed by Rohit Vaswani
Browse files

regulator: Add regulator_bulk_set_voltage



Add a convenience API to set the voltage on multiple consumers
stored in a struct regulator_bulk_data[] in one API call.

Change-Id: Iaeb5ba8c357a66f1401fb1e142bb03904e8e9c7c
Signed-off-by: default avatarJustin Paupore <jpaupore@codeaurora.org>
parent d68c0879
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
@@ -3533,6 +3533,42 @@ err:
}
}
EXPORT_SYMBOL_GPL(regulator_bulk_enable);
EXPORT_SYMBOL_GPL(regulator_bulk_enable);


/**
 * regulator_bulk_set_voltage - set voltage for multiple regulator consumers
 *
 * @num_consumers: Number of consumers
 * @consumers:     Consumer data; clients are stored here.
 * @return         0 on success, an errno on failure
 *
 * This convenience API allows the voted voltage ranges of multiple regulator
 * clients to be set in a single API call. If any consumers cannot have their
 * voltages set, this function returns WITHOUT withdrawing votes for any
 * consumers that have already been set.
 */
int regulator_bulk_set_voltage(int num_consumers,
			       struct regulator_bulk_data *consumers)
{
	int i;
	int rc;

	for (i = 0; i < num_consumers; i++) {
		if (!consumers[i].min_uV && !consumers[i].max_uV)
			continue;
		rc = regulator_set_voltage(consumers[i].consumer,
				consumers[i].min_uV,
				consumers[i].max_uV);
		if (rc)
			goto err;
	}

	return 0;

err:
	pr_err("Failed to set voltage for %s: %d\n", consumers[i].supply, rc);
	return rc;
}
EXPORT_SYMBOL_GPL(regulator_bulk_set_voltage);

/**
/**
 * regulator_bulk_disable - disable multiple regulator consumers
 * regulator_bulk_disable - disable multiple regulator consumers
 *
 *
+8 −0
Original line number Original line Diff line number Diff line
@@ -144,6 +144,10 @@ struct regulator;
 *            using the bulk regulator APIs.
 *            using the bulk regulator APIs.
 * @consumer: The regulator consumer for the supply.  This will be managed
 * @consumer: The regulator consumer for the supply.  This will be managed
 *            by the bulk API.
 *            by the bulk API.
 * @min_uV:   The minimum requested voltage for the regulator (in microvolts),
 *            or 0 to not set a voltage.
 * @max_uV:   The maximum requested voltage for the regulator (in microvolts),
 *            or 0 to use @min_uV.
 *
 *
 * The regulator APIs provide a series of regulator_bulk_() API calls as
 * The regulator APIs provide a series of regulator_bulk_() API calls as
 * a convenience to consumers which require multiple supplies.  This
 * a convenience to consumers which require multiple supplies.  This
@@ -152,6 +156,8 @@ struct regulator;
struct regulator_bulk_data {
struct regulator_bulk_data {
	const char *supply;
	const char *supply;
	struct regulator *consumer;
	struct regulator *consumer;
	int min_uV;
	int max_uV;


	/* private: Internal use */
	/* private: Internal use */
	int ret;
	int ret;
@@ -216,6 +222,8 @@ int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
					 struct regulator_bulk_data *consumers);
					 struct regulator_bulk_data *consumers);
int __must_check regulator_bulk_enable(int num_consumers,
int __must_check regulator_bulk_enable(int num_consumers,
				       struct regulator_bulk_data *consumers);
				       struct regulator_bulk_data *consumers);
int regulator_bulk_set_voltage(int num_consumers,
			  struct regulator_bulk_data *consumers);
int regulator_bulk_disable(int num_consumers,
int regulator_bulk_disable(int num_consumers,
			   struct regulator_bulk_data *consumers);
			   struct regulator_bulk_data *consumers);
int regulator_bulk_force_disable(int num_consumers,
int regulator_bulk_force_disable(int num_consumers,