| .. | .. |
|---|
| 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 | } |
|---|
| .. | .. |
|---|
| 185 | 192 | } |
|---|
| 186 | 193 | error = class_add_groups(class_get(cls), cls->class_groups); |
|---|
| 187 | 194 | class_put(cls); |
|---|
| 195 | + if (error) { |
|---|
| 196 | + kobject_del(&cp->subsys.kobj); |
|---|
| 197 | + kfree_const(cp->subsys.kobj.name); |
|---|
| 198 | + kfree(cp); |
|---|
| 199 | + } |
|---|
| 188 | 200 | return error; |
|---|
| 189 | 201 | } |
|---|
| 190 | 202 | EXPORT_SYMBOL_GPL(__class_register); |
|---|
| .. | .. |
|---|
| 277 | 289 | struct klist_node *start_knode = NULL; |
|---|
| 278 | 290 | |
|---|
| 279 | 291 | if (start) |
|---|
| 280 | | - start_knode = &start->knode_class; |
|---|
| 292 | + start_knode = &start->p->knode_class; |
|---|
| 281 | 293 | klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode); |
|---|
| 282 | 294 | iter->type = type; |
|---|
| 283 | 295 | } |
|---|
| .. | .. |
|---|
| 304 | 316 | knode = klist_next(&iter->ki); |
|---|
| 305 | 317 | if (!knode) |
|---|
| 306 | 318 | return NULL; |
|---|
| 307 | | - dev = container_of(knode, struct device, knode_class); |
|---|
| 319 | + dev = klist_class_to_dev(knode); |
|---|
| 308 | 320 | if (!iter->type || iter->type == dev->type) |
|---|
| 309 | 321 | return dev; |
|---|
| 310 | 322 | } |
|---|
| .. | .. |
|---|
| 471 | 483 | struct class_attribute_string *cs; |
|---|
| 472 | 484 | |
|---|
| 473 | 485 | cs = container_of(attr, struct class_attribute_string, attr); |
|---|
| 474 | | - return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); |
|---|
| 486 | + return sysfs_emit(buf, "%s\n", cs->str); |
|---|
| 475 | 487 | } |
|---|
| 476 | 488 | |
|---|
| 477 | 489 | EXPORT_SYMBOL_GPL(show_class_attr_string); |
|---|