Convert amr(4) to device_t (CFATTACH_DECL_NEW).
This commit is contained in:
parent
414b1de06c
commit
8f128a3925
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: amr.c,v 1.54 2010/11/13 13:52:05 uebayasi Exp $ */
|
||||
/* $NetBSD: amr.c,v 1.55 2012/07/27 16:25:11 jakllsch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.54 2010/11/13 13:52:05 uebayasi Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: amr.c,v 1.55 2012/07/27 16:25:11 jakllsch Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -112,7 +112,7 @@ static dev_type_open(amropen);
|
|||
static dev_type_close(amrclose);
|
||||
static dev_type_ioctl(amrioctl);
|
||||
|
||||
CFATTACH_DECL(amr, sizeof(struct amr_softc),
|
||||
CFATTACH_DECL_NEW(amr, sizeof(struct amr_softc),
|
||||
amr_match, amr_attach, NULL, NULL);
|
||||
|
||||
const struct cdevsw amr_cdevsw = {
|
||||
|
@ -270,6 +270,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
aprint_naive(": RAID controller\n");
|
||||
|
||||
amr = device_private(self);
|
||||
amr->amr_dv = self;
|
||||
pa = (struct pci_attach_args *)aux;
|
||||
pc = pa->pa_pc;
|
||||
|
||||
|
@ -348,7 +349,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
|
||||
if ((rv = bus_dmamem_alloc(amr->amr_dmat, size, PAGE_SIZE, 0,
|
||||
&amr->amr_dmaseg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "unable to allocate buffer, rv = %d\n",
|
||||
aprint_error_dev(amr->amr_dv, "unable to allocate buffer, rv = %d\n",
|
||||
rv);
|
||||
amr_teardown(amr);
|
||||
return;
|
||||
|
@ -358,7 +359,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
if ((rv = bus_dmamem_map(amr->amr_dmat, &amr->amr_dmaseg, rseg, size,
|
||||
(void **)&amr->amr_mbox,
|
||||
BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "unable to map buffer, rv = %d\n",
|
||||
aprint_error_dev(amr->amr_dv, "unable to map buffer, rv = %d\n",
|
||||
rv);
|
||||
amr_teardown(amr);
|
||||
return;
|
||||
|
@ -367,7 +368,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
|
||||
if ((rv = bus_dmamap_create(amr->amr_dmat, size, 1, size, 0,
|
||||
BUS_DMA_NOWAIT, &amr->amr_dmamap)) != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "unable to create buffer DMA map, rv = %d\n",
|
||||
aprint_error_dev(amr->amr_dv, "unable to create buffer DMA map, rv = %d\n",
|
||||
rv);
|
||||
amr_teardown(amr);
|
||||
return;
|
||||
|
@ -376,7 +377,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
|
||||
if ((rv = bus_dmamap_load(amr->amr_dmat, amr->amr_dmamap,
|
||||
amr->amr_mbox, size, NULL, BUS_DMA_NOWAIT)) != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "unable to load buffer DMA map, rv = %d\n",
|
||||
aprint_error_dev(amr->amr_dv, "unable to load buffer DMA map, rv = %d\n",
|
||||
rv);
|
||||
amr_teardown(amr);
|
||||
return;
|
||||
|
@ -415,7 +416,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
amr_ccb_free(amr, ac);
|
||||
}
|
||||
if (i != AMR_MAX_CMDS) {
|
||||
aprint_error_dev(&amr->amr_dv, "memory exhausted\n");
|
||||
aprint_error_dev(amr->amr_dv, "memory exhausted\n");
|
||||
amr_teardown(amr);
|
||||
return;
|
||||
}
|
||||
|
@ -473,7 +474,7 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
|
||||
locs[AMRCF_UNIT] = j;
|
||||
|
||||
amr->amr_drive[j].al_dv = config_found_sm_loc(&amr->amr_dv,
|
||||
amr->amr_drive[j].al_dv = config_found_sm_loc(amr->amr_dv,
|
||||
"amr", locs, &amra, amr_print, config_stdsubmatch);
|
||||
}
|
||||
|
||||
|
@ -482,9 +483,9 @@ amr_attach(device_t parent, device_t self, void *aux)
|
|||
/* XXX This doesn't work for newer boards yet. */
|
||||
if ((apt->apt_flags & AT_QUARTZ) == 0) {
|
||||
rv = kthread_create(PRI_NONE, 0, NULL, amr_thread, amr,
|
||||
&amr->amr_thread, "%s", device_xname(&amr->amr_dv));
|
||||
&amr->amr_thread, "%s", device_xname(amr->amr_dv));
|
||||
if (rv != 0)
|
||||
aprint_error_dev(&amr->amr_dv, "unable to create thread (%d)",
|
||||
aprint_error_dev(amr->amr_dv, "unable to create thread (%d)",
|
||||
rv);
|
||||
else
|
||||
amr->amr_flags |= AMRF_THREAD;
|
||||
|
@ -571,9 +572,9 @@ amr_init(struct amr_softc *amr, const char *intrstr,
|
|||
if (ap != NULL) {
|
||||
aprint_normal("<%.80s>\n", ap->ap_product);
|
||||
if (intrstr != NULL)
|
||||
aprint_normal_dev(&amr->amr_dv, "interrupting at %s\n",
|
||||
aprint_normal_dev(amr->amr_dv, "interrupting at %s\n",
|
||||
intrstr);
|
||||
aprint_normal_dev(&amr->amr_dv, "firmware %.16s, BIOS %.16s, %dMB RAM\n",
|
||||
aprint_normal_dev(amr->amr_dv, "firmware %.16s, BIOS %.16s, %dMB RAM\n",
|
||||
ap->ap_firmware, ap->ap_bios,
|
||||
le16toh(ap->ap_memsize));
|
||||
|
||||
|
@ -585,19 +586,19 @@ amr_init(struct amr_softc *amr, const char *intrstr,
|
|||
aex = amr_enquire(amr, AMR_CMD_CONFIG, AMR_CONFIG_ENQ3,
|
||||
AMR_CONFIG_ENQ3_SOLICITED_FULL, amr->amr_enqbuf);
|
||||
if (aex == NULL) {
|
||||
aprint_error_dev(&amr->amr_dv, "ENQUIRY3 failed\n");
|
||||
aprint_error_dev(amr->amr_dv, "ENQUIRY3 failed\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (aex->ae_numldrives > __arraycount(aex->ae_drivestate)) {
|
||||
aprint_error_dev(&amr->amr_dv, "Inquiry returned more drives (%d)"
|
||||
aprint_error_dev(amr->amr_dv, "Inquiry returned more drives (%d)"
|
||||
" than the array can handle (%zu)\n",
|
||||
aex->ae_numldrives,
|
||||
__arraycount(aex->ae_drivestate));
|
||||
aex->ae_numldrives = __arraycount(aex->ae_drivestate);
|
||||
}
|
||||
if (aex->ae_numldrives > AMR_MAX_UNITS) {
|
||||
aprint_error_dev(&amr->amr_dv,
|
||||
aprint_error_dev(amr->amr_dv,
|
||||
"adjust AMR_MAX_UNITS to %d (currently %d)"
|
||||
"\n", AMR_MAX_UNITS,
|
||||
amr->amr_numdrives);
|
||||
|
@ -638,7 +639,7 @@ amr_init(struct amr_softc *amr, const char *intrstr,
|
|||
} else {
|
||||
ae = amr_enquire(amr, AMR_CMD_ENQUIRY, 0, 0, amr->amr_enqbuf);
|
||||
if (ae == NULL) {
|
||||
aprint_error_dev(&amr->amr_dv, "unsupported controller\n");
|
||||
aprint_error_dev(amr->amr_dv, "unsupported controller\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -679,16 +680,16 @@ amr_init(struct amr_softc *amr, const char *intrstr,
|
|||
|
||||
aprint_normal("<%s>\n", prodstr);
|
||||
if (intrstr != NULL)
|
||||
aprint_normal_dev(&amr->amr_dv, "interrupting at %s\n",
|
||||
aprint_normal_dev(amr->amr_dv, "interrupting at %s\n",
|
||||
intrstr);
|
||||
|
||||
if (ishp)
|
||||
aprint_normal_dev(&amr->amr_dv, "firmware <%c.%02d.%02d>, BIOS <%c.%02d.%02d>"
|
||||
aprint_normal_dev(amr->amr_dv, "firmware <%c.%02d.%02d>, BIOS <%c.%02d.%02d>"
|
||||
", %dMB RAM\n", aa->aa_firmware[2],
|
||||
aa->aa_firmware[1], aa->aa_firmware[0], aa->aa_bios[2],
|
||||
aa->aa_bios[1], aa->aa_bios[0], aa->aa_memorysize);
|
||||
else
|
||||
aprint_normal_dev(&amr->amr_dv, "firmware <%.4s>, BIOS <%.4s>, %dMB RAM\n",
|
||||
aprint_normal_dev(amr->amr_dv, "firmware <%.4s>, BIOS <%.4s>, %dMB RAM\n",
|
||||
aa->aa_firmware, aa->aa_bios,
|
||||
aa->aa_memorysize);
|
||||
|
||||
|
@ -698,14 +699,14 @@ amr_init(struct amr_softc *amr, const char *intrstr,
|
|||
* Record state of logical drives.
|
||||
*/
|
||||
if (ae->ae_ldrv.al_numdrives > __arraycount(ae->ae_ldrv.al_size)) {
|
||||
aprint_error_dev(&amr->amr_dv, "Inquiry returned more drives (%d)"
|
||||
aprint_error_dev(amr->amr_dv, "Inquiry returned more drives (%d)"
|
||||
" than the array can handle (%zu)\n",
|
||||
ae->ae_ldrv.al_numdrives,
|
||||
__arraycount(ae->ae_ldrv.al_size));
|
||||
ae->ae_ldrv.al_numdrives = __arraycount(ae->ae_ldrv.al_size);
|
||||
}
|
||||
if (ae->ae_ldrv.al_numdrives > AMR_MAX_UNITS) {
|
||||
aprint_error_dev(&amr->amr_dv, "adjust AMR_MAX_UNITS to %d (currently %d)\n",
|
||||
aprint_error_dev(amr->amr_dv, "adjust AMR_MAX_UNITS to %d (currently %d)\n",
|
||||
ae->ae_ldrv.al_numdrives,
|
||||
AMR_MAX_UNITS);
|
||||
amr->amr_numdrives = AMR_MAX_UNITS;
|
||||
|
@ -745,7 +746,7 @@ amr_shutdown(void *cookie)
|
|||
amr_ccb_free(amr, ac);
|
||||
}
|
||||
if (rv != 0)
|
||||
aprint_error_dev(&amr->amr_dv, "unable to flush cache (%d)\n", rv);
|
||||
aprint_error_dev(amr->amr_dv, "unable to flush cache (%d)\n", rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,13 +772,13 @@ amr_intr(void *cookie)
|
|||
|
||||
if (idx >= amr->amr_maxqueuecnt) {
|
||||
printf("%s: bad status (bogus ID: %u=%u)\n",
|
||||
device_xname(&amr->amr_dv), i, idx);
|
||||
device_xname(amr->amr_dv), i, idx);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ac->ac_flags & AC_ACTIVE) == 0) {
|
||||
printf("%s: bad status (not active; 0x04%x)\n",
|
||||
device_xname(&amr->amr_dv), ac->ac_flags);
|
||||
device_xname(amr->amr_dv), ac->ac_flags);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -788,7 +789,7 @@ amr_intr(void *cookie)
|
|||
|
||||
if ((ac->ac_flags & AC_MOAN) != 0)
|
||||
printf("%s: ccb %d completed\n",
|
||||
device_xname(&amr->amr_dv), ac->ac_ident);
|
||||
device_xname(amr->amr_dv), ac->ac_ident);
|
||||
|
||||
/* Pass notification to upper layers. */
|
||||
if (ac->ac_handler != NULL)
|
||||
|
@ -837,7 +838,7 @@ amr_thread(void *cookie)
|
|||
break;
|
||||
if ((ac->ac_flags & AC_MOAN) == 0) {
|
||||
printf("%s: ccb %d timed out; mailbox:\n",
|
||||
device_xname(&amr->amr_dv), ac->ac_ident);
|
||||
device_xname(amr->amr_dv), ac->ac_ident);
|
||||
amr_ccb_dump(amr, ac);
|
||||
ac->ac_flags |= AC_MOAN;
|
||||
}
|
||||
|
@ -847,7 +848,7 @@ amr_thread(void *cookie)
|
|||
|
||||
if ((rv = amr_ccb_alloc(amr, &ac)) != 0) {
|
||||
printf("%s: ccb_alloc failed (%d)\n",
|
||||
device_xname(&amr->amr_dv), rv);
|
||||
device_xname(amr->amr_dv), rv);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -856,7 +857,7 @@ amr_thread(void *cookie)
|
|||
rv = amr_ccb_map(amr, ac, amr->amr_enqbuf,
|
||||
AMR_ENQUIRY_BUFSIZE, AC_XFER_IN);
|
||||
if (rv != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "ccb_map failed (%d)\n",
|
||||
aprint_error_dev(amr->amr_dv, "ccb_map failed (%d)\n",
|
||||
rv);
|
||||
amr_ccb_free(amr, ac);
|
||||
continue;
|
||||
|
@ -865,7 +866,7 @@ amr_thread(void *cookie)
|
|||
rv = amr_ccb_wait(amr, ac);
|
||||
amr_ccb_unmap(amr, ac);
|
||||
if (rv != 0) {
|
||||
aprint_error_dev(&amr->amr_dv, "enquiry failed (st=%d)\n",
|
||||
aprint_error_dev(amr->amr_dv, "enquiry failed (st=%d)\n",
|
||||
ac->ac_status);
|
||||
continue;
|
||||
}
|
||||
|
@ -1140,7 +1141,7 @@ amr_mbox_wait(struct amr_softc *amr)
|
|||
}
|
||||
|
||||
if (timo == 0)
|
||||
printf("%s: controller wedged\n", device_xname(&amr->amr_dv));
|
||||
printf("%s: controller wedged\n", device_xname(amr->amr_dv));
|
||||
|
||||
return (timo != 0 ? 0 : EAGAIN);
|
||||
}
|
||||
|
@ -1292,7 +1293,7 @@ amr_ccb_dump(struct amr_softc *amr, struct amr_ccb *ac)
|
|||
{
|
||||
int i;
|
||||
|
||||
printf("%s: ", device_xname(&amr->amr_dv));
|
||||
printf("%s: ", device_xname(amr->amr_dv));
|
||||
for (i = 0; i < 4; i++)
|
||||
printf("%08x ", ((u_int32_t *)&ac->ac_cmd)[i]);
|
||||
printf("\n");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: amrvar.h,v 1.8 2008/04/28 20:23:54 martin Exp $ */
|
||||
/* $NetBSD: amrvar.h,v 1.9 2012/07/27 16:25:11 jakllsch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -46,14 +46,14 @@ struct amr_logdrive {
|
|||
u_int al_size;
|
||||
u_short al_state;
|
||||
u_short al_properties;
|
||||
struct device *al_dv;
|
||||
device_t al_dv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Per-controller state.
|
||||
*/
|
||||
struct amr_softc {
|
||||
struct device amr_dv;
|
||||
device_t amr_dv;
|
||||
bus_space_tag_t amr_iot;
|
||||
bus_space_handle_t amr_ioh;
|
||||
bus_size_t amr_ios;
|
||||
|
@ -120,7 +120,7 @@ struct amr_ccb {
|
|||
bus_dmamap_t ac_xfer_map;
|
||||
void (*ac_handler)(struct amr_ccb *);
|
||||
void *ac_context;
|
||||
struct device *ac_dv;
|
||||
device_t ac_dv;
|
||||
struct amr_mailbox_cmd ac_cmd;
|
||||
};
|
||||
#define AC_XFER_IN 0x01 /* Map describes inbound xfer */
|
||||
|
|
Loading…
Reference in New Issue