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

Commit 88ca0557 authored by Rob Herring's avatar Rob Herring Committed by David S. Miller
Browse files

sparc: Use device_type helpers to access the node type



Remove directly accessing device_node.type pointer and use the accessors
instead. This will eventually allow removing the type pointer.

Replace the open coded iterating over child nodes with
for_each_child_of_node() while we're here.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29c990df
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@


static int of_bus_pci_match(struct device_node *np)
static int of_bus_pci_match(struct device_node *np)
{
{
	if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) {
	if (of_node_is_type(np, "pci") || of_node_is_type(np, "pciex")) {
		/* Do not do PCI specific frobbing if the
		/* Do not do PCI specific frobbing if the
		 * PCI bridge lacks a ranges property.  We
		 * PCI bridge lacks a ranges property.  We
		 * want to pass it through up to the next
		 * want to pass it through up to the next
@@ -107,7 +107,7 @@ static unsigned long of_bus_sbus_get_flags(const u32 *addr, unsigned long flags)


static int of_bus_ambapp_match(struct device_node *np)
static int of_bus_ambapp_match(struct device_node *np)
{
{
	return !strcmp(np->type, "ambapp");
	return of_node_is_type(np, "ambapp");
}
}


static void of_bus_ambapp_count_cells(struct device_node *child,
static void of_bus_ambapp_count_cells(struct device_node *child,
+2 −7
Original line number Original line Diff line number Diff line
@@ -267,7 +267,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
	struct dev_archdata *sd;
	struct dev_archdata *sd;
	struct platform_device *op;
	struct platform_device *op;
	struct pci_dev *dev;
	struct pci_dev *dev;
	const char *type;
	u32 class;
	u32 class;


	dev = pci_alloc_dev(bus);
	dev = pci_alloc_dev(bus);
@@ -286,13 +285,9 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
	if (of_node_name_eq(node, "ebus"))
	if (of_node_name_eq(node, "ebus"))
		of_propagate_archdata(op);
		of_propagate_archdata(op);


	type = of_get_property(node, "device_type", NULL);
	if (type == NULL)
		type = "";

	if (ofpci_verbose)
	if (ofpci_verbose)
		pci_info(bus,"    create device, devfn: %x, type: %s\n",
		pci_info(bus,"    create device, devfn: %x, type: %s\n",
			 devfn, type);
			 devfn, of_node_get_device_type(node));


	dev->sysdata = node;
	dev->sysdata = node;
	dev->dev.parent = bus->bridge;
	dev->dev.parent = bus->bridge;
@@ -340,7 +335,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
		/* a PCI-PCI bridge */
		/* a PCI-PCI bridge */
		dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
		dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
		dev->rom_base_reg = PCI_ROM_ADDRESS1;
		dev->rom_base_reg = PCI_ROM_ADDRESS1;
	} else if (!strcmp(type, "cardbus")) {
	} else if (of_node_is_type(node, "cardbus")) {
		dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
		dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
	} else {
	} else {
		dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
		dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
+1 −1
Original line number Original line Diff line number Diff line
@@ -110,7 +110,7 @@ void machine_restart(char * cmd)
void machine_power_off(void)
void machine_power_off(void)
{
{
	if (auxio_power_register &&
	if (auxio_power_register &&
	    (strcmp(of_console_device->type, "serial") || scons_pwroff)) {
	    (!of_node_is_type(of_console_device, "serial") || scons_pwroff)) {
		u8 power_register = sbus_readb(auxio_power_register);
		u8 power_register = sbus_readb(auxio_power_register);
		power_register |= AUXIO_POWER_OFF;
		power_register |= AUXIO_POWER_OFF;
		sbus_writeb(power_register, auxio_power_register);
		sbus_writeb(power_register, auxio_power_register);
+7 −13
Original line number Original line Diff line number Diff line
@@ -182,14 +182,14 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
	struct device_node *parent = dp->parent;
	struct device_node *parent = dp->parent;


	if (parent != NULL) {
	if (parent != NULL) {
		if (!strcmp(parent->type, "pci") ||
		if (of_node_is_type(parent, "pci") ||
		    !strcmp(parent->type, "pciex"))
		    of_node_is_type(parent, "pciex"))
			return pci_path_component(dp, tmp_buf);
			return pci_path_component(dp, tmp_buf);
		if (!strcmp(parent->type, "sbus"))
		if (of_node_is_type(parent, "sbus"))
			return sbus_path_component(dp, tmp_buf);
			return sbus_path_component(dp, tmp_buf);
		if (!strcmp(parent->type, "ebus"))
		if (of_node_is_type(parent, "ebus"))
			return ebus_path_component(dp, tmp_buf);
			return ebus_path_component(dp, tmp_buf);
		if (!strcmp(parent->type, "ambapp"))
		if (of_node_is_type(parent, "ambapp"))
			return ambapp_path_component(dp, tmp_buf);
			return ambapp_path_component(dp, tmp_buf);


		/* "isa" is handled with platform naming */
		/* "isa" is handled with platform naming */
@@ -284,15 +284,9 @@ void __init of_console_init(void)
			prom_halt();
			prom_halt();
		}
		}
		dp = of_find_node_by_phandle(node);
		dp = of_find_node_by_phandle(node);
		type = of_get_property(dp, "device_type", NULL);


		if (!type) {
		if (!of_node_is_type(dp, "display") &&
			prom_printf("Console stdout lacks "
		    !of_node_is_type(dp, "serial")) {
				    "device_type property.\n");
			prom_halt();
		}

		if (strcmp(type, "display") && strcmp(type, "serial")) {
			prom_printf("Console device_type is neither display "
			prom_printf("Console device_type is neither display "
				    "nor serial.\n");
				    "nor serial.\n");
			prom_halt();
			prom_halt();
+9 −15
Original line number Original line Diff line number Diff line
@@ -318,20 +318,20 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
	struct device_node *parent = dp->parent;
	struct device_node *parent = dp->parent;


	if (parent != NULL) {
	if (parent != NULL) {
		if (!strcmp(parent->type, "pci") ||
		if (of_node_is_type(parent, "pci") ||
		    !strcmp(parent->type, "pciex")) {
		    of_node_is_type(parent, "pciex")) {
			pci_path_component(dp, tmp_buf);
			pci_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "sbus")) {
		if (of_node_is_type(parent, "sbus")) {
			sbus_path_component(dp, tmp_buf);
			sbus_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "upa")) {
		if (of_node_is_type(parent, "upa")) {
			upa_path_component(dp, tmp_buf);
			upa_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "ebus")) {
		if (of_node_is_type(parent, "ebus")) {
			ebus_path_component(dp, tmp_buf);
			ebus_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
@@ -340,15 +340,15 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
			usb_path_component(dp, tmp_buf);
			usb_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "i2c")) {
		if (of_node_is_type(parent, "i2c")) {
			i2c_path_component(dp, tmp_buf);
			i2c_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "firewire")) {
		if (of_node_is_type(parent, "firewire")) {
			ieee1394_path_component(dp, tmp_buf);
			ieee1394_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
		if (!strcmp(parent->type, "virtual-devices")) {
		if (of_node_is_type(parent, "virtual-devices")) {
			vdev_path_component(dp, tmp_buf);
			vdev_path_component(dp, tmp_buf);
			return;
			return;
		}
		}
@@ -605,7 +605,6 @@ void __init of_console_init(void)
{
{
	char *msg = "OF stdout device is: %s\n";
	char *msg = "OF stdout device is: %s\n";
	struct device_node *dp;
	struct device_node *dp;
	const char *type;
	phandle node;
	phandle node;


	of_console_path = prom_early_alloc(256);
	of_console_path = prom_early_alloc(256);
@@ -628,13 +627,8 @@ void __init of_console_init(void)
	}
	}


	dp = of_find_node_by_phandle(node);
	dp = of_find_node_by_phandle(node);
	type = of_get_property(dp, "device_type", NULL);
	if (!type) {
		prom_printf("Console stdout lacks device_type property.\n");
		prom_halt();
	}


	if (strcmp(type, "display") && strcmp(type, "serial")) {
	if (!of_node_is_type(dp, "display") && !of_node_is_type(dp, "serial")) {
		prom_printf("Console device_type is neither display "
		prom_printf("Console device_type is neither display "
			    "nor serial.\n");
			    "nor serial.\n");
		prom_halt();
		prom_halt();
Loading