Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+36 −31
Original line number Diff line number Diff line
@@ -120,32 +120,13 @@ static void bcma_release_core_dev(struct device *dev)
	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, 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;
	int err;

	core->dev.release = bcma_release_core_dev;
	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) {
	case BCMA_HOSTTYPE_PCI:
@@ -163,14 +144,38 @@ static int bcma_register_cores(struct bcma_bus *bus)

	err = device_register(&core->dev);
	if (err) {
			bcma_err(bus,
				 "Could not register dev for core 0x%03X\n",
		bcma_err(bus, "Could not register dev for core 0x%03X\n",
			 core->id.id);
		put_device(&core->dev);
			continue;
		return;
	}
	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
@@ -297,7 +302,7 @@ int bcma_bus_register(struct bcma_bus *bus)
	}

	/* Register found cores */
	bcma_register_cores(bus);
	bcma_register_devices(bus);

	bcma_info(bus, "Bus registered\n");