Merge tag 'module-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg...
[cascardo/linux.git] / drivers / bcma / main.c
index ec31f7d..7e138ec 100644 (file)
 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
 MODULE_LICENSE("GPL");
 
+/* contains the number the next bus should get. */
+static unsigned int bcma_bus_next_num = 0;
+
+/* bcma_buses_mutex locks the bcma_bus_next_num */
+static DEFINE_MUTEX(bcma_buses_mutex);
+
 static int bcma_bus_match(struct device *dev, struct device_driver *drv);
 static int bcma_device_probe(struct device *dev);
 static int bcma_device_remove(struct device *dev);
@@ -55,7 +61,7 @@ static struct bus_type bcma_bus_type = {
        .dev_attrs      = bcma_device_attrs,
 };
 
-static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
+struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
 {
        struct bcma_device *core;
 
@@ -65,6 +71,7 @@ static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
        }
        return NULL;
 }
+EXPORT_SYMBOL_GPL(bcma_find_core);
 
 static void bcma_release_core_dev(struct device *dev)
 {
@@ -93,7 +100,7 @@ static int bcma_register_cores(struct bcma_bus *bus)
 
                core->dev.release = bcma_release_core_dev;
                core->dev.bus = &bcma_bus_type;
-               dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id);
+               dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
 
                switch (bus->hosttype) {
                case BCMA_HOSTTYPE_PCI:
@@ -132,11 +139,15 @@ static void bcma_unregister_cores(struct bcma_bus *bus)
        }
 }
 
-int bcma_bus_register(struct bcma_bus *bus)
+int __devinit bcma_bus_register(struct bcma_bus *bus)
 {
        int err;
        struct bcma_device *core;
 
+       mutex_lock(&bcma_buses_mutex);
+       bus->num = bcma_bus_next_num++;
+       mutex_unlock(&bcma_buses_mutex);
+
        /* Scan for devices (cores) */
        err = bcma_bus_scan(bus);
        if (err) {