|
19 | 19 |
|
20 | 20 | #include "counter-sysfs.h" |
21 | 21 |
|
| 22 | +static inline struct counter_device *counter_from_dev(struct device *dev) |
| 23 | +{ |
| 24 | + return container_of(dev, struct counter_device, dev); |
| 25 | +} |
| 26 | + |
22 | 27 | /** |
23 | 28 | * struct counter_attribute - Counter sysfs attribute |
24 | 29 | * @dev_attr: device attribute for sysfs |
@@ -90,7 +95,7 @@ static ssize_t counter_comp_u8_show(struct device *dev, |
90 | 95 | struct device_attribute *attr, char *buf) |
91 | 96 | { |
92 | 97 | const struct counter_attribute *const a = to_counter_attribute(attr); |
93 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 98 | + struct counter_device *const counter = counter_from_dev(dev); |
94 | 99 | int err; |
95 | 100 | u8 data = 0; |
96 | 101 |
|
@@ -122,7 +127,7 @@ static ssize_t counter_comp_u8_store(struct device *dev, |
122 | 127 | const char *buf, size_t len) |
123 | 128 | { |
124 | 129 | const struct counter_attribute *const a = to_counter_attribute(attr); |
125 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 130 | + struct counter_device *const counter = counter_from_dev(dev); |
126 | 131 | int err; |
127 | 132 | bool bool_data = 0; |
128 | 133 | u8 data = 0; |
@@ -158,7 +163,7 @@ static ssize_t counter_comp_u32_show(struct device *dev, |
158 | 163 | struct device_attribute *attr, char *buf) |
159 | 164 | { |
160 | 165 | const struct counter_attribute *const a = to_counter_attribute(attr); |
161 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 166 | + struct counter_device *const counter = counter_from_dev(dev); |
162 | 167 | const struct counter_available *const avail = a->comp.priv; |
163 | 168 | int err; |
164 | 169 | u32 data = 0; |
@@ -221,7 +226,7 @@ static ssize_t counter_comp_u32_store(struct device *dev, |
221 | 226 | const char *buf, size_t len) |
222 | 227 | { |
223 | 228 | const struct counter_attribute *const a = to_counter_attribute(attr); |
224 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 229 | + struct counter_device *const counter = counter_from_dev(dev); |
225 | 230 | struct counter_count *const count = a->parent; |
226 | 231 | struct counter_synapse *const synapse = a->comp.priv; |
227 | 232 | const struct counter_available *const avail = a->comp.priv; |
@@ -281,7 +286,7 @@ static ssize_t counter_comp_u64_show(struct device *dev, |
281 | 286 | struct device_attribute *attr, char *buf) |
282 | 287 | { |
283 | 288 | const struct counter_attribute *const a = to_counter_attribute(attr); |
284 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 289 | + struct counter_device *const counter = counter_from_dev(dev); |
285 | 290 | int err; |
286 | 291 | u64 data = 0; |
287 | 292 |
|
@@ -309,7 +314,7 @@ static ssize_t counter_comp_u64_store(struct device *dev, |
309 | 314 | const char *buf, size_t len) |
310 | 315 | { |
311 | 316 | const struct counter_attribute *const a = to_counter_attribute(attr); |
312 | | - struct counter_device *const counter = dev_get_drvdata(dev); |
| 317 | + struct counter_device *const counter = counter_from_dev(dev); |
313 | 318 | int err; |
314 | 319 | u64 data = 0; |
315 | 320 |
|
|
0 commit comments