Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jul 2012 04:17:49 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238334 - head/sys/arm/at91
Message-ID:  <201207100417.q6A4HnV9059065@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Jul 10 04:17:49 2012
New Revision: 238334
URL: http://svn.freebsd.org/changeset/base/238334

Log:
  Collapse all copies of at91_add_child into at91.c.  They were
  logically identical before today, and actually identical after today's
  changes.

Modified:
  head/sys/arm/at91/at91.c
  head/sys/arm/at91/at91rm9200.c
  head/sys/arm/at91/at91sam9260.c
  head/sys/arm/at91/at91sam9g20.c
  head/sys/arm/at91/at91sam9x25.c
  head/sys/arm/at91/at91var.h

Modified: head/sys/arm/at91/at91.c
==============================================================================
--- head/sys/arm/at91/at91.c	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91.c	Tue Jul 10 04:17:49 2012	(r238334)
@@ -270,10 +270,12 @@ at91_attach(device_t dev)
 	}
 
 
-	/* Our device list will be added automatically by the cpu device
+	/*
+         * Our device list will be added automatically by the cpu device
 	 * e.g. at91rm9200.c when it is identified. To ensure that the
 	 * CPU and PMC are attached first any other "identified" devices
-	 * call BUS_ADD_CHILD(9) with an "order" of at least 2. */
+	 * call BUS_ADD_CHILD(9) with an "order" of at least 2.
+         */
 
 	bus_generic_probe(dev);
 	bus_generic_attach(dev);
@@ -471,6 +473,41 @@ at91_eoi(void *unused)
 	    IC_EOICR, 0);
 }
 
+void
+at91_add_child(device_t dev, int prio, const char *name, int unit,
+    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2)
+{
+	device_t kid;
+	struct at91_ivar *ivar;
+
+	kid = device_add_child_ordered(dev, prio, name, unit);
+	if (kid == NULL) {
+	    printf("Can't add child %s%d ordered\n", name, unit);
+	    return;
+	}
+	ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
+	if (ivar == NULL) {
+		device_delete_child(dev, kid);
+		printf("Can't add alloc ivar\n");
+		return;
+	}
+	device_set_ivars(kid, ivar);
+	resource_list_init(&ivar->resources);
+	if (irq0 != -1) {
+		bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1);
+		if (irq0 != AT91_IRQ_SYSTEM)
+			at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0);
+	}
+	if (irq1 != 0)
+		bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1);
+	if (irq2 != 0)
+		bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1);
+	if (addr != 0 && addr < AT91_BASE) 
+		addr += AT91_BASE;
+	if (addr != 0)
+		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
+}
+
 static device_method_t at91_methods[] = {
 	DEVMETHOD(device_probe, at91_probe),
 	DEVMETHOD(device_attach, at91_attach),

Modified: head/sys/arm/at91/at91rm9200.c
==============================================================================
--- head/sys/arm/at91/at91rm9200.c	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91rm9200.c	Tue Jul 10 04:17:49 2012	(r238334)
@@ -137,41 +137,6 @@ static const struct cpu_devs at91_devs[]
 };
 
 static void
-at91_add_child(device_t dev, int prio, const char *name, int unit,
-    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2)
-{
-	device_t kid;
-	struct at91_ivar *ivar;
-
-	kid = device_add_child_ordered(dev, prio, name, unit);
-	if (kid == NULL) {
-	    printf("Can't add child %s%d ordered\n", name, unit);
-	    return;
-	}
-	ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (ivar == NULL) {
-		device_delete_child(dev, kid);
-		printf("Can't add alloc ivar\n");
-		return;
-	}
-	device_set_ivars(kid, ivar);
-	resource_list_init(&ivar->resources);
-	if (irq0 != -1) {
-		bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1);
-		if (irq0 != AT91_IRQ_SYSTEM)
-			at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0);
-	}
-	if (irq1 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1);
-	if (irq2 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1);
-	if (addr != 0 && addr < AT91_BASE)
-		addr += AT91_BASE;
-	if (addr != 0)
-		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
-}
-
-static void
 at91_cpu_add_builtin_children(device_t dev)
 {
 	int i;

Modified: head/sys/arm/at91/at91sam9260.c
==============================================================================
--- head/sys/arm/at91/at91sam9260.c	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91sam9260.c	Tue Jul 10 04:17:49 2012	(r238334)
@@ -130,41 +130,6 @@ static const struct cpu_devs at91_devs[]
 };
 
 static void
-at91_add_child(device_t dev, int prio, const char *name, int unit,
-    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2)
-{
-	device_t kid;
-	struct at91_ivar *ivar;
-
-	kid = device_add_child_ordered(dev, prio, name, unit);
-	if (kid == NULL) {
-	    printf("Can't add child %s%d ordered\n", name, unit);
-	    return;
-	}
-	ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (ivar == NULL) {
-		device_delete_child(dev, kid);
-		printf("Can't add alloc ivar\n");
-		return;
-	}
-	device_set_ivars(kid, ivar);
-	resource_list_init(&ivar->resources);
-	if (irq0 != -1) {
-		bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1);
-		if (irq0 != AT91_IRQ_SYSTEM)
-			at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0);
-	}
-	if (irq1 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1);
-	if (irq2 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1);
-	if (addr != 0 && addr < AT91_BASE)
-		addr += AT91_BASE;
-	if (addr != 0)
-		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
-}
-
-static void
 at91_cpu_add_builtin_children(device_t dev)
 {
 	int i;

Modified: head/sys/arm/at91/at91sam9g20.c
==============================================================================
--- head/sys/arm/at91/at91sam9g20.c	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91sam9g20.c	Tue Jul 10 04:17:49 2012	(r238334)
@@ -130,41 +130,6 @@ static const struct cpu_devs at91_devs[]
 };
 
 static void
-at91_add_child(device_t dev, int prio, const char *name, int unit,
-    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2)
-{
-	device_t kid;
-	struct at91_ivar *ivar;
-
-	kid = device_add_child_ordered(dev, prio, name, unit);
-	if (kid == NULL) {
-		printf("Can't add child %s%d ordered\n", name, unit);
-		return;
-	}
-	ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (ivar == NULL) {
-		device_delete_child(dev, kid);
-		printf("Can't add alloc ivar\n");
-		return;
-	}
-	device_set_ivars(kid, ivar);
-	resource_list_init(&ivar->resources);
-	if (irq0 != -1) {
-		bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1);
-		if (irq0 != AT91_IRQ_SYSTEM)
-			at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0);
-	}
-	if (irq1 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1);
-	if (irq2 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1);
-	if (addr != 0 && addr < AT91_BASE)
-		addr += AT91_BASE;
-	if (addr != 0)
-		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
-}
-
-static void
 at91_cpu_add_builtin_children(device_t dev)
 {
 	int i;

Modified: head/sys/arm/at91/at91sam9x25.c
==============================================================================
--- head/sys/arm/at91/at91sam9x25.c	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91sam9x25.c	Tue Jul 10 04:17:49 2012	(r238334)
@@ -133,41 +133,6 @@ static const struct cpu_devs at91_devs[]
 };
 
 static void
-at91_add_child(device_t dev, int prio, const char *name, int unit,
-    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2)
-{
-	device_t kid;
-	struct at91_ivar *ivar;
-
-	kid = device_add_child_ordered(dev, prio, name, unit);
-	if (kid == NULL) {
-	    printf("Can't add child %s%d ordered\n", name, unit);
-	    return;
-	}
-	ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (ivar == NULL) {
-		device_delete_child(dev, kid);
-		printf("Can't add alloc ivar\n");
-		return;
-	}
-	device_set_ivars(kid, ivar);
-	resource_list_init(&ivar->resources);
-	if (irq0 != -1) {
-		bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1);
-		if (irq0 != AT91_IRQ_SYSTEM)
-			at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0);
-	}
-	if (irq1 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1);
-	if (irq2 != 0)
-		bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1);
-	if (addr != 0 && addr < AT91_BASE) 
-		addr += AT91_BASE;
-	if (addr != 0)
-		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
-}
-
-static void
 at91_cpu_add_builtin_children(device_t dev)
 {
 	int i;

Modified: head/sys/arm/at91/at91var.h
==============================================================================
--- head/sys/arm/at91/at91var.h	Tue Jul 10 03:48:07 2012	(r238333)
+++ head/sys/arm/at91/at91var.h	Tue Jul 10 04:17:49 2012	(r238334)
@@ -151,6 +151,9 @@ at91_cpu_is(u_int cpu)
 	return (soc_data.type == cpu);
 }
 
+void at91_add_child(device_t dev, int prio, const char *name, int unit,
+    bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2);
+
 extern uint32_t at91_irq_system;
 extern uint32_t at91_master_clock;
 void at91_pmc_init_clock(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207100417.q6A4HnV9059065>