fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / spi / spi.c
index 146298a..6307428 100644 (file)
@@ -281,7 +281,6 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
        up(&board_lock);
        return 0;
 }
-EXPORT_SYMBOL_GPL(spi_register_board_info);
 
 /* FIXME someone should add support for a __setup("spi", ...) that
  * creates board info from kernel command lines
@@ -361,7 +360,7 @@ spi_alloc_master(struct device *dev, unsigned size)
        if (!dev)
                return NULL;
 
-       master = kzalloc(size + sizeof *master, SLAB_KERNEL);
+       master = kzalloc(size + sizeof *master, GFP_KERNEL);
        if (!master)
                return NULL;
 
@@ -448,7 +447,9 @@ static int __unregister(struct device *dev, void *unused)
  */
 void spi_unregister_master(struct spi_master *master)
 {
-       (void) device_for_each_child(master->cdev.dev, NULL, __unregister);
+       int dummy;
+
+       dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
        class_device_unregister(&master->cdev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
@@ -464,16 +465,20 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
  */
 struct spi_master *spi_busnum_to_master(u16 bus_num)
 {
-       if (bus_num) {
-               char                    name[8];
-               struct kobject          *bus;
-
-               snprintf(name, sizeof name, "spi%u", bus_num);
-               bus = kset_find_obj(&spi_master_class.subsys.kset, name);
-               if (bus)
-                       return container_of(bus, struct spi_master, cdev.kobj);
+       struct class_device     *cdev;
+       struct spi_master       *master = NULL;
+       struct spi_master       *m;
+
+       down(&spi_master_class.sem);
+       list_for_each_entry(cdev, &spi_master_class.children, node) {
+               m = container_of(cdev, struct spi_master, cdev);
+               if (m->bus_num == bus_num) {
+                       master = spi_master_get(m);
+                       break;
+               }
        }
-       return NULL;
+       up(&spi_master_class.sem);
+       return master;
 }
 EXPORT_SYMBOL_GPL(spi_busnum_to_master);
 
@@ -608,7 +613,7 @@ static int __init spi_init(void)
 {
        int     status;
 
-       buf = kmalloc(SPI_BUFSIZ, SLAB_KERNEL);
+       buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
        if (!buf) {
                status = -ENOMEM;
                goto err0;