PERFORCE change 123496 for review
Christopher Davis
loafier at FreeBSD.org
Sat Jul 14 19:42:49 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123496
Change 123496 by loafier at chrisdsoc on 2007/07/14 19:42:02
Added back edits and sound driver template.
Affected files ...
.. //depot/projects/soc2007/loafier_busalloc/src/share/examples/drivers/template.c#1 add
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_mci.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_pio.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_rtc.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_spi.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_ssc.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_twi.c#2 edit
.. //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/if_ate.c#2 edit
Differences ...
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_mci.c#2 (text+ko) ====
@@ -63,14 +63,25 @@
#define BBSZ 512
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec mci_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 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
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_pio.c#2 (text) ====
@@ -42,12 +42,23 @@
#include <arm/at91/at91_pioreg.h>
#include <arm/at91/at91_piovar.h>
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec pio_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE},
+ {-1, 0, 0}
+};
+
struct at91_pio_softc
{
device_t dev; /* Myself */
void *intrhand; /* Interrupt handle */
- 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; /* basically a perimeter lock */
struct cdev *cdev;
int flags;
@@ -57,13 +68,13 @@
static inline uint32_t
RD4(struct at91_pio_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_pio_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);
}
#define AT91_PIO_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
@@ -148,7 +159,7 @@
* Activate the interrupt, but disable all interrupts in the hardware
*/
WR4(sc, PIO_IDR, 0xffffffff);
- err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
+ err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC,
at91_pio_intr, NULL, sc, &sc->intrhand);
if (err) {
AT91_PIO_LOCK_DESTROY(sc);
@@ -177,23 +188,15 @@
at91_pio_activate(device_t dev)
{
struct at91_pio_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 | RF_SHAREABLE);
- if (sc->irq_res == NULL)
- goto errout;
+
+ if (bus_alloc_resources(dev, pio_res_spec, sc->res)) {
+ at91_pio_deactivate(dev);
+ return (ENOMEM);
+ }
+
return (0);
-errout:
- at91_pio_deactivate(dev);
- return (ENOMEM);
}
static void
@@ -203,18 +206,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, pio_res_spec, sc->res);
}
static int
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_rtc.c#2 (text) ====
@@ -43,25 +43,36 @@
#include "clock_if.h"
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec rtc_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE},
+ {-1, 0, 0}
+};
+
struct at91_rtc_softc
{
device_t dev; /* Myself */
void *intrhand; /* Interrupt handle */
- 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; /* basically a perimeter lock */
};
static inline uint32_t
RD4(struct at91_rtc_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_rtc_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);
}
#define AT91_RTC_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
@@ -110,7 +121,7 @@
* Activate the interrupt, but disable all interrupts in the hardware
*/
WR4(sc, RTC_IDR, 0xffffffff);
- err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
+ err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC,
at91_rtc_intr, NULL, sc, &sc->intrhand);
if (err) {
AT91_RTC_LOCK_DESTROY(sc);
@@ -133,23 +144,15 @@
at91_rtc_activate(device_t dev)
{
struct at91_rtc_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 | RF_SHAREABLE);
- if (sc->irq_res == NULL)
- goto errout;
+
+ if (bus_alloc_resources(dev, rtc_res_spec, sc->res)) {
+ at91_rtc_deactivate(dev);
+ return (ENOMEM);
+ }
+
return (0);
-errout:
- at91_rtc_deactivate(dev);
- return (ENOMEM);
}
static void
@@ -159,18 +162,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, rtc_res_spec, sc->res);
}
static int
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_spi.c#2 (text) ====
@@ -43,12 +43,23 @@
#include <dev/spibus/spi.h>
#include "spibus_if.h"
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec spi_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE},
+ {-1, 0, 0}
+};
+
struct at91_spi_softc
{
device_t dev; /* Myself */
void *intrhand; /* Interrupt handle */
- struct resource *irq_res; /* IRQ resource */
- struct resource *mem_res; /* Memory resource */
+ struct resource *res[RES_SZ]; /* IRQ and Memory resource */
bus_dma_tag_t dmatag; /* bus dma tag for mbufs */
bus_dmamap_t map[4]; /* Maps for the transaction */
int rxdone;
@@ -57,13 +68,13 @@
static inline uint32_t
RD4(struct at91_spi_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_spi_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 */
@@ -149,20 +160,14 @@
at91_spi_activate(device_t dev)
{
struct at91_spi_softc *sc;
- int rid, err = ENOMEM;
+ int err = ENOMEM;
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)
+
+ if (bus_alloc_resources(dev, spi_res_spec, sc->res))
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;
- 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_spi_intr, sc, &sc->intrhand);
if (err != 0)
goto errout;
@@ -179,18 +184,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, spi_res_spec, sc->res);
}
static void
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_ssc.c#2 (text) ====
@@ -38,12 +38,23 @@
#include <arm/at91/at91_sscreg.h>
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec ssc_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE},
+ {-1, 0, 0}
+};
+
struct at91_ssc_softc
{
device_t dev; /* Myself */
void *intrhand; /* Interrupt handle */
- 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; /* basically a perimeter lock */
struct cdev *cdev;
int flags;
@@ -53,13 +64,13 @@
static inline uint32_t
RD4(struct at91_ssc_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_ssc_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);
}
#define AT91_SSC_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
@@ -123,7 +134,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_ssc_intr, sc, &sc->intrhand);
if (err) {
AT91_SSC_LOCK_DESTROY(sc);
@@ -165,23 +176,15 @@
at91_ssc_activate(device_t dev)
{
struct at91_ssc_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, ssc_res_spec, sc->res)) {
+ at91_ssc_deactivate(dev);
+ return (ENOMEM);
+ }
+
return (0);
-errout:
- at91_ssc_deactivate(dev);
- return (ENOMEM);
}
static void
@@ -191,18 +194,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, ssc_res_spec, sc->res);
}
static void
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/at91_twi.c#2 (text) ====
@@ -49,12 +49,23 @@
#define TWI_FAST_CLOCK 45000
#define TWI_FASTEST_CLOCK 90000
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec twi_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE},
+ {-1, 0, 0}
+};
+
struct at91_twi_softc
{
device_t dev; /* Myself */
void *intrhand; /* Interrupt handle */
- struct resource *irq_res; /* IRQ resource */
- struct resource *mem_res; /* Memory resource */
+ struct resource *res[RES_SZ]; /* IRQ & Memory resources */
struct mtx sc_mtx; /* basically a perimeter lock */
volatile uint32_t flags;
uint32_t cwgr;
@@ -66,13 +77,13 @@
static inline uint32_t
RD4(struct at91_twi_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_twi_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);
}
#define AT91_TWI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
@@ -121,7 +132,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_twi_intr, sc, &sc->intrhand);
if (err) {
AT91_TWI_LOCK_DESTROY(sc);
@@ -162,23 +173,15 @@
at91_twi_activate(device_t dev)
{
struct at91_twi_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, twi_res_spec, sc->res)) {
+ at91_twi_deactivate(dev);
+ return (ENOMEM);
+ }
+
return (0);
-errout:
- at91_twi_deactivate(dev);
- return (ENOMEM);
}
static void
@@ -188,18 +191,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, twi_res_spec, sc->res);
}
static void
==== //depot/projects/soc2007/loafier_busalloc/src/sys/arm/at91/if_ate.c#2 (text) ====
@@ -75,6 +75,18 @@
#define ATE_MAX_TX_BUFFERS 2 /* We have ping-pong tx buffers */
#define ATE_MAX_RX_BUFFERS 64
+enum {
+ RES_MEM,
+ RES_IRQ,
+ RES_SZ
+};
+
+static struct resource_spec ate_res_spec[] = {
+ {SYS_RES_MEMORY, 0, RF_ACTIVE},
+ {SYS_RES_IRQ, 0, RF_ACTIVE},
+ {-1, 0, 0}
+};
+
struct ate_softc
{
struct ifnet *ifp; /* ifnet pointer */
@@ -82,8 +94,7 @@
device_t dev; /* Myself */
device_t miibus; /* My child miibus */
void *intrhand; /* Interrupt handle */
- struct resource *irq_res; /* IRQ resource */
- struct resource *mem_res; /* Memory resource */
+ struct resource *res[RES_SZ]; /* IRQ & Memory resources */
struct callout tick_ch; /* Tick callout */
bus_dma_tag_t mtag; /* bus dma tag for mbufs */
bus_dmamap_t tx_map[ATE_MAX_TX_BUFFERS];
@@ -104,13 +115,13 @@
static inline uint32_t
RD4(struct ate_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 ate_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);
}
#define ATE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
@@ -225,7 +236,7 @@
/*
* Activate the interrupt
*/
- err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
+ err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_NET | INTR_MPSAFE,
NULL, ate_intr, sc, &sc->intrhand);
if (err) {
ether_ifdetach(ifp);
@@ -324,20 +335,12 @@
ate_activate(device_t dev)
{
struct ate_softc *sc;
- int rid, err, i;
+ int err, i;
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)
+ if (bus_alloc_resources(dev, ate_res_spec, sc->res))
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;
-
+
/*
* Allocate DMA tags and maps
*/
@@ -441,20 +444,12 @@
bus_dma_tag_destroy(sc->mcs_tag);
#endif
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->miibus)
device_delete_child(sc->dev, sc->miibus);
- 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, ate_res_spec, sc->res);
}
/*
More information about the p4-projects
mailing list