Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2007 12:04:18 GMT
From:      Christopher Davis <loafier@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123054 for review
Message-ID:  <200707071204.l67C4IVO092232@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123054

Change 123054 by loafier@chrisdsoc on 2007/07/07 12:04:09

	Missed one

Affected files ...

.. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_mci.c#2 edit

Differences ...

==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_mci.c#2 (text+ko) ====

@@ -63,14 +63,25 @@
 
 #define BBSZ	512
 
+enum {
+	RES_IRQ,
+	RES_MEM,
+	RES_SZ
+};
+
+static struct resource_spec mci_res_spec[] = {
+	{SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE},
+	{SYS_RES_MEMORY, 0, RF_ACTIVE},
+	{-1, 0, 0}
+};
+
 struct at91_mci_softc {
 	void *intrhand;			/* Interrupt handle */
 	device_t dev;
 	int flags;
 #define CMD_STARTED	1
 #define STOP_STARTED	2
-	struct resource *irq_res;	/* IRQ resource */
-	struct resource	*mem_res;	/* Memory resource */
+	struct resource	*res[RES_SZ];	/* IRQ and Memory resources */
 	struct mtx sc_mtx;
 	bus_dma_tag_t dmatag;
 	bus_dmamap_t map;
@@ -86,13 +97,13 @@
 static inline uint32_t
 RD4(struct at91_mci_softc *sc, bus_size_t off)
 {
-	return bus_read_4(sc->mem_res, off);
+	return bus_read_4(sc->res[RES_MEM], off);
 }
 
 static inline void
 WR4(struct at91_mci_softc *sc, bus_size_t off, uint32_t val)
 {
-	bus_write_4(sc->mem_res, off, val);
+	bus_write_4(sc->res[RES_MEM], off, val);
 }
 
 /* bus entry points */
@@ -191,7 +202,7 @@
 	/*
 	 * Activate the interrupt
 	 */
-	err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
+	err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC | INTR_MPSAFE,
 	    NULL, at91_mci_intr, sc, &sc->intrhand);
 	if (err) {
 		AT91_MCI_LOCK_DESTROY(sc);
@@ -222,23 +233,14 @@
 at91_mci_activate(device_t dev)
 {
 	struct at91_mci_softc *sc;
-	int rid;
 
 	sc = device_get_softc(dev);
-	rid = 0;
-	sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
-	    RF_ACTIVE);
-	if (sc->mem_res == NULL)
-		goto errout;
-	rid = 0;
-	sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
-	    RF_ACTIVE);
-	if (sc->irq_res == NULL)
-		goto errout;
+	if (bus_alloc_resources(dev, mci_res_spec, sc->res)) {	
+		at91_mci_deactivate(dev);
+		return (ENOMEM);
+	}
+
 	return (0);
-errout:
-	at91_mci_deactivate(dev);
-	return (ENOMEM);
 }
 
 static void
@@ -248,18 +250,10 @@
 
 	sc = device_get_softc(dev);
 	if (sc->intrhand)
-		bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
+		bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand);
 	sc->intrhand = 0;
 	bus_generic_detach(sc->dev);
-	if (sc->mem_res)
-		bus_release_resource(dev, SYS_RES_IOPORT,
-		    rman_get_rid(sc->mem_res), sc->mem_res);
-	sc->mem_res = 0;
-	if (sc->irq_res)
-		bus_release_resource(dev, SYS_RES_IRQ,
-		    rman_get_rid(sc->irq_res), sc->irq_res);
-	sc->irq_res = 0;
-	return;
+	bus_release_resources(dev, mci_res_spec, sc->res);
 }
 
 static void



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