-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv12-0002-pm-add-to_power_supply-macro-to-the-API.patch
97 lines (83 loc) · 3.29 KB
/
v12-0002-pm-add-to_power_supply-macro-to-the-API.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From ab6a3195d1c99a0d21d22398a94ce9e8511483a8 Mon Sep 17 00:00:00 2001
From: Ognjen Galic <[email protected]>
Date: Wed, 3 Jan 2018 11:18:51 +0100
Subject: [PATCH v12 2/4] pm: 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 <[email protected]>
Signed-off-by: Ognjen Galic <[email protected]>
---
Notes:
v9:
* Split the pm changes from the thinkpad_acpi patch
into its own patch
v10:
* No changes in this patch in v10
v11:
* Fix changelog formatting
v12:
* Fix build issues in ds2781 and ds2780 battery drivers
drivers/power/supply/ds2780_battery.c | 5 -----
drivers/power/supply/ds2781_battery.c | 5 -----
drivers/power/supply/power_supply_core.c | 2 +-
include/linux/power_supply.h | 2 ++
4 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/power/supply/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c
index e5d81b4..370e910 100644
--- a/drivers/power/supply/ds2780_battery.c
+++ b/drivers/power/supply/ds2780_battery.c
@@ -56,11 +56,6 @@ to_ds2780_device_info(struct power_supply *psy)
return power_supply_get_drvdata(psy);
}
-static inline struct power_supply *to_power_supply(struct device *dev)
-{
- return dev_get_drvdata(dev);
-}
-
static inline int ds2780_battery_io(struct ds2780_device_info *dev_info,
char *buf, int addr, size_t count, int io)
{
diff --git a/drivers/power/supply/ds2781_battery.c b/drivers/power/supply/ds2781_battery.c
index efe83ef..d1b5a19 100644
--- a/drivers/power/supply/ds2781_battery.c
+++ b/drivers/power/supply/ds2781_battery.c
@@ -54,11 +54,6 @@ to_ds2781_device_info(struct power_supply *psy)
return power_supply_get_drvdata(psy);
}
-static inline struct power_supply *to_power_supply(struct device *dev)
-{
- return dev_get_drvdata(dev);
-}
-
static inline int ds2781_battery_io(struct ds2781_device_info *dev_info,
char *buf, int addr, size_t count, int io)
{
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 82f998a..feac7b0 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -668,7 +668,7 @@ EXPORT_SYMBOL_GPL(power_supply_powers);
static void power_supply_dev_release(struct device *dev)
{
- struct power_supply *psy = container_of(dev, struct power_supply, dev);
+ struct power_supply *psy = to_power_supply(dev);
dev_dbg(dev, "%s\n", __func__);
kfree(psy);
}
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 79e90b3..f0139b4 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,
extern void power_supply_unregister(struct power_supply *psy);
extern int power_supply_powers(struct power_supply *psy, struct device *dev);
+#define to_power_supply(device) container_of(device, struct power_supply, dev)
+
extern void *power_supply_get_drvdata(struct power_supply *psy);
/* For APM emulation, think legacy userspace. */
extern struct class *power_supply_class;
--
2.7.4