aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-11-01 22:41:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:33 -0500
commitc6f7e72a3f4641095ade9ded287d910c980c6148 (patch)
treed2d7d946b978ce9f5586a02c3520aa76e928a551 /drivers
parentb249072ee6897fe4f8d461c7bb4b926223263c28 (diff)
driver core: remove fields from struct bus_type
struct bus_type is static everywhere in the kernel. This moves the kobject in the structure out of it, and a bunch of other private only to the driver core fields are now moved to a private structure. This lets us dynamically create the backing kobject properly and gives us the chance to be able to document to users exactly how to use the struct bus_type as there are no fields they can improperly access. Thanks to Kay for the build fixes on this patch. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/base.h30
-rw-r--r--drivers/base/bus.c116
-rw-r--r--drivers/base/core.c6
-rw-r--r--drivers/base/dd.c4
-rw-r--r--drivers/base/driver.c2
-rw-r--r--drivers/base/platform.c4
6 files changed, 102 insertions, 60 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 7e309a49a711..ca6d273064f8 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -1,6 +1,34 @@
1 1
2/* initialisation functions */ 2/**
3 * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure.
4 *
5 * @subsys - the struct kset that defines this bus. This is the main kobject
6 * @drivers_kset - the list of drivers associated with this bus
7 * @devices_kset - the list of devices associated with this bus
8 * @klist_devices - the klist to iterate over the @devices_kset
9 * @klist_drivers - the klist to iterate over the @drivers_kset
10 * @bus_notifier - the bus notifier list for anything that cares about things
11 * on this bus.
12 * @bus - pointer back to the struct bus_type that this structure is associated
13 * with.
14 *
15 * This structure is the one that is the actual kobject allowing struct
16 * bus_type to be statically allocated safely. Nothing outside of the driver
17 * core should ever touch these fields.
18 */
19struct bus_type_private {
20 struct kset subsys;
21 struct kset *drivers_kset;
22 struct kset *devices_kset;
23 struct klist klist_devices;
24 struct klist klist_drivers;
25 struct blocking_notifier_head bus_notifier;
26 unsigned int drivers_autoprobe:1;
27 struct bus_type *bus;
28};
29
3 30
31/* initialisation functions */
4extern int devices_init(void); 32extern int devices_init(void);
5extern int buses_init(void); 33extern int buses_init(void);
6extern int classes_init(void); 34extern int classes_init(void);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 9c9027b2c44e..04d3850ff4b7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -17,7 +17,7 @@
17#include "power/power.h" 17#include "power/power.h"
18 18
19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) 19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
20#define to_bus(obj) container_of(obj, struct bus_type, subsys.kobj) 20#define to_bus(obj) container_of(obj, struct bus_type_private, subsys.kobj)
21 21
22/* 22/*
23 * sysfs bindings for drivers 23 * sysfs bindings for drivers
@@ -32,13 +32,17 @@ static int __must_check bus_rescan_devices_helper(struct device *dev,
32 32
33static struct bus_type *bus_get(struct bus_type *bus) 33static struct bus_type *bus_get(struct bus_type *bus)
34{ 34{
35 return bus ? container_of(kset_get(&bus->subsys), 35 if (bus) {
36 struct bus_type, subsys) : NULL; 36 kset_get(&bus->p->subsys);
37 return bus;
38 }
39 return NULL;
37} 40}
38 41
39static void bus_put(struct bus_type *bus) 42static void bus_put(struct bus_type *bus)
40{ 43{
41 kset_put(&bus->subsys); 44 if (bus)
45 kset_put(&bus->p->subsys);
42} 46}
43 47
44static ssize_t 48static ssize_t
@@ -104,11 +108,11 @@ static ssize_t
104bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 108bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
105{ 109{
106 struct bus_attribute * bus_attr = to_bus_attr(attr); 110 struct bus_attribute * bus_attr = to_bus_attr(attr);
107 struct bus_type * bus = to_bus(kobj); 111 struct bus_type_private *bus_priv = to_bus(kobj);
108 ssize_t ret = 0; 112 ssize_t ret = 0;
109 113
110 if (bus_attr->show) 114 if (bus_attr->show)
111 ret = bus_attr->show(bus, buf); 115 ret = bus_attr->show(bus_priv->bus, buf);
112 return ret; 116 return ret;
113} 117}
114 118
@@ -117,11 +121,11 @@ bus_attr_store(struct kobject * kobj, struct attribute * attr,
117 const char * buf, size_t count) 121 const char * buf, size_t count)
118{ 122{
119 struct bus_attribute * bus_attr = to_bus_attr(attr); 123 struct bus_attribute * bus_attr = to_bus_attr(attr);
120 struct bus_type * bus = to_bus(kobj); 124 struct bus_type_private *bus_priv = to_bus(kobj);
121 ssize_t ret = 0; 125 ssize_t ret = 0;
122 126
123 if (bus_attr->store) 127 if (bus_attr->store)
124 ret = bus_attr->store(bus, buf, count); 128 ret = bus_attr->store(bus_priv->bus, buf, count);
125 return ret; 129 return ret;
126} 130}
127 131
@@ -134,7 +138,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
134{ 138{
135 int error; 139 int error;
136 if (bus_get(bus)) { 140 if (bus_get(bus)) {
137 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr); 141 error = sysfs_create_file(&bus->p->subsys.kobj, &attr->attr);
138 bus_put(bus); 142 bus_put(bus);
139 } else 143 } else
140 error = -EINVAL; 144 error = -EINVAL;
@@ -144,7 +148,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
144void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) 148void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
145{ 149{
146 if (bus_get(bus)) { 150 if (bus_get(bus)) {
147 sysfs_remove_file(&bus->subsys.kobj, &attr->attr); 151 sysfs_remove_file(&bus->p->subsys.kobj, &attr->attr);
148 bus_put(bus); 152 bus_put(bus);
149 } 153 }
150} 154}
@@ -237,16 +241,16 @@ static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
237 241
238static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf) 242static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf)
239{ 243{
240 return sprintf(buf, "%d\n", bus->drivers_autoprobe); 244 return sprintf(buf, "%d\n", bus->p->drivers_autoprobe);
241} 245}
242 246
243static ssize_t store_drivers_autoprobe(struct bus_type *bus, 247static ssize_t store_drivers_autoprobe(struct bus_type *bus,
244 const char *buf, size_t count) 248 const char *buf, size_t count)
245{ 249{
246 if (buf[0] == '0') 250 if (buf[0] == '0')
247 bus->drivers_autoprobe = 0; 251 bus->p->drivers_autoprobe = 0;
248 else 252 else
249 bus->drivers_autoprobe = 1; 253 bus->p->drivers_autoprobe = 1;
250 return count; 254 return count;
251} 255}
252 256
@@ -300,7 +304,7 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
300 if (!bus) 304 if (!bus)
301 return -EINVAL; 305 return -EINVAL;
302 306
303 klist_iter_init_node(&bus->klist_devices, &i, 307 klist_iter_init_node(&bus->p->klist_devices, &i,
304 (start ? &start->knode_bus : NULL)); 308 (start ? &start->knode_bus : NULL));
305 while ((dev = next_device(&i)) && !error) 309 while ((dev = next_device(&i)) && !error)
306 error = fn(dev, data); 310 error = fn(dev, data);
@@ -333,7 +337,7 @@ struct device * bus_find_device(struct bus_type *bus,
333 if (!bus) 337 if (!bus)
334 return NULL; 338 return NULL;
335 339
336 klist_iter_init_node(&bus->klist_devices, &i, 340 klist_iter_init_node(&bus->p->klist_devices, &i,
337 (start ? &start->knode_bus : NULL)); 341 (start ? &start->knode_bus : NULL));
338 while ((dev = next_device(&i))) 342 while ((dev = next_device(&i)))
339 if (match(dev, data) && get_device(dev)) 343 if (match(dev, data) && get_device(dev))
@@ -379,7 +383,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
379 if (!bus) 383 if (!bus)
380 return -EINVAL; 384 return -EINVAL;
381 385
382 klist_iter_init_node(&bus->klist_drivers, &i, 386 klist_iter_init_node(&bus->p->klist_drivers, &i,
383 start ? &start->knode_bus : NULL); 387 start ? &start->knode_bus : NULL);
384 while ((drv = next_driver(&i)) && !error) 388 while ((drv = next_driver(&i)) && !error)
385 error = fn(drv, data); 389 error = fn(drv, data);
@@ -420,7 +424,7 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
420static int make_deprecated_bus_links(struct device *dev) 424static int make_deprecated_bus_links(struct device *dev)
421{ 425{
422 return sysfs_create_link(&dev->kobj, 426 return sysfs_create_link(&dev->kobj,
423 &dev->bus->subsys.kobj, "bus"); 427 &dev->bus->p->subsys.kobj, "bus");
424} 428}
425 429
426static void remove_deprecated_bus_links(struct device *dev) 430static void remove_deprecated_bus_links(struct device *dev)
@@ -449,12 +453,12 @@ int bus_add_device(struct device * dev)
449 error = device_add_attrs(bus, dev); 453 error = device_add_attrs(bus, dev);
450 if (error) 454 if (error)
451 goto out_put; 455 goto out_put;
452 error = sysfs_create_link(&bus->devices_kset->kobj, 456 error = sysfs_create_link(&bus->p->devices_kset->kobj,
453 &dev->kobj, dev->bus_id); 457 &dev->kobj, dev->bus_id);
454 if (error) 458 if (error)
455 goto out_id; 459 goto out_id;
456 error = sysfs_create_link(&dev->kobj, 460 error = sysfs_create_link(&dev->kobj,
457 &dev->bus->subsys.kobj, "subsystem"); 461 &dev->bus->p->subsys.kobj, "subsystem");
458 if (error) 462 if (error)
459 goto out_subsys; 463 goto out_subsys;
460 error = make_deprecated_bus_links(dev); 464 error = make_deprecated_bus_links(dev);
@@ -466,7 +470,7 @@ int bus_add_device(struct device * dev)
466out_deprecated: 470out_deprecated:
467 sysfs_remove_link(&dev->kobj, "subsystem"); 471 sysfs_remove_link(&dev->kobj, "subsystem");
468out_subsys: 472out_subsys:
469 sysfs_remove_link(&bus->devices_kset->kobj, dev->bus_id); 473 sysfs_remove_link(&bus->p->devices_kset->kobj, dev->bus_id);
470out_id: 474out_id:
471 device_remove_attrs(bus, dev); 475 device_remove_attrs(bus, dev);
472out_put: 476out_put:
@@ -488,11 +492,11 @@ void bus_attach_device(struct device * dev)
488 492
489 if (bus) { 493 if (bus) {
490 dev->is_registered = 1; 494 dev->is_registered = 1;
491 if (bus->drivers_autoprobe) 495 if (bus->p->drivers_autoprobe)
492 ret = device_attach(dev); 496 ret = device_attach(dev);
493 WARN_ON(ret < 0); 497 WARN_ON(ret < 0);
494 if (ret >= 0) 498 if (ret >= 0)
495 klist_add_tail(&dev->knode_bus, &bus->klist_devices); 499 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
496 else 500 else
497 dev->is_registered = 0; 501 dev->is_registered = 0;
498 } 502 }
@@ -512,7 +516,7 @@ void bus_remove_device(struct device * dev)
512 if (dev->bus) { 516 if (dev->bus) {
513 sysfs_remove_link(&dev->kobj, "subsystem"); 517 sysfs_remove_link(&dev->kobj, "subsystem");
514 remove_deprecated_bus_links(dev); 518 remove_deprecated_bus_links(dev);
515 sysfs_remove_link(&dev->bus->devices_kset->kobj, dev->bus_id); 519 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev->bus_id);
516 device_remove_attrs(dev->bus, dev); 520 device_remove_attrs(dev->bus, dev);
517 if (dev->is_registered) { 521 if (dev->is_registered) {
518 dev->is_registered = 0; 522 dev->is_registered = 0;
@@ -638,18 +642,18 @@ int bus_add_driver(struct device_driver *drv)
638 error = kobject_set_name(&drv->kobj, "%s", drv->name); 642 error = kobject_set_name(&drv->kobj, "%s", drv->name);
639 if (error) 643 if (error)
640 goto out_put_bus; 644 goto out_put_bus;
641 drv->kobj.kset = bus->drivers_kset; 645 drv->kobj.kset = bus->p->drivers_kset;
642 drv->kobj.ktype = &driver_ktype; 646 drv->kobj.ktype = &driver_ktype;
643 error = kobject_register(&drv->kobj); 647 error = kobject_register(&drv->kobj);
644 if (error) 648 if (error)
645 goto out_put_bus; 649 goto out_put_bus;
646 650
647 if (drv->bus->drivers_autoprobe) { 651 if (drv->bus->p->drivers_autoprobe) {
648 error = driver_attach(drv); 652 error = driver_attach(drv);
649 if (error) 653 if (error)
650 goto out_unregister; 654 goto out_unregister;
651 } 655 }
652 klist_add_tail(&drv->knode_bus, &bus->klist_drivers); 656 klist_add_tail(&drv->knode_bus, &bus->p->klist_drivers);
653 module_add_driver(drv->owner, drv); 657 module_add_driver(drv->owner, drv);
654 658
655 error = driver_create_file(drv, &driver_attr_uevent); 659 error = driver_create_file(drv, &driver_attr_uevent);
@@ -828,7 +832,7 @@ static ssize_t bus_uevent_store(struct bus_type *bus,
828 enum kobject_action action; 832 enum kobject_action action;
829 833
830 if (kobject_action_type(buf, count, &action) == 0) 834 if (kobject_action_type(buf, count, &action) == 0)
831 kobject_uevent(&bus->subsys.kobj, action); 835 kobject_uevent(&bus->p->subsys.kobj, action);
832 return count; 836 return count;
833} 837}
834static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); 838static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
@@ -844,17 +848,26 @@ static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
844int bus_register(struct bus_type * bus) 848int bus_register(struct bus_type * bus)
845{ 849{
846 int retval; 850 int retval;
851 struct bus_type_private *priv;
852
853 priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL);
854 if (!priv)
855 return -ENOMEM;
856
857 priv->bus = bus;
858 bus->p = priv;
847 859
848 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier); 860 BLOCKING_INIT_NOTIFIER_HEAD(&priv->bus_notifier);
849 861
850 retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name); 862 retval = kobject_set_name(&priv->subsys.kobj, "%s", bus->name);
851 if (retval) 863 if (retval)
852 goto out; 864 goto out;
853 865
854 bus->subsys.kobj.kset = bus_kset; 866 priv->subsys.kobj.kset = bus_kset;
855 bus->subsys.kobj.ktype = &bus_ktype; 867 priv->subsys.kobj.ktype = &bus_ktype;
868 priv->drivers_autoprobe = 1;
856 869
857 retval = kset_register(&bus->subsys); 870 retval = kset_register(&priv->subsys);
858 if (retval) 871 if (retval)
859 goto out; 872 goto out;
860 873
@@ -862,24 +875,23 @@ int bus_register(struct bus_type * bus)
862 if (retval) 875 if (retval)
863 goto bus_uevent_fail; 876 goto bus_uevent_fail;
864 877
865 bus->devices_kset = kset_create_and_add("devices", NULL, 878 priv->devices_kset = kset_create_and_add("devices", NULL,
866 &bus->subsys.kobj); 879 &priv->subsys.kobj);
867 if (!bus->devices_kset) { 880 if (!priv->devices_kset) {
868 retval = -ENOMEM; 881 retval = -ENOMEM;
869 goto bus_devices_fail; 882 goto bus_devices_fail;
870 } 883 }
871 884
872 bus->drivers_kset = kset_create_and_add("drivers", NULL, 885 priv->drivers_kset = kset_create_and_add("drivers", NULL,
873 &bus->subsys.kobj); 886 &priv->subsys.kobj);
874 if (!bus->drivers_kset) { 887 if (!priv->drivers_kset) {
875 retval = -ENOMEM; 888 retval = -ENOMEM;
876 goto bus_drivers_fail; 889 goto bus_drivers_fail;
877 } 890 }
878 891
879 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put); 892 klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
880 klist_init(&bus->klist_drivers, NULL, NULL); 893 klist_init(&priv->klist_drivers, NULL, NULL);
881 894
882 bus->drivers_autoprobe = 1;
883 retval = add_probe_files(bus); 895 retval = add_probe_files(bus);
884 if (retval) 896 if (retval)
885 goto bus_probe_files_fail; 897 goto bus_probe_files_fail;
@@ -894,13 +906,14 @@ int bus_register(struct bus_type * bus)
894bus_attrs_fail: 906bus_attrs_fail:
895 remove_probe_files(bus); 907 remove_probe_files(bus);
896bus_probe_files_fail: 908bus_probe_files_fail:
897 kset_unregister(bus->drivers_kset); 909 kset_unregister(bus->p->drivers_kset);
898bus_drivers_fail: 910bus_drivers_fail:
899 kset_unregister(bus->devices_kset); 911 kset_unregister(bus->p->devices_kset);
900bus_devices_fail: 912bus_devices_fail:
901 bus_remove_file(bus, &bus_attr_uevent); 913 bus_remove_file(bus, &bus_attr_uevent);
902bus_uevent_fail: 914bus_uevent_fail:
903 kset_unregister(&bus->subsys); 915 kset_unregister(&bus->p->subsys);
916 kfree(bus->p);
904out: 917out:
905 return retval; 918 return retval;
906} 919}
@@ -917,33 +930,34 @@ void bus_unregister(struct bus_type * bus)
917 pr_debug("bus %s: unregistering\n", bus->name); 930 pr_debug("bus %s: unregistering\n", bus->name);
918 bus_remove_attrs(bus); 931 bus_remove_attrs(bus);
919 remove_probe_files(bus); 932 remove_probe_files(bus);
920 kset_unregister(bus->drivers_kset); 933 kset_unregister(bus->p->drivers_kset);
921 kset_unregister(bus->devices_kset); 934 kset_unregister(bus->p->devices_kset);
922 bus_remove_file(bus, &bus_attr_uevent); 935 bus_remove_file(bus, &bus_attr_uevent);
923 kset_unregister(&bus->subsys); 936 kset_unregister(&bus->p->subsys);
937 kfree(bus->p);
924} 938}
925 939
926int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) 940int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
927{ 941{
928 return blocking_notifier_chain_register(&bus->bus_notifier, nb); 942 return blocking_notifier_chain_register(&bus->p->bus_notifier, nb);
929} 943}
930EXPORT_SYMBOL_GPL(bus_register_notifier); 944EXPORT_SYMBOL_GPL(bus_register_notifier);
931 945
932int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb) 946int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
933{ 947{
934 return blocking_notifier_chain_unregister(&bus->bus_notifier, nb); 948 return blocking_notifier_chain_unregister(&bus->p->bus_notifier, nb);
935} 949}
936EXPORT_SYMBOL_GPL(bus_unregister_notifier); 950EXPORT_SYMBOL_GPL(bus_unregister_notifier);
937 951
938struct kset *bus_get_kset(struct bus_type *bus) 952struct kset *bus_get_kset(struct bus_type *bus)
939{ 953{
940 return &bus->subsys; 954 return &bus->p->subsys;
941} 955}
942EXPORT_SYMBOL_GPL(bus_get_kset); 956EXPORT_SYMBOL_GPL(bus_get_kset);
943 957
944struct klist *bus_get_device_klist(struct bus_type *bus) 958struct klist *bus_get_device_klist(struct bus_type *bus)
945{ 959{
946 return &bus->klist_devices; 960 return &bus->p->klist_devices;
947} 961}
948EXPORT_SYMBOL_GPL(bus_get_device_klist); 962EXPORT_SYMBOL_GPL(bus_get_device_klist);
949 963
diff --git a/drivers/base/core.c b/drivers/base/core.c
index beb351600675..414a480e10a3 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -769,7 +769,7 @@ int device_add(struct device *dev)
769 769
770 /* notify clients of device entry (new way) */ 770 /* notify clients of device entry (new way) */
771 if (dev->bus) 771 if (dev->bus)
772 blocking_notifier_call_chain(&dev->bus->bus_notifier, 772 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
773 BUS_NOTIFY_ADD_DEVICE, dev); 773 BUS_NOTIFY_ADD_DEVICE, dev);
774 774
775 error = device_create_file(dev, &uevent_attr); 775 error = device_create_file(dev, &uevent_attr);
@@ -820,7 +820,7 @@ int device_add(struct device *dev)
820 dpm_sysfs_remove(dev); 820 dpm_sysfs_remove(dev);
821 PMError: 821 PMError:
822 if (dev->bus) 822 if (dev->bus)
823 blocking_notifier_call_chain(&dev->bus->bus_notifier, 823 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
824 BUS_NOTIFY_DEL_DEVICE, dev); 824 BUS_NOTIFY_DEL_DEVICE, dev);
825 device_remove_attrs(dev); 825 device_remove_attrs(dev);
826 AttrsError: 826 AttrsError:
@@ -999,7 +999,7 @@ void device_del(struct device * dev)
999 if (platform_notify_remove) 999 if (platform_notify_remove)
1000 platform_notify_remove(dev); 1000 platform_notify_remove(dev);
1001 if (dev->bus) 1001 if (dev->bus)
1002 blocking_notifier_call_chain(&dev->bus->bus_notifier, 1002 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
1003 BUS_NOTIFY_DEL_DEVICE, dev); 1003 BUS_NOTIFY_DEL_DEVICE, dev);
1004 kobject_uevent(&dev->kobj, KOBJ_REMOVE); 1004 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
1005 kobject_del(&dev->kobj); 1005 kobject_del(&dev->kobj);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 7ac474db88c5..7bf0e674c975 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -38,7 +38,7 @@ static void driver_bound(struct device *dev)
38 dev->bus_id, dev->driver->name); 38 dev->bus_id, dev->driver->name);
39 39
40 if (dev->bus) 40 if (dev->bus)
41 blocking_notifier_call_chain(&dev->bus->bus_notifier, 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
42 BUS_NOTIFY_BOUND_DRIVER, dev); 42 BUS_NOTIFY_BOUND_DRIVER, dev);
43 43
44 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); 44 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
@@ -296,7 +296,7 @@ static void __device_release_driver(struct device * dev)
296 klist_remove(&dev->knode_driver); 296 klist_remove(&dev->knode_driver);
297 297
298 if (dev->bus) 298 if (dev->bus)
299 blocking_notifier_call_chain(&dev->bus->bus_notifier, 299 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
300 BUS_NOTIFY_UNBIND_DRIVER, 300 BUS_NOTIFY_UNBIND_DRIVER,
301 dev); 301 dev);
302 302
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1c9770dfb801..f94be40646d2 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,7 +185,7 @@ void driver_unregister(struct device_driver * drv)
185 */ 185 */
186struct device_driver *driver_find(const char *name, struct bus_type *bus) 186struct device_driver *driver_find(const char *name, struct bus_type *bus)
187{ 187{
188 struct kobject *k = kset_find_obj(bus->drivers_kset, name); 188 struct kobject *k = kset_find_obj(bus->p->drivers_kset, name);
189 if (k) 189 if (k)
190 return to_drv(k); 190 return to_drv(k);
191 return NULL; 191 return NULL;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index fb5609241482..d56a05f94f67 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -497,12 +497,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
497 * if the probe was successful, and make sure any forced probes of 497 * if the probe was successful, and make sure any forced probes of
498 * new devices fail. 498 * new devices fail.
499 */ 499 */
500 spin_lock(&platform_bus_type.klist_drivers.k_lock); 500 spin_lock(&platform_bus_type.p->klist_drivers.k_lock);
501 drv->probe = NULL; 501 drv->probe = NULL;
502 if (code == 0 && list_empty(&drv->driver.klist_devices.k_list)) 502 if (code == 0 && list_empty(&drv->driver.klist_devices.k_list))
503 retval = -ENODEV; 503 retval = -ENODEV;
504 drv->driver.probe = platform_drv_probe_fail; 504 drv->driver.probe = platform_drv_probe_fail;
505 spin_unlock(&platform_bus_type.klist_drivers.k_lock); 505 spin_unlock(&platform_bus_type.p->klist_drivers.k_lock);
506 506
507 if (code != retval) 507 if (code != retval)
508 platform_driver_unregister(drv); 508 platform_driver_unregister(drv);