diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-30 17:31:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-30 17:31:37 -0500 |
commit | 3b470ac43fcd9848fa65e58e54875ad75be61cec (patch) | |
tree | eb067e163380d8a9e77a6df44f69dd4b935dd060 /drivers/base | |
parent | 2c57ee6f924c95e4dce61ed4776fb3f62e1b9f92 (diff) | |
parent | c847c853a5c562bac940c544748525d038167275 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6:
PPC: Fix powerpc vio_find_name to not use devices_subsys
Driver core: add bus_find_device_by_name function
Module: check to see if we have a built in module with the same name
x86: fix runtime error in arch/x86/kernel/cpu/mcheck/mce_amd_64.c
Driver core: Fix up build when CONFIG_BLOCK=N
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/bus.c | 41 | ||||
-rw-r--r-- | drivers/base/class.c | 2 | ||||
-rw-r--r-- | drivers/base/core.c | 30 |
3 files changed, 49 insertions, 24 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index f484495b2ad1..055989e94799 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -163,15 +163,6 @@ static struct kset *bus_kset; | |||
163 | 163 | ||
164 | #ifdef CONFIG_HOTPLUG | 164 | #ifdef CONFIG_HOTPLUG |
165 | /* Manually detach a device from its associated driver. */ | 165 | /* Manually detach a device from its associated driver. */ |
166 | static int driver_helper(struct device *dev, void *data) | ||
167 | { | ||
168 | const char *name = data; | ||
169 | |||
170 | if (strcmp(name, dev->bus_id) == 0) | ||
171 | return 1; | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static ssize_t driver_unbind(struct device_driver *drv, | 166 | static ssize_t driver_unbind(struct device_driver *drv, |
176 | const char *buf, size_t count) | 167 | const char *buf, size_t count) |
177 | { | 168 | { |
@@ -179,7 +170,7 @@ static ssize_t driver_unbind(struct device_driver *drv, | |||
179 | struct device *dev; | 170 | struct device *dev; |
180 | int err = -ENODEV; | 171 | int err = -ENODEV; |
181 | 172 | ||
182 | dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); | 173 | dev = bus_find_device_by_name(bus, NULL, buf); |
183 | if (dev && dev->driver == drv) { | 174 | if (dev && dev->driver == drv) { |
184 | if (dev->parent) /* Needed for USB */ | 175 | if (dev->parent) /* Needed for USB */ |
185 | down(&dev->parent->sem); | 176 | down(&dev->parent->sem); |
@@ -206,7 +197,7 @@ static ssize_t driver_bind(struct device_driver *drv, | |||
206 | struct device *dev; | 197 | struct device *dev; |
207 | int err = -ENODEV; | 198 | int err = -ENODEV; |
208 | 199 | ||
209 | dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); | 200 | dev = bus_find_device_by_name(bus, NULL, buf); |
210 | if (dev && dev->driver == NULL) { | 201 | if (dev && dev->driver == NULL) { |
211 | if (dev->parent) /* Needed for USB */ | 202 | if (dev->parent) /* Needed for USB */ |
212 | down(&dev->parent->sem); | 203 | down(&dev->parent->sem); |
@@ -250,7 +241,7 @@ static ssize_t store_drivers_probe(struct bus_type *bus, | |||
250 | { | 241 | { |
251 | struct device *dev; | 242 | struct device *dev; |
252 | 243 | ||
253 | dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); | 244 | dev = bus_find_device_by_name(bus, NULL, buf); |
254 | if (!dev) | 245 | if (!dev) |
255 | return -ENODEV; | 246 | return -ENODEV; |
256 | if (bus_rescan_devices_helper(dev, NULL) != 0) | 247 | if (bus_rescan_devices_helper(dev, NULL) != 0) |
@@ -338,6 +329,32 @@ struct device *bus_find_device(struct bus_type *bus, | |||
338 | } | 329 | } |
339 | EXPORT_SYMBOL_GPL(bus_find_device); | 330 | EXPORT_SYMBOL_GPL(bus_find_device); |
340 | 331 | ||
332 | static int match_name(struct device *dev, void *data) | ||
333 | { | ||
334 | const char *name = data; | ||
335 | |||
336 | if (strcmp(name, dev->bus_id) == 0) | ||
337 | return 1; | ||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * bus_find_device_by_name - device iterator for locating a particular device of a specific name | ||
343 | * @bus: bus type | ||
344 | * @start: Device to begin with | ||
345 | * @name: name of the device to match | ||
346 | * | ||
347 | * This is similar to the bus_find_device() function above, but it handles | ||
348 | * searching by a name automatically, no need to write another strcmp matching | ||
349 | * function. | ||
350 | */ | ||
351 | struct device *bus_find_device_by_name(struct bus_type *bus, | ||
352 | struct device *start, const char *name) | ||
353 | { | ||
354 | return bus_find_device(bus, start, (void *)name, match_name); | ||
355 | } | ||
356 | EXPORT_SYMBOL_GPL(bus_find_device_by_name); | ||
357 | |||
341 | static struct device_driver *next_driver(struct klist_iter *i) | 358 | static struct device_driver *next_driver(struct klist_iter *i) |
342 | { | 359 | { |
343 | struct klist_node *n = klist_next(i); | 360 | struct klist_node *n = klist_next(i); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 412fd9a05573..9d915376c313 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -149,7 +149,7 @@ int class_register(struct class *cls) | |||
149 | if (error) | 149 | if (error) |
150 | return error; | 150 | return error; |
151 | 151 | ||
152 | #ifdef CONFIG_SYSFS_DEPRECATED | 152 | #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) |
153 | /* let the block class directory show up in the root of sysfs */ | 153 | /* let the block class directory show up in the root of sysfs */ |
154 | if (cls != &block_class) | 154 | if (cls != &block_class) |
155 | cls->subsys.kobj.kset = class_kset; | 155 | cls->subsys.kobj.kset = class_kset; |
diff --git a/drivers/base/core.c b/drivers/base/core.c index edf3bbeb8d6a..b1727876182c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -27,9 +27,17 @@ | |||
27 | int (*platform_notify)(struct device *dev) = NULL; | 27 | int (*platform_notify)(struct device *dev) = NULL; |
28 | int (*platform_notify_remove)(struct device *dev) = NULL; | 28 | int (*platform_notify_remove)(struct device *dev) = NULL; |
29 | 29 | ||
30 | /* | 30 | #ifdef CONFIG_BLOCK |
31 | * sysfs bindings for devices. | 31 | static inline int device_is_not_partition(struct device *dev) |
32 | */ | 32 | { |
33 | return !(dev->type == &part_type); | ||
34 | } | ||
35 | #else | ||
36 | static inline int device_is_not_partition(struct device *dev) | ||
37 | { | ||
38 | return 1; | ||
39 | } | ||
40 | #endif | ||
33 | 41 | ||
34 | /** | 42 | /** |
35 | * dev_driver_string - Return a device's driver name, if at all possible | 43 | * dev_driver_string - Return a device's driver name, if at all possible |
@@ -652,14 +660,14 @@ static int device_add_class_symlinks(struct device *dev) | |||
652 | #ifdef CONFIG_SYSFS_DEPRECATED | 660 | #ifdef CONFIG_SYSFS_DEPRECATED |
653 | /* stacked class devices need a symlink in the class directory */ | 661 | /* stacked class devices need a symlink in the class directory */ |
654 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 662 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
655 | dev->type != &part_type) { | 663 | device_is_not_partition(dev)) { |
656 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 664 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, |
657 | dev->bus_id); | 665 | dev->bus_id); |
658 | if (error) | 666 | if (error) |
659 | goto out_subsys; | 667 | goto out_subsys; |
660 | } | 668 | } |
661 | 669 | ||
662 | if (dev->parent && dev->type != &part_type) { | 670 | if (dev->parent && device_is_not_partition(dev)) { |
663 | struct device *parent = dev->parent; | 671 | struct device *parent = dev->parent; |
664 | char *class_name; | 672 | char *class_name; |
665 | 673 | ||
@@ -688,11 +696,11 @@ static int device_add_class_symlinks(struct device *dev) | |||
688 | return 0; | 696 | return 0; |
689 | 697 | ||
690 | out_device: | 698 | out_device: |
691 | if (dev->parent && dev->type != &part_type) | 699 | if (dev->parent && device_is_not_partition(dev)) |
692 | sysfs_remove_link(&dev->kobj, "device"); | 700 | sysfs_remove_link(&dev->kobj, "device"); |
693 | out_busid: | 701 | out_busid: |
694 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 702 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
695 | dev->type != &part_type) | 703 | device_is_not_partition(dev)) |
696 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 704 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
697 | #else | 705 | #else |
698 | /* link in the class directory pointing to the device */ | 706 | /* link in the class directory pointing to the device */ |
@@ -701,7 +709,7 @@ out_busid: | |||
701 | if (error) | 709 | if (error) |
702 | goto out_subsys; | 710 | goto out_subsys; |
703 | 711 | ||
704 | if (dev->parent && dev->type != &part_type) { | 712 | if (dev->parent && device_is_not_partition(dev)) { |
705 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, | 713 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, |
706 | "device"); | 714 | "device"); |
707 | if (error) | 715 | if (error) |
@@ -725,7 +733,7 @@ static void device_remove_class_symlinks(struct device *dev) | |||
725 | return; | 733 | return; |
726 | 734 | ||
727 | #ifdef CONFIG_SYSFS_DEPRECATED | 735 | #ifdef CONFIG_SYSFS_DEPRECATED |
728 | if (dev->parent && dev->type != &part_type) { | 736 | if (dev->parent && device_is_not_partition(dev)) { |
729 | char *class_name; | 737 | char *class_name; |
730 | 738 | ||
731 | class_name = make_class_name(dev->class->name, &dev->kobj); | 739 | class_name = make_class_name(dev->class->name, &dev->kobj); |
@@ -737,10 +745,10 @@ static void device_remove_class_symlinks(struct device *dev) | |||
737 | } | 745 | } |
738 | 746 | ||
739 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 747 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
740 | dev->type != &part_type) | 748 | device_is_not_partition(dev)) |
741 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 749 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
742 | #else | 750 | #else |
743 | if (dev->parent && dev->type != &part_type) | 751 | if (dev->parent && device_is_not_partition(dev)) |
744 | sysfs_remove_link(&dev->kobj, "device"); | 752 | sysfs_remove_link(&dev->kobj, "device"); |
745 | 753 | ||
746 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 754 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |