Let bus space manage softc.
This commit is contained in:
parent
9189a12295
commit
e060a36d77
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user