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

Commit 5df7b70a authored by David Keitel's avatar David Keitel
Browse files

power: core: add set_voltage_limit API



Add the power_supply_set_voltage_limit API which
allows the POWER_SUPPLY_PROP_VOLTAGE_MAX property
to be configured for a given power supply.

CRs-Fixed: 637169
Change-Id: Ib525366ff742ad31d81ffee75920c19a6f9e8de8
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent 7b3692a8
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -52,6 +52,28 @@ static bool __power_supply_is_supplied_by(struct power_supply *supplier,
	return false;
}

/**
 * power_supply_set_voltage_limit - set current limit
 * @psy:	the power supply to control
 * @limit:	current limit in uV from the power supply.
 *		0 will disable the power supply.
 *
 * This function will set a maximum supply current from a source
 * and it will disable the charger when limit is 0.
 */
int power_supply_set_voltage_limit(struct power_supply *psy, int limit)
{
	const union power_supply_propval ret = {limit,};

	if (psy->set_property)
		return psy->set_property(psy, POWER_SUPPLY_PROP_VOLTAGE_MAX,
								&ret);

	return -ENXIO;
}
EXPORT_SYMBOL(power_supply_set_voltage_limit);


/**
 * power_supply_set_current_limit - set current limit
 * @psy:	the power supply to control
+4 −0
Original line number Diff line number Diff line
@@ -261,6 +261,7 @@ extern void power_supply_changed(struct power_supply *psy);
extern int power_supply_am_i_supplied(struct power_supply *psy);
extern int power_supply_set_battery_charged(struct power_supply *psy);
extern int power_supply_set_current_limit(struct power_supply *psy, int limit);
extern int power_supply_set_voltage_limit(struct power_supply *psy, int limit);
extern int power_supply_set_online(struct power_supply *psy, bool enable);
extern int power_supply_set_health_state(struct power_supply *psy, int health);
extern int power_supply_set_present(struct power_supply *psy, bool enable);
@@ -281,6 +282,9 @@ static inline int power_supply_am_i_supplied(struct power_supply *psy)
							{ return -ENOSYS; }
static inline int power_supply_set_battery_charged(struct power_supply *psy)
							{ return -ENOSYS; }
static inline int power_supply_set_voltage_limit(struct power_supply *psy,
							int limit)
							{ return -ENOSYS; }
static inline int power_supply_set_current_limit(struct power_supply *psy,
							int limit)
							{ return -ENOSYS; }