diff options
| author | Ognjen Galic <smclt30p@gmail.com> | 2018-02-07 09:58:27 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-02-21 17:27:13 -0500 |
| commit | 285995d15d3b1725d021a8a274e55f2ce30ccfa0 (patch) | |
| tree | 1aefa04c3ce461968403105edc9e7f5bada19475 /include/linux/power_supply.h | |
| parent | fa93854f7a7ed63d054405bf3779247d5300edd3 (diff) | |
power: add to_power_supply macro to the API
This patch adds the to_power_supply macro to upcast
a device to a power_supply struct.
This is needed because the same piece of code using
container_of is used in various other places, so we
abstract away such low-level operations via a macro.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ognjen Galic <smclt30p@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/power_supply.h')
| -rw-r--r-- | include/linux/power_supply.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 79e90b3d3288..f0139b460a72 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h | |||
| @@ -371,6 +371,8 @@ devm_power_supply_register_no_ws(struct device *parent, | |||
| 371 | extern void power_supply_unregister(struct power_supply *psy); | 371 | extern void power_supply_unregister(struct power_supply *psy); |
| 372 | extern int power_supply_powers(struct power_supply *psy, struct device *dev); | 372 | extern int power_supply_powers(struct power_supply *psy, struct device *dev); |
| 373 | 373 | ||
| 374 | #define to_power_supply(device) container_of(device, struct power_supply, dev) | ||
| 375 | |||
| 374 | extern void *power_supply_get_drvdata(struct power_supply *psy); | 376 | extern void *power_supply_get_drvdata(struct power_supply *psy); |
| 375 | /* For APM emulation, think legacy userspace. */ | 377 | /* For APM emulation, think legacy userspace. */ |
| 376 | extern struct class *power_supply_class; | 378 | extern struct class *power_supply_class; |
