Commit 6e094bd8 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by John W. Linville

bcma: move code for core registration into separate function

This cleans code a bit and will us to register cores in other places as
well. The only difference with this patch is using "core_index" for
setting device name.
Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Acked-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ed364abf
...@@ -120,32 +120,13 @@ static void bcma_release_core_dev(struct device *dev) ...@@ -120,32 +120,13 @@ static void bcma_release_core_dev(struct device *dev)
kfree(core); kfree(core);
} }
static int bcma_register_cores(struct bcma_bus *bus) static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
{ {
struct bcma_device *core; int err;
int err, dev_id = 0;
list_for_each_entry(core, &bus->cores, list) {
/* We support that cores ourself */
switch (core->id.id) {
case BCMA_CORE_4706_CHIPCOMMON:
case BCMA_CORE_CHIPCOMMON:
case BCMA_CORE_PCI:
case BCMA_CORE_PCIE:
case BCMA_CORE_PCIE2:
case BCMA_CORE_MIPS_74K:
case BCMA_CORE_4706_MAC_GBIT_COMMON:
continue;
}
/* Only first GMAC core on BCM4706 is connected and working */
if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
core->core_unit > 0)
continue;
core->dev.release = bcma_release_core_dev; core->dev.release = bcma_release_core_dev;
core->dev.bus = &bcma_bus_type; core->dev.bus = &bcma_bus_type;
dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id); dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
switch (bus->hosttype) { switch (bus->hosttype) {
case BCMA_HOSTTYPE_PCI: case BCMA_HOSTTYPE_PCI:
...@@ -163,14 +144,38 @@ static int bcma_register_cores(struct bcma_bus *bus) ...@@ -163,14 +144,38 @@ static int bcma_register_cores(struct bcma_bus *bus)
err = device_register(&core->dev); err = device_register(&core->dev);
if (err) { if (err) {
bcma_err(bus, bcma_err(bus, "Could not register dev for core 0x%03X\n",
"Could not register dev for core 0x%03X\n",
core->id.id); core->id.id);
put_device(&core->dev); put_device(&core->dev);
continue; return;
} }
core->dev_registered = true; core->dev_registered = true;
dev_id++; }
static int bcma_register_devices(struct bcma_bus *bus)
{
struct bcma_device *core;
int err;
list_for_each_entry(core, &bus->cores, list) {
/* We support that cores ourself */
switch (core->id.id) {
case BCMA_CORE_4706_CHIPCOMMON:
case BCMA_CORE_CHIPCOMMON:
case BCMA_CORE_PCI:
case BCMA_CORE_PCIE:
case BCMA_CORE_PCIE2:
case BCMA_CORE_MIPS_74K:
case BCMA_CORE_4706_MAC_GBIT_COMMON:
continue;
}
/* Only first GMAC core on BCM4706 is connected and working */
if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
core->core_unit > 0)
continue;
bcma_register_core(bus, core);
} }
#ifdef CONFIG_BCMA_DRIVER_MIPS #ifdef CONFIG_BCMA_DRIVER_MIPS
...@@ -297,7 +302,7 @@ int bcma_bus_register(struct bcma_bus *bus) ...@@ -297,7 +302,7 @@ int bcma_bus_register(struct bcma_bus *bus)
} }
/* Register found cores */ /* Register found cores */
bcma_register_cores(bus); bcma_register_devices(bus);
bcma_info(bus, "Bus registered\n"); bcma_info(bus, "Bus registered\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment