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