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

Commit aab0d375 authored by Kay Sievers's avatar Kay Sievers Committed by Paul Mackerras
Browse files

powerpc: struct device - replace bus_id with dev_name(), dev_set_name()

parent f63837f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
#include <asm/abs_addr.h>

static struct device ibmebus_bus_device = { /* fake "parent" device */
	.bus_id = "ibmebus",
	.init_name = "ibmebus",
};

struct bus_type ibmebus_bus_type;
+7 −11
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ static void of_device_make_bus_id(struct of_device *dev)
{
	static atomic_t bus_no_reg_magic;
	struct device_node *node = dev->node;
	char *name = dev->dev.bus_id;
	const u32 *reg;
	u64 addr;
	int magic;
@@ -27,14 +26,12 @@ static void of_device_make_bus_id(struct of_device *dev)
	reg = of_get_property(node, "dcr-reg", NULL);
	if (reg) {
#ifdef CONFIG_PPC_DCR_NATIVE
		snprintf(name, BUS_ID_SIZE, "d%x.%s",
			 *reg, node->name);
		dev_set_name(&dev->dev, "d%x.%s", *reg, node->name);
#else /* CONFIG_PPC_DCR_NATIVE */
		addr = of_translate_dcr_address(node, *reg, NULL);
		if (addr != OF_BAD_ADDR) {
			snprintf(name, BUS_ID_SIZE,
				 "D%llx.%s", (unsigned long long)addr,
				 node->name);
			dev_set_name(&dev->dev, "D%llx.%s",
				     (unsigned long long)addr, node->name);
			return;
		}
#endif /* !CONFIG_PPC_DCR_NATIVE */
@@ -48,9 +45,8 @@ static void of_device_make_bus_id(struct of_device *dev)
	if (reg) {
		addr = of_translate_address(node, reg);
		if (addr != OF_BAD_ADDR) {
			snprintf(name, BUS_ID_SIZE,
				 "%llx.%s", (unsigned long long)addr,
				 node->name);
			dev_set_name(&dev->dev, "%llx.%s",
				     (unsigned long long)addr, node->name);
			return;
		}
	}
@@ -60,7 +56,7 @@ static void of_device_make_bus_id(struct of_device *dev)
	 * counter (and pray...)
	 */
	magic = atomic_add_return(1, &bus_no_reg_magic);
	snprintf(name, BUS_ID_SIZE, "%s.%d", node->name, magic - 1);
	dev_set_name(&dev->dev, "%s.%d", node->name, magic - 1);
}

struct of_device *of_device_alloc(struct device_node *np,
@@ -80,7 +76,7 @@ struct of_device *of_device_alloc(struct device_node *np,
	dev->dev.archdata.of_node = np;

	if (bus_id)
		strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
		dev_set_name(&dev->dev, bus_id);
	else
		of_device_make_bus_id(dev);

+6 −6
Original line number Diff line number Diff line
@@ -41,9 +41,9 @@
static struct bus_type vio_bus_type;

static struct vio_dev vio_bus_device  = { /* fake "parent" device */
	.name = vio_bus_device.dev.bus_id,
	.name = "vio",
	.type = "",
	.dev.bus_id = "vio",
	.dev.init_name = "vio",
	.dev.bus = &vio_bus_type,
};

@@ -1216,7 +1216,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)

	viodev->irq = irq_of_parse_and_map(of_node, 0);

	snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
	dev_set_name(&viodev->dev, "%x", *unit_address);
	viodev->name = of_node->name;
	viodev->type = of_node->type;
	viodev->unit_address = *unit_address;
@@ -1243,7 +1243,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
	/* register with generic device framework */
	if (device_register(&viodev->dev)) {
		printk(KERN_ERR "%s: failed to register device %s\n",
				__func__, viodev->dev.bus_id);
				__func__, dev_name(&viodev->dev));
		/* XXX free TCE table */
		kfree(viodev);
		return NULL;
@@ -1400,13 +1400,13 @@ static struct vio_dev *vio_find_name(const char *name)
struct vio_dev *vio_find_node(struct device_node *vnode)
{
	const uint32_t *unit_address;
	char kobj_name[BUS_ID_SIZE];
	char kobj_name[20];

	/* construct the kobject name from the device node */
	unit_address = of_get_property(vnode, "reg", NULL);
	if (!unit_address)
		return NULL;
	snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address);
	snprintf(kobj_name, sizeof(kobj_name), "%x", *unit_address);

	return vio_find_name(kobj_name);
}
+3 −3
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ static void __init mpc85xx_mds_setup_arch(void)

static int __init board_fixups(void)
{
	char phy_id[BUS_ID_SIZE];
	char phy_id[20];
	char *compstrs[2] = {"fsl,gianfar-mdio", "fsl,ucc-mdio"};
	struct device_node *mdio;
	struct resource res;
@@ -241,14 +241,14 @@ static int __init board_fixups(void)
		mdio = of_find_compatible_node(NULL, NULL, compstrs[i]);

		of_address_to_resource(mdio, 0, &res);
		snprintf(phy_id, BUS_ID_SIZE, "%llx:%02x",
		snprintf(phy_id, sizeof(phy_id), "%llx:%02x",
			(unsigned long long)res.start, 1);

		phy_register_fixup_for_id(phy_id, mpc8568_fixup_125_clock);
		phy_register_fixup_for_id(phy_id, mpc8568_mds_phy_fixups);

		/* Register a workaround for errata */
		snprintf(phy_id, BUS_ID_SIZE, "%llx:%02x",
		snprintf(phy_id, sizeof(phy_id), "%llx:%02x",
			(unsigned long long)res.start, 7);
		phy_register_fixup_for_id(phy_id, mpc8568_mds_phy_fixups);

+12 −16
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#include "platform.h"

static struct device ps3_system_bus = {
	.bus_id = "ps3_system",
	.init_name = "ps3_system",
};

/* FIXME: need device usage counters! */
@@ -356,12 +356,12 @@ static int ps3_system_bus_match(struct device *_dev,
	if (result)
		pr_info("%s:%d: dev=%u.%u(%s), drv=%u.%u(%s): match\n",
			__func__, __LINE__,
			dev->match_id, dev->match_sub_id, dev->core.bus_id,
			dev->match_id, dev->match_sub_id, dev_name(&dev->core),
			drv->match_id, drv->match_sub_id, drv->core.name);
	else
		pr_debug("%s:%d: dev=%u.%u(%s), drv=%u.%u(%s): miss\n",
			__func__, __LINE__,
			dev->match_id, dev->match_sub_id, dev->core.bus_id,
			dev->match_id, dev->match_sub_id, dev_name(&dev->core),
			drv->match_id, drv->match_sub_id, drv->core.name);

	return result;
@@ -383,9 +383,9 @@ static int ps3_system_bus_probe(struct device *_dev)
		result = drv->probe(dev);
	else
		pr_debug("%s:%d: %s no probe method\n", __func__, __LINE__,
			dev->core.bus_id);
			dev_name(&dev->core));

	pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev->core.bus_id);
	pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev_name(&dev->core));
	return result;
}

@@ -407,7 +407,7 @@ static int ps3_system_bus_remove(struct device *_dev)
		dev_dbg(&dev->core, "%s:%d %s: no remove method\n",
			__func__, __LINE__, drv->core.name);

	pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev->core.bus_id);
	pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev_name(&dev->core));
	return result;
}

@@ -432,7 +432,7 @@ static void ps3_system_bus_shutdown(struct device *_dev)
	BUG_ON(!drv);

	dev_dbg(&dev->core, "%s:%d: %s -> %s\n", __func__, __LINE__,
		dev->core.bus_id, drv->core.name);
		dev_name(&dev->core), drv->core.name);

	if (drv->shutdown)
		drv->shutdown(dev);
@@ -744,22 +744,18 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
	switch (dev->dev_type) {
	case PS3_DEVICE_TYPE_IOC0:
		dev->core.archdata.dma_ops = &ps3_ioc0_dma_ops;
		snprintf(dev->core.bus_id, sizeof(dev->core.bus_id),
			"ioc0_%02x", ++dev_ioc0_count);
		dev_set_name(&dev->core, "ioc0_%02x", ++dev_ioc0_count);
		break;
	case PS3_DEVICE_TYPE_SB:
		dev->core.archdata.dma_ops = &ps3_sb_dma_ops;
		snprintf(dev->core.bus_id, sizeof(dev->core.bus_id),
			"sb_%02x", ++dev_sb_count);
		dev_set_name(&dev->core, "sb_%02x", ++dev_sb_count);

		break;
	case PS3_DEVICE_TYPE_VUART:
		snprintf(dev->core.bus_id, sizeof(dev->core.bus_id),
			"vuart_%02x", ++dev_vuart_count);
		dev_set_name(&dev->core, "vuart_%02x", ++dev_vuart_count);
		break;
	case PS3_DEVICE_TYPE_LPM:
		snprintf(dev->core.bus_id, sizeof(dev->core.bus_id),
			"lpm_%02x", ++dev_lpm_count);
		dev_set_name(&dev->core, "lpm_%02x", ++dev_lpm_count);
		break;
	default:
		BUG();
@@ -768,7 +764,7 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
	dev->core.archdata.of_node = NULL;
	set_dev_node(&dev->core, 0);

	pr_debug("%s:%d add %s\n", __func__, __LINE__, dev->core.bus_id);
	pr_debug("%s:%d add %s\n", __func__, __LINE__, dev_name(&dev->core));

	result = device_register(&dev->core);
	return result;