diff options
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 63c143e54a57..12eec3f633b1 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/device.h> | 13 | #include <linux/device.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/slab.h> | ||
16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
17 | #include <linux/string.h> | 18 | #include <linux/string.h> |
18 | #include "base.h" | 19 | #include "base.h" |
@@ -70,7 +71,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr, | |||
70 | return ret; | 71 | return ret; |
71 | } | 72 | } |
72 | 73 | ||
73 | static struct sysfs_ops driver_sysfs_ops = { | 74 | static const struct sysfs_ops driver_sysfs_ops = { |
74 | .show = drv_attr_show, | 75 | .show = drv_attr_show, |
75 | .store = drv_attr_store, | 76 | .store = drv_attr_store, |
76 | }; | 77 | }; |
@@ -115,7 +116,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr, | |||
115 | return ret; | 116 | return ret; |
116 | } | 117 | } |
117 | 118 | ||
118 | static struct sysfs_ops bus_sysfs_ops = { | 119 | static const struct sysfs_ops bus_sysfs_ops = { |
119 | .show = bus_attr_show, | 120 | .show = bus_attr_show, |
120 | .store = bus_attr_store, | 121 | .store = bus_attr_store, |
121 | }; | 122 | }; |
@@ -154,7 +155,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj) | |||
154 | return 0; | 155 | return 0; |
155 | } | 156 | } |
156 | 157 | ||
157 | static struct kset_uevent_ops bus_uevent_ops = { | 158 | static const struct kset_uevent_ops bus_uevent_ops = { |
158 | .filter = bus_uevent_filter, | 159 | .filter = bus_uevent_filter, |
159 | }; | 160 | }; |
160 | 161 | ||
@@ -173,10 +174,10 @@ static ssize_t driver_unbind(struct device_driver *drv, | |||
173 | dev = bus_find_device_by_name(bus, NULL, buf); | 174 | dev = bus_find_device_by_name(bus, NULL, buf); |
174 | if (dev && dev->driver == drv) { | 175 | if (dev && dev->driver == drv) { |
175 | if (dev->parent) /* Needed for USB */ | 176 | if (dev->parent) /* Needed for USB */ |
176 | down(&dev->parent->sem); | 177 | device_lock(dev->parent); |
177 | device_release_driver(dev); | 178 | device_release_driver(dev); |
178 | if (dev->parent) | 179 | if (dev->parent) |
179 | up(&dev->parent->sem); | 180 | device_unlock(dev->parent); |
180 | err = count; | 181 | err = count; |
181 | } | 182 | } |
182 | put_device(dev); | 183 | put_device(dev); |
@@ -200,12 +201,12 @@ static ssize_t driver_bind(struct device_driver *drv, | |||
200 | dev = bus_find_device_by_name(bus, NULL, buf); | 201 | dev = bus_find_device_by_name(bus, NULL, buf); |
201 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { | 202 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { |
202 | if (dev->parent) /* Needed for USB */ | 203 | if (dev->parent) /* Needed for USB */ |
203 | down(&dev->parent->sem); | 204 | device_lock(dev->parent); |
204 | down(&dev->sem); | 205 | device_lock(dev); |
205 | err = driver_probe_device(drv, dev); | 206 | err = driver_probe_device(drv, dev); |
206 | up(&dev->sem); | 207 | device_unlock(dev); |
207 | if (dev->parent) | 208 | if (dev->parent) |
208 | up(&dev->parent->sem); | 209 | device_unlock(dev->parent); |
209 | 210 | ||
210 | if (err > 0) { | 211 | if (err > 0) { |
211 | /* success */ | 212 | /* success */ |
@@ -703,9 +704,9 @@ int bus_add_driver(struct device_driver *drv) | |||
703 | return 0; | 704 | return 0; |
704 | 705 | ||
705 | out_unregister: | 706 | out_unregister: |
707 | kobject_put(&priv->kobj); | ||
706 | kfree(drv->p); | 708 | kfree(drv->p); |
707 | drv->p = NULL; | 709 | drv->p = NULL; |
708 | kobject_put(&priv->kobj); | ||
709 | out_put_bus: | 710 | out_put_bus: |
710 | bus_put(bus); | 711 | bus_put(bus); |
711 | return error; | 712 | return error; |
@@ -744,10 +745,10 @@ static int __must_check bus_rescan_devices_helper(struct device *dev, | |||
744 | 745 | ||
745 | if (!dev->driver) { | 746 | if (!dev->driver) { |
746 | if (dev->parent) /* Needed for USB */ | 747 | if (dev->parent) /* Needed for USB */ |
747 | down(&dev->parent->sem); | 748 | device_lock(dev->parent); |
748 | ret = device_attach(dev); | 749 | ret = device_attach(dev); |
749 | if (dev->parent) | 750 | if (dev->parent) |
750 | up(&dev->parent->sem); | 751 | device_unlock(dev->parent); |
751 | } | 752 | } |
752 | return ret < 0 ? ret : 0; | 753 | return ret < 0 ? ret : 0; |
753 | } | 754 | } |
@@ -779,10 +780,10 @@ int device_reprobe(struct device *dev) | |||
779 | { | 780 | { |
780 | if (dev->driver) { | 781 | if (dev->driver) { |
781 | if (dev->parent) /* Needed for USB */ | 782 | if (dev->parent) /* Needed for USB */ |
782 | down(&dev->parent->sem); | 783 | device_lock(dev->parent); |
783 | device_release_driver(dev); | 784 | device_release_driver(dev); |
784 | if (dev->parent) | 785 | if (dev->parent) |
785 | up(&dev->parent->sem); | 786 | device_unlock(dev->parent); |
786 | } | 787 | } |
787 | return bus_rescan_devices_helper(dev, NULL); | 788 | return bus_rescan_devices_helper(dev, NULL); |
788 | } | 789 | } |