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

Commit 271134ac authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power_supply: Add enum defining USB properties"

parents ef30abab 425f11de
Loading
Loading
Loading
Loading
+52 −1
Original line number Diff line number Diff line
@@ -544,7 +544,9 @@ EXPORT_SYMBOL_GPL(power_supply_is_system_supplied);

int power_supply_set_battery_charged(struct power_supply *psy)
{
	if (psy->type == POWER_SUPPLY_TYPE_BATTERY && psy->set_charged) {
	if (atomic_read(&psy->use_cnt) >= 0 &&
			psy->type == POWER_SUPPLY_TYPE_BATTERY &&
			psy->set_charged) {
		psy->set_charged(psy);
		return 0;
	}
@@ -596,6 +598,47 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np,
EXPORT_SYMBOL_GPL(power_supply_get_by_phandle);
#endif /* CONFIG_OF */

int power_supply_get_property(struct power_supply *psy,
				enum power_supply_property psp,
				union power_supply_propval *val)
{
	if (atomic_read(&psy->use_cnt) <= 0)
		return -ENODEV;

	return psy->get_property(psy, psp, val);
}
EXPORT_SYMBOL_GPL(power_supply_get_property);

int power_supply_set_property(struct power_supply *psy,
				enum power_supply_property psp,
				const union power_supply_propval *val)
{
	if (atomic_read(&psy->use_cnt) <= 0 || !psy->set_property)
		return -ENODEV;

	return psy->set_property(psy, psp, val);
}
EXPORT_SYMBOL_GPL(power_supply_set_property);

int power_supply_property_is_writeable(struct power_supply *psy,
				enum power_supply_property psp)
{
	if (atomic_read(&psy->use_cnt) <= 0 || !psy->property_is_writeable)
		return -ENODEV;

	return psy->property_is_writeable(psy, psp);
}
EXPORT_SYMBOL_GPL(power_supply_property_is_writeable);

void power_supply_external_power_changed(struct power_supply *psy)
{
	if (atomic_read(&psy->use_cnt) <= 0 || !psy->external_power_changed)
		return;

	psy->external_power_changed(psy);
}
EXPORT_SYMBOL_GPL(power_supply_external_power_changed);

int power_supply_powers(struct power_supply *psy, struct device *dev)
{
	return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers");
@@ -783,6 +826,7 @@ static int __power_supply_register(struct device *parent,
	dev->release = power_supply_dev_release;
	dev_set_drvdata(dev, psy);
	psy->dev = dev;
	atomic_inc(&psy->use_cnt);

	rc = dev_set_name(dev, "%s", psy->name);
	if (rc)
@@ -849,6 +893,7 @@ EXPORT_SYMBOL_GPL(power_supply_register_no_ws);

void power_supply_unregister(struct power_supply *psy)
{
	WARN_ON(atomic_dec_return(&psy->use_cnt));
	cancel_work_sync(&psy->changed_work);
	sysfs_remove_link(&psy->dev->kobj, "powers");
	power_supply_remove_triggers(psy);
@@ -859,6 +904,12 @@ void power_supply_unregister(struct power_supply *psy)
}
EXPORT_SYMBOL_GPL(power_supply_unregister);

void *power_supply_get_drvdata(struct power_supply *psy)
{
	return psy->drv_data;
}
EXPORT_SYMBOL_GPL(power_supply_get_drvdata);

static int __init power_supply_class_init(void)
{
	power_supply_class = class_create(THIS_MODULE, "power_supply");
+27 −0
Original line number Diff line number Diff line
@@ -110,6 +110,13 @@ enum {
	POWER_SUPPLY_PARALLEL_MID_MID,
};

enum {
	POWER_SUPPLY_PL_NONE,
	POWER_SUPPLY_PL_USBIN_USBIN,
	POWER_SUPPLY_PL_USBIN_USBIN_EXT,
	POWER_SUPPLY_PL_USBMID_USBMID,
};

enum power_supply_property {
	/* Properties of type `int' */
	POWER_SUPPLY_PROP_STATUS = 0,
@@ -335,6 +342,12 @@ struct power_supply {
	size_t num_supplies;
	struct device_node *of_node;

	/*
	 * Functions for drivers implementing power supply class.
	 * These shouldn't be called directly by other drivers for accessing
	 * this power supply. Instead use power_supply_*() functions (for
	 * example power_supply_get_property()).
	 */
	int (*get_property)(struct power_supply *psy,
			    enum power_supply_property psp,
			    union power_supply_propval *val);
@@ -355,11 +368,15 @@ struct power_supply {
	/* For APM emulation, think legacy userspace. */
	int use_for_apm;

	/* Driver private data */
	void *drv_data;

	/* private */
	struct device *dev;
	struct work_struct changed_work;
	spinlock_t changed_lock;
	bool changed;
	atomic_t use_cnt;
#ifdef CONFIG_THERMAL
	struct thermal_zone_device *tzd;
	struct thermal_cooling_device *tcd;
@@ -420,6 +437,15 @@ extern int power_supply_is_system_supplied(void);
static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
#endif

extern int power_supply_get_property(struct power_supply *psy,
			    enum power_supply_property psp,
			    union power_supply_propval *val);
extern int power_supply_set_property(struct power_supply *psy,
			    enum power_supply_property psp,
			    const union power_supply_propval *val);
extern int power_supply_property_is_writeable(struct power_supply *psy,
					enum power_supply_property psp);
extern void power_supply_external_power_changed(struct power_supply *psy);
extern int power_supply_register(struct device *parent,
				 struct power_supply *psy);
extern int power_supply_register_no_ws(struct device *parent,
@@ -444,6 +470,7 @@ extern int power_supply_set_dp_dm(struct power_supply *psy,
							int value);
extern int power_supply_is_system_supplied(void);
extern int power_supply_set_scope(struct power_supply *psy, int scope);
extern void *power_supply_get_drvdata(struct power_supply *psy);
/* For APM emulation, think legacy userspace. */
extern struct class *power_supply_class;