| .. | .. |
|---|
| 8 | 8 | * Copyright (c) 2003-2004 IBM Corp. |
|---|
| 9 | 9 | */ |
|---|
| 10 | 10 | |
|---|
| 11 | +#include <linux/device/class.h> |
|---|
| 11 | 12 | #include <linux/device.h> |
|---|
| 12 | 13 | #include <linux/module.h> |
|---|
| 13 | 14 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 117 | 118 | kset_put(&cls->p->subsys); |
|---|
| 118 | 119 | } |
|---|
| 119 | 120 | |
|---|
| 121 | +static struct device *klist_class_to_dev(struct klist_node *n) |
|---|
| 122 | +{ |
|---|
| 123 | + struct device_private *p = to_device_private_class(n); |
|---|
| 124 | + return p->device; |
|---|
| 125 | +} |
|---|
| 126 | + |
|---|
| 120 | 127 | static void klist_class_dev_get(struct klist_node *n) |
|---|
| 121 | 128 | { |
|---|
| 122 | | - struct device *dev = container_of(n, struct device, knode_class); |
|---|
| 129 | + struct device *dev = klist_class_to_dev(n); |
|---|
| 123 | 130 | |
|---|
| 124 | 131 | get_device(dev); |
|---|
| 125 | 132 | } |
|---|
| 126 | 133 | |
|---|
| 127 | 134 | static void klist_class_dev_put(struct klist_node *n) |
|---|
| 128 | 135 | { |
|---|
| 129 | | - struct device *dev = container_of(n, struct device, knode_class); |
|---|
| 136 | + struct device *dev = klist_class_to_dev(n); |
|---|
| 130 | 137 | |
|---|
| 131 | 138 | put_device(dev); |
|---|
| 132 | 139 | } |
|---|
| .. | .. |
|---|
| 277 | 284 | struct klist_node *start_knode = NULL; |
|---|
| 278 | 285 | |
|---|
| 279 | 286 | if (start) |
|---|
| 280 | | - start_knode = &start->knode_class; |
|---|
| 287 | + start_knode = &start->p->knode_class; |
|---|
| 281 | 288 | klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode); |
|---|
| 282 | 289 | iter->type = type; |
|---|
| 283 | 290 | } |
|---|
| .. | .. |
|---|
| 304 | 311 | knode = klist_next(&iter->ki); |
|---|
| 305 | 312 | if (!knode) |
|---|
| 306 | 313 | return NULL; |
|---|
| 307 | | - dev = container_of(knode, struct device, knode_class); |
|---|
| 314 | + dev = klist_class_to_dev(knode); |
|---|
| 308 | 315 | if (!iter->type || iter->type == dev->type) |
|---|
| 309 | 316 | return dev; |
|---|
| 310 | 317 | } |
|---|
| .. | .. |
|---|
| 471 | 478 | struct class_attribute_string *cs; |
|---|
| 472 | 479 | |
|---|
| 473 | 480 | cs = container_of(attr, struct class_attribute_string, attr); |
|---|
| 474 | | - return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); |
|---|
| 481 | + return sysfs_emit(buf, "%s\n", cs->str); |
|---|
| 475 | 482 | } |
|---|
| 476 | 483 | |
|---|
| 477 | 484 | EXPORT_SYMBOL_GPL(show_class_attr_string); |
|---|