summaryrefslogtreecommitdiffstats
path: root/sys/dev/aha
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-11-09 19:51:16 +0000
committerimp <imp@FreeBSD.org>2003-11-09 19:51:16 +0000
commite060a36d77eab7ddc10328b6d86ccbd6f044648f (patch)
tree0652da449588358cfb53cc4e077d8eb8e69e0d98 /sys/dev/aha
parent9189a12295dbbf9c9e8b80a6095bf5b7c3a24a8b (diff)
downloadFreeBSD-src-e060a36d77eab7ddc10328b6d86ccbd6f044648f.zip
FreeBSD-src-e060a36d77eab7ddc10328b6d86ccbd6f044648f.tar.gz
Let bus space manage softc.
Diffstat (limited to 'sys/dev/aha')
-rw-r--r--sys/dev/aha/aha.c13
-rw-r--r--sys/dev/aha/aha_isa.c24
-rw-r--r--sys/dev/aha/aha_mca.c12
-rw-r--r--sys/dev/aha/ahareg.h30
4 files changed, 23 insertions, 56 deletions
diff --git a/sys/dev/aha/aha.c b/sys/dev/aha/aha.c
index 12c882f..8762de2 100644
--- a/sys/dev/aha/aha.c
+++ b/sys/dev/aha/aha.c
@@ -198,16 +198,11 @@ static uint16_t aha_board_ports[] =
};
/* Exported functions */
-struct aha_softc *
-aha_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
+void
+aha_alloc(struct aha_softc *aha, int unit, bus_space_tag_t tag,
+ bus_space_handle_t bsh)
{
- struct aha_softc *aha;
- aha = malloc(sizeof(struct aha_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
- if (!aha) {
- printf("aha%d: cannot malloc!\n", unit);
- return NULL;
- }
SLIST_INIT(&aha->free_aha_ccbs);
LIST_INIT(&aha->pending_ccbs);
SLIST_INIT(&aha->sg_maps);
@@ -216,7 +211,6 @@ aha_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
aha->bsh = bsh;
aha->ccb_sg_opcode = INITIATOR_SG_CCB_WRESID;
aha->ccb_ccb_opcode = INITIATOR_CCB_WRESID;
- return (aha);
}
void
@@ -258,7 +252,6 @@ aha_free(struct aha_softc *aha)
case 0:
break;
}
- free(aha, M_DEVBUF);
}
/*
diff --git a/sys/dev/aha/aha_isa.c b/sys/dev/aha/aha_isa.c
index b734724..f52b2ba 100644
--- a/sys/dev/aha/aha_isa.c
+++ b/sys/dev/aha/aha_isa.c
@@ -72,8 +72,7 @@ aha_isa_probe(device_t dev)
/*
* find unit and check we have that many defined
*/
- struct aha_softc **sc = device_get_softc(dev);
- struct aha_softc *aha;
+ struct aha_softc *aha = device_get_softc(dev);
int port_index;
int max_port_index;
int error;
@@ -83,8 +82,6 @@ aha_isa_probe(device_t dev)
int drq;
int irq;
- aha = NULL;
-
/* Check isapnp ids */
if (ISA_PNP_PROBE(device_get_parent(dev), dev, aha_ids) == ENXIO)
return (ENXIO);
@@ -123,15 +120,9 @@ aha_isa_probe(device_t dev)
continue;
/* Allocate a softc for use during probing */
- aha = aha_alloc(device_get_unit(dev), rman_get_bustag(port_res),
+ aha_alloc(aha, device_get_unit(dev), rman_get_bustag(port_res),
rman_get_bushandle(port_res));
- if (aha == NULL) {
- bus_release_resource(dev, SYS_RES_IOPORT, port_rid,
- port_res);
- break;
- }
-
/* See if there is really a card present */
if (aha_probe(aha) || aha_fetch_adapter_info(aha)) {
aha_free(aha);
@@ -185,9 +176,6 @@ aha_isa_probe(device_t dev)
if (error)
return error;
- *sc = aha;
- aha_unit++;
-
return (0);
}
@@ -200,15 +188,13 @@ aha_isa_probe(device_t dev)
static int
aha_isa_attach(device_t dev)
{
- struct aha_softc **sc = device_get_softc(dev);
- struct aha_softc *aha;
+ struct aha_softc *aha = device_get_softc(dev);
bus_dma_filter_t *filter;
void *filter_arg;
bus_addr_t lowaddr;
void *ih;
int error;
- aha = *sc;
aha->portrid = 0;
aha->port = bus_alloc_resource(dev, SYS_RES_IOPORT, &aha->portrid,
0, ~0, AHA_NREGS, RF_ACTIVE);
@@ -304,7 +290,7 @@ aha_isa_attach(device_t dev)
static int
aha_isa_detach(device_t dev)
{
- struct aha_softc *aha = *(struct aha_softc **) device_get_softc(dev);
+ struct aha_softc *aha = (struct aha_softc *)device_get_softc(dev);
int error;
error = bus_teardown_intr(dev, aha->irq, aha->ih);
@@ -344,7 +330,7 @@ static device_method_t aha_isa_methods[] = {
static driver_t aha_isa_driver = {
"aha",
aha_isa_methods,
- sizeof(struct aha_softc*),
+ sizeof(struct aha_softc),
};
static devclass_t aha_devclass;
diff --git a/sys/dev/aha/aha_mca.c b/sys/dev/aha/aha_mca.c
index c3d4417..caa110f 100644
--- a/sys/dev/aha/aha_mca.c
+++ b/sys/dev/aha/aha_mca.c
@@ -110,15 +110,13 @@ aha_mca_probe (device_t dev)
mca_add_drq(dev, drq);
mca_add_irq(dev, irq);
- aha_unit++;
-
return (0);
}
static int
aha_mca_attach (device_t dev)
{
- struct aha_softc * sc = NULL;
+ struct aha_softc * sc = device_get_softc(dev);
struct resource * io = NULL;
struct resource * irq = NULL;
struct resource * drq = NULL;
@@ -154,13 +152,7 @@ aha_mca_attach (device_t dev)
goto bad;
}
- sc = aha_alloc(unit, rman_get_bustag(io), rman_get_bushandle(io));
- if (sc == NULL) {
- device_printf(dev, "aha_alloc() failed!\n");
- error = ENOMEM;
- goto bad;
- }
-
+ aha_alloc(sc, unit, rman_get_bustag(io), rman_get_bushandle(io));
error = aha_probe(sc);
if (error) {
device_printf(dev, "aha_probe() failed!\n");
diff --git a/sys/dev/aha/ahareg.h b/sys/dev/aha/ahareg.h
index 180b14f..f9aa12e 100644
--- a/sys/dev/aha/ahareg.h
+++ b/sys/dev/aha/ahareg.h
@@ -398,23 +398,19 @@ struct aha_softc {
void **ih;
};
-extern struct aha_softc *aha_softcs[]; /* XXX Config should handle this */
-extern u_long aha_unit;
-
-#define AHA_TEMP_UNIT 0xFF /* Unit for probes */
-struct aha_softc* aha_alloc(int, bus_space_tag_t, bus_space_handle_t);
-int aha_attach(struct aha_softc *);
-int aha_cmd(struct aha_softc *, aha_op_t, uint8_t *,
- u_int, uint8_t *, u_int, u_int);
-int aha_detach(struct aha_softc *);
-int aha_fetch_adapter_info(struct aha_softc *);
-void aha_find_probe_range(int, int *, int *);
-void aha_free(struct aha_softc *);
-int aha_init(struct aha_softc *);
-void aha_intr(void *);
-int aha_iop_from_bio(isa_compat_io_t);
-char * aha_name(struct aha_softc *);
-int aha_probe(struct aha_softc *);
+void aha_alloc(struct aha_softc *, int, bus_space_tag_t, bus_space_handle_t);
+int aha_attach(struct aha_softc *);
+int aha_cmd(struct aha_softc *, aha_op_t, uint8_t *, u_int, uint8_t *, u_int,
+ u_int);
+int aha_detach(struct aha_softc *);
+int aha_fetch_adapter_info(struct aha_softc *);
+void aha_find_probe_range(int, int *, int *);
+void aha_free(struct aha_softc *);
+int aha_init(struct aha_softc *);
+void aha_intr(void *);
+int aha_iop_from_bio(isa_compat_io_t);
+char *aha_name(struct aha_softc *);
+int aha_probe(struct aha_softc *);
#define DEFAULT_CMD_TIMEOUT 10000 /* 1 sec */
OpenPOWER on IntegriCloud