Convert to prototypes, de'__P, use device_private, switch to aprint_*,

make things static, and some minor constification.
This commit is contained in:
matt 2008-02-25 19:22:39 +00:00
parent e73d7a75d0
commit 652f27646d
2 changed files with 72 additions and 110 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kauai.c,v 1.21 2007/10/17 19:55:18 garbled Exp $ */
/* $NetBSD: kauai.c,v 1.22 2008/02/25 19:22:39 matt Exp $ */
/*-
* Copyright (c) 2003 Tsubai Masanari. All rights reserved.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kauai.c,v 1.21 2007/10/17 19:55:18 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: kauai.c,v 1.22 2008/02/25 19:22:39 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -73,23 +73,20 @@ struct kauai_softc {
void (*sc_calc_timing)(struct kauai_softc *, int);
};
int kauai_match __P((struct device *, struct cfdata *, void *));
void kauai_attach __P((struct device *, struct device *, void *));
int kauai_dma_init __P((void *, int, int, void *, size_t, int));
void kauai_dma_start __P((void *, int, int));
int kauai_dma_finish __P((void *, int, int, int));
void kauai_set_modes __P((struct ata_channel *));
static void calc_timing_kauai __P((struct kauai_softc *, int));
static int kauai_match(device_t, cfdata_t, void *);
static void kauai_attach(device_t, device_t, void *);
static int kauai_dma_init(void *, int, int, void *, size_t, int);
static void kauai_dma_start(void *, int, int);
static int kauai_dma_finish(void *, int, int, int);
static void kauai_set_modes(struct ata_channel *);
static void calc_timing_kauai(struct kauai_softc *, int);
static int getnodebypci(pci_chipset_tag_t, pcitag_t);
CFATTACH_DECL(kauai, sizeof(struct kauai_softc),
kauai_match, kauai_attach, NULL, wdcactivate);
int
kauai_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
kauai_match(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
@ -106,11 +103,9 @@ kauai_match(parent, match, aux)
}
void
kauai_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
kauai_attach(device_t parent, device_t self, void *aux)
{
struct kauai_softc *sc = (void *)self;
struct kauai_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
struct ata_channel *chp = &sc->sc_channel;
struct wdc_regs *wdr;
@ -120,19 +115,19 @@ kauai_attach(parent, self, aux)
#ifdef DIAGNOSTIC
if ((vaddr_t)sc->sc_dmacmd & 0x0f) {
printf(": bad dbdma alignment\n");
aprint_error(": bad dbdma alignment\n");
return;
}
#endif
node = getnodebypci(pa->pa_pc, pa->pa_tag);
if (node == 0) {
printf(": cannot find kauai node\n");
aprint_error(": cannot find kauai node\n");
return;
}
if (OF_getprop(node, "assigned-addresses", reg, sizeof reg) < 12) {
printf(": cannot get address property\n");
aprint_error(": cannot get address property\n");
return;
}
regbase = reg[2] + 0x2000;
@ -148,10 +143,10 @@ kauai_attach(parent, self, aux)
}
if (pci_intr_map(pa, &ih)) {
printf(": unable to map interrupt\n");
aprint_error(": unable to map interrupt\n");
return;
}
printf(": interrupting at %s\n", pci_intr_string(pa->pa_pc, ih));
aprint_normal(": interrupting at %s\n", pci_intr_string(pa->pa_pc, ih));
sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;
@ -161,7 +156,7 @@ kauai_attach(parent, self, aux)
&wdr->cmd_baseioh) ||
bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_AUXREG_OFFSET << 4, 1, &wdr->ctl_ioh)) {
printf("%s: couldn't map registers\n", self->dv_xname);
aprint_error_dev(self, "couldn't map registers\n");
return;
}
for (i = 0; i < WDC_NREG; i++) {
@ -169,14 +164,14 @@ kauai_attach(parent, self, aux)
i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) {
bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_REG_NPORTS << 4);
printf("%s: couldn't subregion registers\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
aprint_error_dev(self,
"couldn't subregion registers\n");
return;
}
}
if (pci_intr_establish(pa->pa_pc, ih, IPL_BIO, wdcintr, chp) == NULL) {
printf("%s: unable to establish interrupt\n", self->dv_xname);
aprint_error_dev(self, "unable to establish interrupt\n");
return;
}
@ -207,8 +202,7 @@ kauai_attach(parent, self, aux)
}
void
kauai_set_modes(chp)
struct ata_channel *chp;
kauai_set_modes(struct ata_channel *chp)
{
struct kauai_softc *sc = (void *)chp->ch_atac;
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
@ -262,9 +256,7 @@ static const u_int udma_timing_kauai[] = { /* 0x0000ffff */
* Timing calculation for Kauai.
*/
void
calc_timing_kauai(sc, drive)
struct kauai_softc *sc;
int drive;
calc_timing_kauai(struct kauai_softc *sc, int drive)
{
struct ata_channel *chp = &sc->sc_channel;
struct ata_drive_datas *drvp = &chp->ch_drive[drive];
@ -289,11 +281,8 @@ calc_timing_kauai(sc, drive)
}
int
kauai_dma_init(v, channel, drive, databuf, datalen, flags)
void *v;
void *databuf;
size_t datalen;
int flags;
kauai_dma_init(void *v, int channel, int drive, void *databuf,
size_t datalen, int flags)
{
struct kauai_softc *sc = v;
dbdma_command_t *cmdp = sc->sc_dmacmd;
@ -346,9 +335,7 @@ kauai_dma_init(v, channel, drive, databuf, datalen, flags)
}
void
kauai_dma_start(v, channel, drive)
void *v;
int channel, drive;
kauai_dma_start(void *v, int channel, int drive)
{
struct kauai_softc *sc = v;
@ -356,10 +343,7 @@ kauai_dma_start(v, channel, drive)
}
int
kauai_dma_finish(v, channel, drive, read)
void *v;
int channel, drive;
int read;
kauai_dma_finish(void *v, int channel, int drive, int read)
{
struct kauai_softc *sc = v;
@ -371,9 +355,7 @@ kauai_dma_finish(v, channel, drive, read)
* Find OF-device corresponding to the PCI device.
*/
int
getnodebypci(pc, tag)
pci_chipset_tag_t pc;
pcitag_t tag;
getnodebypci(pci_chipset_tag_t pc, pcitag_t tag)
{
int bus, dev, func;
u_int reg[5];

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc_obio.c,v 1.47 2007/10/17 19:55:20 garbled Exp $ */
/* $NetBSD: wdc_obio.c,v 1.48 2008/02/25 19:22:39 matt Exp $ */
/*-
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.47 2007/10/17 19:55:20 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.48 2008/02/25 19:22:39 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -82,21 +82,21 @@ struct wdc_obio_softc {
void *sc_ih;
};
int wdc_obio_probe __P((struct device *, struct cfdata *, void *));
void wdc_obio_attach __P((struct device *, struct device *, void *));
int wdc_obio_detach __P((struct device *, int));
int wdc_obio_dma_init __P((void *, int, int, void *, size_t, int));
void wdc_obio_dma_start __P((void *, int, int));
int wdc_obio_dma_finish __P((void *, int, int, int));
static int wdc_obio_match(device_t, cfdata_t, void *);
static void wdc_obio_attach(device_t, device_t, void *);
static int wdc_obio_detach(device_t, int);
static int wdc_obio_dma_init(void *, int, int, void *, size_t, int);
static void wdc_obio_dma_start(void *, int, int);
static int wdc_obio_dma_finish(void *, int, int, int);
static void wdc_obio_select __P((struct ata_channel *, int));
static void adjust_timing __P((struct ata_channel *));
static void ata4_adjust_timing __P((struct ata_channel *));
static void wdc_obio_select(struct ata_channel *, int);
static void adjust_timing(struct ata_channel *);
static void ata4_adjust_timing(struct ata_channel *);
CFATTACH_DECL(wdc_obio, sizeof(struct wdc_obio_softc),
wdc_obio_probe, wdc_obio_attach, wdc_obio_detach, wdcactivate);
wdc_obio_match, wdc_obio_attach, wdc_obio_detach, wdcactivate);
static const char *ata_names[] = {
static const char * const ata_names[] = {
"heathrow-ata",
"keylargo-ata",
"ohare-ata",
@ -104,10 +104,7 @@ static const char *ata_names[] = {
};
int
wdc_obio_probe(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
wdc_obio_match(device_t parent, cfdata_t match, void *aux)
{
struct confargs *ca = aux;
@ -125,11 +122,9 @@ wdc_obio_probe(parent, match, aux)
}
void
wdc_obio_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
wdc_obio_attach(device_t parent, device_t self, void *aux)
{
struct wdc_obio_softc *sc = (void *)self;
struct wdc_obio_softc *sc = device_private(self);
struct wdc_regs *wdr;
struct confargs *ca = aux;
struct ata_channel *chp = &sc->sc_channel;
@ -145,23 +140,23 @@ wdc_obio_attach(parent, self, aux)
if (ca->ca_nintr >= 4 && ca->ca_nreg >= 8) {
intr = ca->ca_intr[0];
printf(" irq %d", intr);
aprint_normal(" irq %d", intr);
if (ca->ca_nintr > 8) {
type = ca->ca_intr[1] ? IST_LEVEL : IST_EDGE;
}
printf(", %s triggered", (type == IST_EDGE) ? "edge" : "level");
aprint_normal(", %s triggered", (type == IST_EDGE) ? "edge" : "level");
} else if (ca->ca_nintr == -1) {
intr = WDC_DEFAULT_PIO_IRQ;
printf(" irq property not found; using %d", intr);
aprint_normal(" irq property not found; using %d", intr);
} else {
printf(": couldn't get irq property\n");
aprint_error(": couldn't get irq property\n");
return;
}
if (use_dma)
printf(": DMA transfer");
aprint_normal(": DMA transfer");
printf("\n");
aprint_normal("\n");
sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;
@ -171,8 +166,7 @@ wdc_obio_attach(parent, self, aux)
WDC_REG_NPORTS << 4, 0, &wdr->cmd_baseioh) ||
bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_AUXREG_OFFSET << 4, 1, &wdr->ctl_ioh)) {
printf("%s: couldn't map registers\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
aprint_error_dev(self, "couldn't map registers\n");
return;
}
@ -181,8 +175,8 @@ wdc_obio_attach(parent, self, aux)
i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) {
bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_REG_NPORTS << 4);
printf("%s: couldn't subregion registers\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
aprint_error_dev(self,
"couldn't subregion registers\n");
return;
}
}
@ -207,8 +201,8 @@ wdc_obio_attach(parent, self, aux)
if (bus_space_map(wdr->cmd_iot, ca->ca_baseaddr + ca->ca_reg[2],
0x100, BUS_SPACE_MAP_LINEAR, &sc->sc_dmaregh)) {
aprint_error("%s: unable to map DMA registers (%08x)\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname,
aprint_error_dev(self,
"unable to map DMA registers (%08x)\n",
ca->ca_reg[2]);
/* should unmap stuff here */
return;
@ -274,25 +268,25 @@ struct ide_timings {
int cycle; /* minimum cycle time [ns] */
int active; /* minimum command active time [ns] */
};
static struct ide_timings pio_timing[5] = {
static const struct ide_timings pio_timing[5] = {
{ 600, 180 }, /* Mode 0 */
{ 390, 150 }, /* 1 */
{ 240, 105 }, /* 2 */
{ 180, 90 }, /* 3 */
{ 120, 75 } /* 4 */
};
static struct ide_timings dma_timing[3] = {
static const struct ide_timings dma_timing[3] = {
{ 480, 240 }, /* Mode 0 */
{ 165, 90 }, /* Mode 1 */
{ 120, 75 } /* Mode 2 */
};
static struct ide_timings udma_timing[5] = {
{120, 180}, /* Mode 0 */
{ 90, 150}, /* Mode 1 */
{ 60, 120}, /* Mode 2 */
{ 45, 90}, /* Mode 3 */
{ 30, 90} /* Mode 4 */
static const struct ide_timings udma_timing[5] = {
{ 120, 180 }, /* Mode 0 */
{ 90, 150 }, /* Mode 1 */
{ 60, 120 }, /* Mode 2 */
{ 45, 90 }, /* Mode 3 */
{ 30, 90 } /* Mode 4 */
};
#define TIME_TO_TICK(time) howmany((time), 30)
@ -308,9 +302,7 @@ static struct ide_timings udma_timing[5] = {
#define CONFIG_REG (0x200) /* IDE access timing register */
void
wdc_obio_select(chp, drive)
struct ata_channel *chp;
int drive;
wdc_obio_select(struct ata_channel *chp, int drive)
{
struct wdc_obio_softc *sc = (struct wdc_obio_softc *)chp->ch_atac;
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
@ -320,8 +312,7 @@ wdc_obio_select(chp, drive)
}
void
adjust_timing(chp)
struct ata_channel *chp;
adjust_timing(struct ata_channel *chp)
{
struct wdc_obio_softc *sc = (struct wdc_obio_softc *)chp->ch_atac;
int drive;
@ -386,8 +377,7 @@ adjust_timing(chp)
}
void
ata4_adjust_timing(chp)
struct ata_channel *chp;
ata4_adjust_timing(struct ata_channel *chp)
{
struct wdc_obio_softc *sc = (struct wdc_obio_softc *)chp->ch_atac;
int drive;
@ -454,11 +444,9 @@ ata4_adjust_timing(chp)
}
int
wdc_obio_detach(self, flags)
struct device *self;
int flags;
wdc_obio_detach(device_t self, int flags)
{
struct wdc_obio_softc *sc = (void *)self;
struct wdc_obio_softc *sc = device_private(self);
int error;
if ((error = wdcdetach(self, flags)) != 0)
@ -478,11 +466,8 @@ wdc_obio_detach(self, flags)
}
int
wdc_obio_dma_init(v, channel, drive, databuf, datalen, flags)
void *v;
void *databuf;
size_t datalen;
int flags;
wdc_obio_dma_init(void *v, int channel, int drive, void *databuf,
size_t datalen, int flags)
{
struct wdc_obio_softc *sc = v;
vaddr_t va = (vaddr_t)databuf;
@ -531,9 +516,7 @@ wdc_obio_dma_init(v, channel, drive, databuf, datalen, flags)
}
void
wdc_obio_dma_start(v, channel, drive)
void *v;
int channel, drive;
wdc_obio_dma_start(void *v, int channel, int drive)
{
struct wdc_obio_softc *sc = v;
@ -541,10 +524,7 @@ wdc_obio_dma_start(v, channel, drive)
}
int
wdc_obio_dma_finish(v, channel, drive, read)
void *v;
int channel, drive;
int read;
wdc_obio_dma_finish(void *v, int channel, int drive, int read)
{
struct wdc_obio_softc *sc = v;