aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-30 17:31:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-30 17:31:37 -0500
commit3b470ac43fcd9848fa65e58e54875ad75be61cec (patch)
treeeb067e163380d8a9e77a6df44f69dd4b935dd060
parent2c57ee6f924c95e4dce61ed4776fb3f62e1b9f92 (diff)
parentc847c853a5c562bac940c544748525d038167275 (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
-rw-r--r--arch/powerpc/kernel/vio.c13
-rw-r--r--drivers/base/bus.c41
-rw-r--r--drivers/base/class.c2
-rw-r--r--drivers/base/core.c30
-rw-r--r--include/linux/device.h3
5 files changed, 56 insertions, 33 deletions
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 19a5656001c0..f0bad7070fb5 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -37,8 +37,6 @@
37#include <asm/iseries/hv_call_xm.h> 37#include <asm/iseries/hv_call_xm.h>
38#include <asm/iseries/iommu.h> 38#include <asm/iseries/iommu.h>
39 39
40extern struct kset devices_subsys; /* needed for vio_find_name() */
41
42static struct bus_type vio_bus_type; 40static struct bus_type vio_bus_type;
43 41
44static struct vio_dev vio_bus_device = { /* fake "parent" device */ 42static struct vio_dev vio_bus_device = { /* fake "parent" device */
@@ -361,19 +359,16 @@ EXPORT_SYMBOL(vio_get_attribute);
361#ifdef CONFIG_PPC_PSERIES 359#ifdef CONFIG_PPC_PSERIES
362/* vio_find_name() - internal because only vio.c knows how we formatted the 360/* vio_find_name() - internal because only vio.c knows how we formatted the
363 * kobject name 361 * kobject name
364 * XXX once vio_bus_type.devices is actually used as a kset in
365 * drivers/base/bus.c, this function should be removed in favor of
366 * "device_find(kobj_name, &vio_bus_type)"
367 */ 362 */
368static struct vio_dev *vio_find_name(const char *kobj_name) 363static struct vio_dev *vio_find_name(const char *name)
369{ 364{
370 struct kobject *found; 365 struct device *found;
371 366
372 found = kset_find_obj(&devices_subsys, kobj_name); 367 found = bus_find_device_by_name(&vio_bus_type, NULL, name);
373 if (!found) 368 if (!found)
374 return NULL; 369 return NULL;
375 370
376 return to_vio_dev(container_of(found, struct device, kobj)); 371 return to_vio_dev(found);
377} 372}
378 373
379/** 374/**
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. */
166static 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
175static ssize_t driver_unbind(struct device_driver *drv, 166static 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}
339EXPORT_SYMBOL_GPL(bus_find_device); 330EXPORT_SYMBOL_GPL(bus_find_device);
340 331
332static 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 */
351struct 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}
356EXPORT_SYMBOL_GPL(bus_find_device_by_name);
357
341static struct device_driver *next_driver(struct klist_iter *i) 358static 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 @@
27int (*platform_notify)(struct device *dev) = NULL; 27int (*platform_notify)(struct device *dev) = NULL;
28int (*platform_notify_remove)(struct device *dev) = NULL; 28int (*platform_notify_remove)(struct device *dev) = NULL;
29 29
30/* 30#ifdef CONFIG_BLOCK
31 * sysfs bindings for devices. 31static inline int device_is_not_partition(struct device *dev)
32 */ 32{
33 return !(dev->type == &part_type);
34}
35#else
36static 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
690out_device: 698out_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");
693out_busid: 701out_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);
diff --git a/include/linux/device.h b/include/linux/device.h
index 1880208964d6..db375be333c7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -84,6 +84,9 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
84struct device *bus_find_device(struct bus_type *bus, struct device *start, 84struct device *bus_find_device(struct bus_type *bus, struct device *start,
85 void *data, 85 void *data,
86 int (*match)(struct device *dev, void *data)); 86 int (*match)(struct device *dev, void *data));
87struct device *bus_find_device_by_name(struct bus_type *bus,
88 struct device *start,
89 const char *name);
87 90
88int __must_check bus_for_each_drv(struct bus_type *bus, 91int __must_check bus_for_each_drv(struct bus_type *bus,
89 struct device_driver *start, void *data, 92 struct device_driver *start, void *data,