diff options
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 54def4e02f00..d8a6a5864c2e 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -117,16 +117,22 @@ static void class_put(struct class *cls) | |||
117 | kset_put(&cls->p->subsys); | 117 | kset_put(&cls->p->subsys); |
118 | } | 118 | } |
119 | 119 | ||
120 | static struct device *klist_class_to_dev(struct klist_node *n) | ||
121 | { | ||
122 | struct device_private *p = to_device_private_class(n); | ||
123 | return p->device; | ||
124 | } | ||
125 | |||
120 | static void klist_class_dev_get(struct klist_node *n) | 126 | static void klist_class_dev_get(struct klist_node *n) |
121 | { | 127 | { |
122 | struct device *dev = container_of(n, struct device, knode_class); | 128 | struct device *dev = klist_class_to_dev(n); |
123 | 129 | ||
124 | get_device(dev); | 130 | get_device(dev); |
125 | } | 131 | } |
126 | 132 | ||
127 | static void klist_class_dev_put(struct klist_node *n) | 133 | static void klist_class_dev_put(struct klist_node *n) |
128 | { | 134 | { |
129 | struct device *dev = container_of(n, struct device, knode_class); | 135 | struct device *dev = klist_class_to_dev(n); |
130 | 136 | ||
131 | put_device(dev); | 137 | put_device(dev); |
132 | } | 138 | } |
@@ -277,7 +283,7 @@ void class_dev_iter_init(struct class_dev_iter *iter, struct class *class, | |||
277 | struct klist_node *start_knode = NULL; | 283 | struct klist_node *start_knode = NULL; |
278 | 284 | ||
279 | if (start) | 285 | if (start) |
280 | start_knode = &start->knode_class; | 286 | start_knode = &start->p->knode_class; |
281 | klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode); | 287 | klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode); |
282 | iter->type = type; | 288 | iter->type = type; |
283 | } | 289 | } |
@@ -304,7 +310,7 @@ struct device *class_dev_iter_next(struct class_dev_iter *iter) | |||
304 | knode = klist_next(&iter->ki); | 310 | knode = klist_next(&iter->ki); |
305 | if (!knode) | 311 | if (!knode) |
306 | return NULL; | 312 | return NULL; |
307 | dev = container_of(knode, struct device, knode_class); | 313 | dev = klist_class_to_dev(knode); |
308 | if (!iter->type || iter->type == dev->type) | 314 | if (!iter->type || iter->type == dev->type) |
309 | return dev; | 315 | return dev; |
310 | } | 316 | } |