Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
Revert "driver core: create a private portion of struct device"
Revert "driver core: move klist_children into private structure"
Revert "driver core: move knode_driver into private structure"
Revert "driver core: move knode_bus into private structure"

+38 -106
-26
drivers/base/base.h
··· 63 63 #define to_class(obj) \ 64 64 container_of(obj, struct class_private, class_subsys.kobj) 65 65 66 - /** 67 - * struct device_private - structure to hold the private to the driver core portions of the device structure. 68 - * 69 - * @klist_children - klist containing all children of this device 70 - * @knode_parent - node in sibling list 71 - * @knode_driver - node in driver list 72 - * @knode_bus - node in bus list 73 - * @device - pointer back to the struct class that this structure is 74 - * associated with. 75 - * 76 - * Nothing outside of the driver core should ever touch these fields. 77 - */ 78 - struct device_private { 79 - struct klist klist_children; 80 - struct klist_node knode_parent; 81 - struct klist_node knode_driver; 82 - struct klist_node knode_bus; 83 - struct device *device; 84 - }; 85 - #define to_device_private_parent(obj) \ 86 - container_of(obj, struct device_private, knode_parent) 87 - #define to_device_private_driver(obj) \ 88 - container_of(obj, struct device_private, knode_driver) 89 - #define to_device_private_bus(obj) \ 90 - container_of(obj, struct device_private, knode_bus) 91 - 92 66 /* initialisation functions */ 93 67 extern int devices_init(void); 94 68 extern int buses_init(void);
+13 -27
drivers/base/bus.c
··· 253 253 static struct device *next_device(struct klist_iter *i) 254 254 { 255 255 struct klist_node *n = klist_next(i); 256 - struct device *dev = NULL; 257 - struct device_private *dev_prv; 258 - 259 - if (n) { 260 - dev_prv = to_device_private_bus(n); 261 - dev = dev_prv->device; 262 - } 263 - return dev; 256 + return n ? container_of(n, struct device, knode_bus) : NULL; 264 257 } 265 258 266 259 /** ··· 286 293 return -EINVAL; 287 294 288 295 klist_iter_init_node(&bus->p->klist_devices, &i, 289 - (start ? &start->p->knode_bus : NULL)); 296 + (start ? &start->knode_bus : NULL)); 290 297 while ((dev = next_device(&i)) && !error) 291 298 error = fn(dev, data); 292 299 klist_iter_exit(&i); ··· 320 327 return NULL; 321 328 322 329 klist_iter_init_node(&bus->p->klist_devices, &i, 323 - (start ? &start->p->knode_bus : NULL)); 330 + (start ? &start->knode_bus : NULL)); 324 331 while ((dev = next_device(&i))) 325 332 if (match(dev, data) && get_device(dev)) 326 333 break; ··· 507 514 ret = device_attach(dev); 508 515 WARN_ON(ret < 0); 509 516 if (ret >= 0) 510 - klist_add_tail(&dev->p->knode_bus, 511 - &bus->p->klist_devices); 517 + klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 512 518 } 513 519 } 514 520 ··· 528 536 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 529 537 dev_name(dev)); 530 538 device_remove_attrs(dev->bus, dev); 531 - if (klist_node_attached(&dev->p->knode_bus)) 532 - klist_del(&dev->p->knode_bus); 539 + if (klist_node_attached(&dev->knode_bus)) 540 + klist_del(&dev->knode_bus); 533 541 534 542 pr_debug("bus: '%s': remove device %s\n", 535 543 dev->bus->name, dev_name(dev)); ··· 831 839 832 840 static void klist_devices_get(struct klist_node *n) 833 841 { 834 - struct device_private *dev_prv = to_device_private_bus(n); 835 - struct device *dev = dev_prv->device; 842 + struct device *dev = container_of(n, struct device, knode_bus); 836 843 837 844 get_device(dev); 838 845 } 839 846 840 847 static void klist_devices_put(struct klist_node *n) 841 848 { 842 - struct device_private *dev_prv = to_device_private_bus(n); 843 - struct device *dev = dev_prv->device; 849 + struct device *dev = container_of(n, struct device, knode_bus); 844 850 845 851 put_device(dev); 846 852 } ··· 993 1003 { 994 1004 struct list_head *pos; 995 1005 struct klist_node *n; 996 - struct device_private *dev_prv; 997 1006 struct device *b; 998 1007 999 1008 list_for_each(pos, list) { 1000 1009 n = container_of(pos, struct klist_node, n_node); 1001 - dev_prv = to_device_private_bus(n); 1002 - b = dev_prv->device; 1010 + b = container_of(n, struct device, knode_bus); 1003 1011 if (compare(a, b) <= 0) { 1004 - list_move_tail(&a->p->knode_bus.n_node, 1005 - &b->p->knode_bus.n_node); 1012 + list_move_tail(&a->knode_bus.n_node, 1013 + &b->knode_bus.n_node); 1006 1014 return; 1007 1015 } 1008 1016 } 1009 - list_move_tail(&a->p->knode_bus.n_node, list); 1017 + list_move_tail(&a->knode_bus.n_node, list); 1010 1018 } 1011 1019 1012 1020 void bus_sort_breadthfirst(struct bus_type *bus, ··· 1014 1026 LIST_HEAD(sorted_devices); 1015 1027 struct list_head *pos, *tmp; 1016 1028 struct klist_node *n; 1017 - struct device_private *dev_prv; 1018 1029 struct device *dev; 1019 1030 struct klist *device_klist; 1020 1031 ··· 1022 1035 spin_lock(&device_klist->k_lock); 1023 1036 list_for_each_safe(pos, tmp, &device_klist->k_list) { 1024 1037 n = container_of(pos, struct klist_node, n_node); 1025 - dev_prv = to_device_private_bus(n); 1026 - dev = dev_prv->device; 1038 + dev = container_of(n, struct device, knode_bus); 1027 1039 device_insertion_sort_klist(dev, &sorted_devices, compare); 1028 1040 } 1029 1041 list_splice(&sorted_devices, &device_klist->k_list);
+13 -32
drivers/base/core.c
··· 109 109 static void device_release(struct kobject *kobj) 110 110 { 111 111 struct device *dev = to_dev(kobj); 112 - struct device_private *p = dev->p; 113 112 114 113 if (dev->release) 115 114 dev->release(dev); ··· 120 121 WARN(1, KERN_ERR "Device '%s' does not have a release() " 121 122 "function, it is broken and must be fixed.\n", 122 123 dev_name(dev)); 123 - kfree(p); 124 124 } 125 125 126 126 static struct kobj_type device_ktype = { ··· 507 509 508 510 static void klist_children_get(struct klist_node *n) 509 511 { 510 - struct device_private *p = to_device_private_parent(n); 511 - struct device *dev = p->device; 512 + struct device *dev = container_of(n, struct device, knode_parent); 512 513 513 514 get_device(dev); 514 515 } 515 516 516 517 static void klist_children_put(struct klist_node *n) 517 518 { 518 - struct device_private *p = to_device_private_parent(n); 519 - struct device *dev = p->device; 519 + struct device *dev = container_of(n, struct device, knode_parent); 520 520 521 521 put_device(dev); 522 522 } ··· 536 540 */ 537 541 void device_initialize(struct device *dev) 538 542 { 539 - dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL); 540 - if (!dev->p) { 541 - WARN_ON(1); 542 - return; 543 - } 544 - dev->p->device = dev; 545 543 dev->kobj.kset = devices_kset; 546 544 kobject_init(&dev->kobj, &device_ktype); 547 - klist_init(&dev->p->klist_children, klist_children_get, 545 + klist_init(&dev->klist_children, klist_children_get, 548 546 klist_children_put); 549 547 INIT_LIST_HEAD(&dev->dma_pools); 550 548 init_MUTEX(&dev->sem); ··· 922 932 kobject_uevent(&dev->kobj, KOBJ_ADD); 923 933 bus_attach_device(dev); 924 934 if (parent) 925 - klist_add_tail(&dev->p->knode_parent, 926 - &parent->p->klist_children); 935 + klist_add_tail(&dev->knode_parent, &parent->klist_children); 927 936 928 937 if (dev->class) { 929 938 mutex_lock(&dev->class->p->class_mutex); ··· 1036 1047 device_pm_remove(dev); 1037 1048 dpm_sysfs_remove(dev); 1038 1049 if (parent) 1039 - klist_del(&dev->p->knode_parent); 1050 + klist_del(&dev->knode_parent); 1040 1051 if (MAJOR(dev->devt)) { 1041 1052 device_remove_sys_dev_entry(dev); 1042 1053 device_remove_file(dev, &devt_attr); ··· 1097 1108 static struct device *next_device(struct klist_iter *i) 1098 1109 { 1099 1110 struct klist_node *n = klist_next(i); 1100 - struct device *dev = NULL; 1101 - struct device_private *p; 1102 - 1103 - if (n) { 1104 - p = to_device_private_parent(n); 1105 - dev = p->device; 1106 - } 1107 - return dev; 1111 + return n ? container_of(n, struct device, knode_parent) : NULL; 1108 1112 } 1109 1113 1110 1114 /** ··· 1119 1137 struct device *child; 1120 1138 int error = 0; 1121 1139 1122 - klist_iter_init(&parent->p->klist_children, &i); 1140 + klist_iter_init(&parent->klist_children, &i); 1123 1141 while ((child = next_device(&i)) && !error) 1124 1142 error = fn(child, data); 1125 1143 klist_iter_exit(&i); ··· 1150 1168 if (!parent) 1151 1169 return NULL; 1152 1170 1153 - klist_iter_init(&parent->p->klist_children, &i); 1171 + klist_iter_init(&parent->klist_children, &i); 1154 1172 while ((child = next_device(&i))) 1155 1173 if (match(child, data) && get_device(child)) 1156 1174 break; ··· 1564 1582 old_parent = dev->parent; 1565 1583 dev->parent = new_parent; 1566 1584 if (old_parent) 1567 - klist_remove(&dev->p->knode_parent); 1585 + klist_remove(&dev->knode_parent); 1568 1586 if (new_parent) { 1569 - klist_add_tail(&dev->p->knode_parent, 1570 - &new_parent->p->klist_children); 1587 + klist_add_tail(&dev->knode_parent, &new_parent->klist_children); 1571 1588 set_dev_node(dev, dev_to_node(new_parent)); 1572 1589 } 1573 1590 ··· 1578 1597 device_move_class_links(dev, new_parent, old_parent); 1579 1598 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1580 1599 if (new_parent) 1581 - klist_remove(&dev->p->knode_parent); 1600 + klist_remove(&dev->knode_parent); 1582 1601 dev->parent = old_parent; 1583 1602 if (old_parent) { 1584 - klist_add_tail(&dev->p->knode_parent, 1585 - &old_parent->p->klist_children); 1603 + klist_add_tail(&dev->knode_parent, 1604 + &old_parent->klist_children); 1586 1605 set_dev_node(dev, dev_to_node(old_parent)); 1587 1606 } 1588 1607 }
+5 -8
drivers/base/dd.c
··· 28 28 29 29 static void driver_bound(struct device *dev) 30 30 { 31 - if (klist_node_attached(&dev->p->knode_driver)) { 31 + if (klist_node_attached(&dev->knode_driver)) { 32 32 printk(KERN_WARNING "%s: device %s already bound\n", 33 33 __func__, kobject_name(&dev->kobj)); 34 34 return; ··· 41 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 42 42 BUS_NOTIFY_BOUND_DRIVER, dev); 43 43 44 - klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); 44 + klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices); 45 45 } 46 46 47 47 static int driver_sysfs_add(struct device *dev) ··· 310 310 drv->remove(dev); 311 311 devres_release_all(dev); 312 312 dev->driver = NULL; 313 - klist_remove(&dev->p->knode_driver); 313 + klist_remove(&dev->knode_driver); 314 314 } 315 315 } 316 316 ··· 340 340 */ 341 341 void driver_detach(struct device_driver *drv) 342 342 { 343 - struct device_private *dev_prv; 344 343 struct device *dev; 345 344 346 345 for (;;) { ··· 348 349 spin_unlock(&drv->p->klist_devices.k_lock); 349 350 break; 350 351 } 351 - dev_prv = list_entry(drv->p->klist_devices.k_list.prev, 352 - struct device_private, 353 - knode_driver.n_node); 354 - dev = dev_prv->device; 352 + dev = list_entry(drv->p->klist_devices.k_list.prev, 353 + struct device, knode_driver.n_node); 355 354 get_device(dev); 356 355 spin_unlock(&drv->p->klist_devices.k_lock); 357 356
+3 -10
drivers/base/driver.c
··· 19 19 static struct device *next_device(struct klist_iter *i) 20 20 { 21 21 struct klist_node *n = klist_next(i); 22 - struct device *dev = NULL; 23 - struct device_private *dev_prv; 24 - 25 - if (n) { 26 - dev_prv = to_device_private_driver(n); 27 - dev = dev_prv->device; 28 - } 29 - return dev; 22 + return n ? container_of(n, struct device, knode_driver) : NULL; 30 23 } 31 24 32 25 /** ··· 42 49 return -EINVAL; 43 50 44 51 klist_iter_init_node(&drv->p->klist_devices, &i, 45 - start ? &start->p->knode_driver : NULL); 52 + start ? &start->knode_driver : NULL); 46 53 while ((dev = next_device(&i)) && !error) 47 54 error = fn(dev, data); 48 55 klist_iter_exit(&i); ··· 76 83 return NULL; 77 84 78 85 klist_iter_init_node(&drv->p->klist_devices, &i, 79 - (start ? &start->p->knode_driver : NULL)); 86 + (start ? &start->knode_driver : NULL)); 80 87 while ((dev = next_device(&i))) 81 88 if (match(dev, data) && get_device(dev)) 82 89 break;
+4 -3
include/linux/device.h
··· 28 28 #define BUS_ID_SIZE 20 29 29 30 30 struct device; 31 - struct device_private; 32 31 struct device_driver; 33 32 struct driver_private; 34 33 struct class; ··· 365 366 }; 366 367 367 368 struct device { 369 + struct klist klist_children; 370 + struct klist_node knode_parent; /* node in sibling list */ 371 + struct klist_node knode_driver; 372 + struct klist_node knode_bus; 368 373 struct device *parent; 369 - 370 - struct device_private *p; 371 374 372 375 struct kobject kobj; 373 376 char bus_id[BUS_ID_SIZE]; /* position on parent bus */