| 1 | From eecd733c14952b074d7488934a4f3dc83c9c426b Mon Sep 17 00:00:00 2001 |
| 2 | From: Hauke Mehrtens <hauke@hauke-m.de> |
| 3 | Date: Sat, 14 Jan 2012 16:29:51 +0100 |
| 4 | Subject: [PATCH 28/32] bcma: add bus num counter |
| 5 | |
| 6 | If we have two bcma buses on one computer the second will not work |
| 7 | without this patch. Now each bus gets an own number. |
| 8 | |
| 9 | Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> |
| 10 | --- |
| 11 | drivers/bcma/main.c | 12 +++++++++++- |
| 12 | include/linux/bcma/bcma.h | 1 + |
| 13 | 2 files changed, 12 insertions(+), 1 deletions(-) |
| 14 | |
| 15 | --- a/drivers/bcma/main.c |
| 16 | +++ b/drivers/bcma/main.c |
| 17 | @@ -13,6 +13,12 @@ |
| 18 | MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); |
| 19 | MODULE_LICENSE("GPL"); |
| 20 | |
| 21 | +/* contains the number the next bus should get. */ |
| 22 | +static unsigned int bcma_bus_next_num = 0; |
| 23 | + |
| 24 | +/* bcma_buses_mutex locks the bcma_bus_next_num */ |
| 25 | +static DEFINE_MUTEX(bcma_buses_mutex); |
| 26 | + |
| 27 | static int bcma_bus_match(struct device *dev, struct device_driver *drv); |
| 28 | static int bcma_device_probe(struct device *dev); |
| 29 | static int bcma_device_remove(struct device *dev); |
| 30 | @@ -93,7 +99,7 @@ static int bcma_register_cores(struct bc |
| 31 | |
| 32 | core->dev.release = bcma_release_core_dev; |
| 33 | core->dev.bus = &bcma_bus_type; |
| 34 | - dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id); |
| 35 | + dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id); |
| 36 | |
| 37 | switch (bus->hosttype) { |
| 38 | case BCMA_HOSTTYPE_PCI: |
| 39 | @@ -137,6 +143,10 @@ int __devinit bcma_bus_register(struct b |
| 40 | int err; |
| 41 | struct bcma_device *core; |
| 42 | |
| 43 | + mutex_lock(&bcma_buses_mutex); |
| 44 | + bus->num = bcma_bus_next_num++; |
| 45 | + mutex_unlock(&bcma_buses_mutex); |
| 46 | + |
| 47 | /* Scan for devices (cores) */ |
| 48 | err = bcma_bus_scan(bus); |
| 49 | if (err) { |
| 50 | --- a/include/linux/bcma/bcma.h |
| 51 | +++ b/include/linux/bcma/bcma.h |
| 52 | @@ -196,6 +196,7 @@ struct bcma_bus { |
| 53 | struct list_head cores; |
| 54 | u8 nr_cores; |
| 55 | u8 init_done:1; |
| 56 | + u8 num; |
| 57 | |
| 58 | struct bcma_drv_cc drv_cc; |
| 59 | struct bcma_drv_pci drv_pci; |
| 60 | |