diff options
| author | cube <cube@NetBSD.org> | 2008-03-18 20:46:35 +0000 |
|---|---|---|
| committer | cube <cube@NetBSD.org> | 2008-03-18 20:46:35 +0000 |
| commit | 7aa6248cdfde8d80960cbcd5742d38e5423761de (patch) | |
| tree | 2eb35c7a40d288793365d11d66727bc210920b60 /sys/dev | |
| parent | 0db6a6b0230a7ce748cf08924d67ae6b109f4b0f (diff) | |
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
Diffstat (limited to 'sys/dev')
47 files changed, 974 insertions, 946 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index c6296382bcc..2ee23429346 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.97 2008/02/29 06:38:28 dyoung Exp $ */ +/* $NetBSD: ata.c,v 1.98 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.97 2008/02/29 06:38:28 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.98 2008/03/18 20:46:36 cube Exp $"); #include "opt_ata.h" @@ -165,7 +165,7 @@ ata_channel_attach(struct ata_channel *chp) chp->ch_queue->queue_flags = 0; chp->ch_queue->active_xfer = NULL; - chp->atabus = config_found_ia(&chp->ch_atac->atac_dev, "ata", chp, + chp->atabus = config_found_ia(chp->ch_atac->atac_dev, "ata", chp, atabusprint); } @@ -219,7 +219,7 @@ atabusconfig(struct atabus_softc *atabus_sc) * Fake the autoconfig "not configured" message */ aprint_normal("atapibus at %s not configured\n", - device_xname(&atac->atac_dev)); + device_xname(atac->atac_dev)); chp->atapibus = NULL; s = splbio(); for (i = 0; i < chp->ch_ndrive; i++) @@ -241,7 +241,7 @@ atabusconfig(struct atabus_softc *atabus_sc) adev.adev_channel = chp->ch_channel; adev.adev_openings = 1; adev.adev_drv_data = &chp->ch_drive[i]; - chp->ata_drives[i] = config_found_ia(&atabus_sc->sc_dev, + chp->ata_drives[i] = config_found_ia(atabus_sc->sc_dev, "ata_hl", &adev, ataprint); if (chp->ata_drives[i] != NULL) ata_probe_caps(&chp->ch_drive[i]); @@ -406,6 +406,8 @@ atabus_attach(device_t parent, device_t self, void *aux) aprint_normal("\n"); aprint_naive("\n"); + sc->sc_dev = self; + if (ata_addref(chp)) return; @@ -575,7 +577,7 @@ atabus_childdetached(device_t self, device_t child) aprint_error_dev(self, "unknown child %p", (const void *)child); } -CFATTACH_DECL2(atabus, sizeof(struct atabus_softc), +CFATTACH_DECL2_NEW(atabus, sizeof(struct atabus_softc), atabus_match, atabus_attach, atabus_detach, atabus_activate, NULL, atabus_childdetached); @@ -1018,7 +1020,7 @@ ata_addref(struct ata_channel *chp) s = splbio(); if (adapt->adapt_refcnt++ == 0 && adapt->adapt_enable != NULL) { - error = (*adapt->adapt_enable)(&atac->atac_dev, 1); + error = (*adapt->adapt_enable)(atac->atac_dev, 1); if (error) adapt->adapt_refcnt--; } @@ -1036,7 +1038,7 @@ ata_delref(struct ata_channel *chp) s = splbio(); if (adapt->adapt_refcnt-- == 1 && adapt->adapt_enable != NULL) - (void) (*adapt->adapt_enable)(&atac->atac_dev, 0); + (void) (*adapt->adapt_enable)(atac->atac_dev, 0); splx(s); } @@ -1053,7 +1055,7 @@ ata_print_modes(struct ata_channel *chp) continue; aprint_verbose("%s(%s:%d:%d): using PIO mode %d", device_xname(drvp->drv_softc), - device_xname(&atac->atac_dev), + device_xname(atac->atac_dev), chp->ch_channel, drvp->drive, drvp->PIO_mode); #if NATA_DMA if (drvp->drive_flags & DRIVE_DMA) @@ -1119,8 +1121,9 @@ ata_downgrade_mode(struct ata_drive_datas *drvp, int flags) */ if ((drvp->drive_flags & DRIVE_UDMA) && drvp->UDMA_mode >= 2) { drvp->UDMA_mode--; - printf("%s: transfer error, downgrading to Ultra-DMA mode %d\n", - device_xname(drv_dev), drvp->UDMA_mode); + aprint_error_dev(drv_dev, + "transfer error, downgrading to Ultra-DMA mode %d\n", + drvp->UDMA_mode); } #endif @@ -1130,8 +1133,9 @@ ata_downgrade_mode(struct ata_drive_datas *drvp, int flags) else if (drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) { drvp->drive_flags &= ~(DRIVE_DMA | DRIVE_UDMA); drvp->PIO_mode = drvp->PIO_cap; - printf("%s: transfer error, downgrading to PIO mode %d\n", - device_xname(drv_dev), drvp->PIO_mode); + aprint_error_dev(drv_dev, + "transfer error, downgrading to PIO mode %d\n", + drvp->PIO_mode); } else /* already using PIO, can't downgrade */ return 0; @@ -1179,8 +1183,7 @@ ata_probe_caps(struct ata_drive_datas *drvp) drvp->drive_flags &= ~DRIVE_CAP32; splx(s); } else { - aprint_verbose("%s: 32-bit data port\n", - device_xname(drv_dev)); + aprint_verbose_dev(drv_dev, "32-bit data port\n"); } } #if 0 /* Some ultra-DMA drives claims to only support ATA-3. sigh */ @@ -1188,8 +1191,8 @@ ata_probe_caps(struct ata_drive_datas *drvp) params.atap_ata_major != 0xffff) { for (i = 14; i > 0; i--) { if (params.atap_ata_major & (1 << i)) { - aprint_verbose("%s: ATA version %d\n", - device_xname(drv_dev), i); + aprint_verbose_dev(drv_dev, + "ATA version %d\n", i); drvp->ata_vers = i; break; } @@ -1234,8 +1237,8 @@ ata_probe_caps(struct ata_drive_datas *drvp) AT_WAIT) != CMD_OK) continue; if (!printed) { - aprint_verbose("%s: drive supports PIO mode %d", - device_xname(drv_dev), i + 3); + aprint_verbose_dev(drv_dev, + "drive supports PIO mode %d", i + 3); sep = ","; printed = 1; } @@ -1411,7 +1414,7 @@ atabusopen(dev_t dev, int flag, int fmt, int error, unit = minor(dev); if (unit >= atabus_cd.cd_ndevs || - (sc = atabus_cd.cd_devs[unit]) == NULL) + (sc = device_private(atabus_cd.cd_devs[unit])) == NULL) return (ENXIO); if (sc->sc_flags & ATABUSCF_OPEN) @@ -1430,7 +1433,8 @@ int atabusclose(dev_t dev, int flag, int fmt, struct lwp *l) { - struct atabus_softc *sc = atabus_cd.cd_devs[minor(dev)]; + struct atabus_softc *sc = + device_private(atabus_cd.cd_devs[minor(dev)]); ata_delref(sc->sc_chan); @@ -1443,7 +1447,8 @@ int atabusioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { - struct atabus_softc *sc = atabus_cd.cd_devs[minor(dev)]; + struct atabus_softc *sc = + device_private(atabus_cd.cd_devs[minor(dev)]); struct ata_channel *chp = sc->sc_chan; int min_drive, max_drive, drive; int error; diff --git a/sys/dev/ata/ata_raid_adaptec.c b/sys/dev/ata/ata_raid_adaptec.c index 7a1c54ba89f..1bb9cb11580 100644 --- a/sys/dev/ata/ata_raid_adaptec.c +++ b/sys/dev/ata/ata_raid_adaptec.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_adaptec.c,v 1.7 2008/02/02 16:15:01 mjf Exp $ */ +/* $NetBSD: ata_raid_adaptec.c,v 1.8 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.7 2008/02/02 16:15:01 mjf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.8 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -78,10 +78,10 @@ ata_raid_read_config_adaptec(struct wd_softc *sc) info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK); - bmajor = devsw_name2blk(sc->sc_dev.dv_xname, NULL, 0); + bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0); /* Get a vnode for the raw partition of this disk. */ - dev = MAKEDISKDEV(bmajor, device_unit(&sc->sc_dev), RAW_PART); + dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART); error = bdevvp(dev, &vp); if (error) goto out; @@ -97,8 +97,8 @@ ata_raid_read_config_adaptec(struct wd_softc *sc) VOP_CLOSE(vp, FREAD, NOCRED); vput(vp); if (error) { - printf("%s: error %d reading Adaptec config block\n", - sc->sc_dev.dv_xname, error); + aprint_error_dev(sc->sc_dev, + "error %d reading Adaptec config block\n", error); goto out; } @@ -110,7 +110,7 @@ ata_raid_read_config_adaptec(struct wd_softc *sc) /* Check the signature. */ if (info->magic_0 != ADP_MAGIC_0 || info->magic_3 != ADP_MAGIC_3) { DPRINTF(("%s: Adaptec signature check failed\n", - sc->sc_dev.dv_xname)); + device_xname(sc->sc_dev))); error = ESRCH; goto out; } @@ -145,8 +145,9 @@ ata_raid_read_config_adaptec(struct wd_softc *sc) break; default: - aprint_error("%s: unknown Adaptec RAID type 0x%02x\n", - sc->sc_dev.dv_xname, info->configs[0].type); + aprint_error_dev(sc->sc_dev, + "unknown Adaptec RAID type 0x%02x\n", + info->configs[0].type); error = EINVAL; goto out; } @@ -165,18 +166,18 @@ ata_raid_read_config_adaptec(struct wd_softc *sc) aai->aai_interleave = aai->aai_capacity; } - atabus = (struct atabus_softc *) device_parent(&sc->sc_dev); + atabus = device_private(device_parent(sc->sc_dev)); drive = atabus->sc_chan->ch_channel; if (drive >= aai->aai_ndisks) { - aprint_error("%s: drive number %d doesn't make sense within " - "%d-disk array\n", - sc->sc_dev.dv_xname, drive, aai->aai_ndisks); + aprint_error_dev(sc->sc_dev, + "drive number %d doesn't make sense within %d-disk " + "array\n", drive, aai->aai_ndisks); error = EINVAL; goto out; } adi = &aai->aai_disks[drive]; - adi->adi_dev = &sc->sc_dev; + adi->adi_dev = sc->sc_dev; adi->adi_status = ADI_S_ONLINE | ADI_S_ASSIGNED; adi->adi_sectors = aai->aai_capacity; adi->adi_compsize = be32toh(info->configs[drive+1].sectors); diff --git a/sys/dev/ata/ata_raid_promise.c b/sys/dev/ata/ata_raid_promise.c index 7c06802bdee..a996bc6a0a7 100644 --- a/sys/dev/ata/ata_raid_promise.c +++ b/sys/dev/ata/ata_raid_promise.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_promise.c,v 1.10 2008/02/02 16:15:02 mjf Exp $ */ +/* $NetBSD: ata_raid_promise.c,v 1.11 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_promise.c,v 1.10 2008/02/02 16:15:02 mjf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_promise.c,v 1.11 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -78,10 +78,10 @@ ata_raid_read_config_promise(struct wd_softc *sc) info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK); - bmajor = devsw_name2blk(sc->sc_dev.dv_xname, NULL, 0); + bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0); /* Get a vnode for the raw partition of this disk. */ - dev = MAKEDISKDEV(bmajor, device_unit(&sc->sc_dev), RAW_PART); + dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART); error = bdevvp(dev, &vp); if (error) goto out; @@ -97,15 +97,15 @@ ata_raid_read_config_promise(struct wd_softc *sc) VOP_CLOSE(vp, FREAD, NOCRED); vput(vp); if (error) { - printf("%s: error %d reading Promise config block\n", - sc->sc_dev.dv_xname, error); + aprint_error_dev(sc->sc_dev, + "error %d reading Promise config block\n", error); goto out; } /* Check the signature. */ if (strncmp(info->promise_id, PR_MAGIC, sizeof(PR_MAGIC)) != 0) { DPRINTF(("%s: Promise signature check failed\n", - sc->sc_dev.dv_xname)); + device_xname(sc->sc_dev))); error = ESRCH; goto out; } @@ -115,14 +115,15 @@ ata_raid_read_config_promise(struct wd_softc *sc) count++) cksum += *ckptr++; if (cksum != *ckptr) { - DPRINTF(("%s: Promise checksum failed\n", sc->sc_dev.dv_xname)); + DPRINTF(("%s: Promise checksum failed\n", + device_xname(sc->sc_dev))); error = ESRCH; goto out; } if (info->raid.integrity != PR_I_VALID) { DPRINTF(("%s: Promise config block marked invalid\n", - sc->sc_dev.dv_xname)); + device_xname(sc->sc_dev))); error = ESRCH; goto out; } @@ -163,8 +164,9 @@ ata_raid_read_config_promise(struct wd_softc *sc) break; default: - printf("%s: unknown Promise RAID type 0x%02x\n", - sc->sc_dev.dv_xname, info->raid.type); + aprint_error_dev(sc->sc_dev, + "unknown Promise RAID type 0x%02x\n", + info->raid.type); error = EINVAL; goto out; } @@ -197,7 +199,7 @@ ata_raid_read_config_promise(struct wd_softc *sc) } adi = &aai->aai_disks[info->raid.disk_number]; if (adi->adi_status) { - adi->adi_dev = &sc->sc_dev; + adi->adi_dev = sc->sc_dev; adi->adi_sectors = info->raid.disk_sectors; adi->adi_compsize = sc->sc_capacity - aai->aai_reserved; } diff --git a/sys/dev/ata/ata_raid_via.c b/sys/dev/ata/ata_raid_via.c index 86c12289314..51d8081af47 100644 --- a/sys/dev/ata/ata_raid_via.c +++ b/sys/dev/ata/ata_raid_via.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_via.c,v 1.4 2008/02/07 13:48:33 xtraeme Exp $ */ +/* $NetBSD: ata_raid_via.c,v 1.5 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.4 2008/02/07 13:48:33 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.5 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -127,10 +127,10 @@ ata_raid_read_config_via(struct wd_softc *sc) info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK); - bmajor = devsw_name2blk(sc->sc_dev.dv_xname, NULL, 0); + bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0); /* Get a vnode for the raw partition of this disk. */ - dev = MAKEDISKDEV(bmajor, device_unit(&sc->sc_dev), RAW_PART); + dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART); error = bdevvp(dev, &vp); if (error) goto out; @@ -146,8 +146,8 @@ ata_raid_read_config_via(struct wd_softc *sc) VOP_CLOSE(vp, FREAD, NOCRED); vput(vp); if (error) { - printf("%s: error %d reading VIA V-RAID config block\n", - sc->sc_dev.dv_xname, error); + aprint_error_dev(sc->sc_dev, + "error %d reading VIA V-RAID config block\n", error); goto out; } @@ -159,7 +159,7 @@ ata_raid_read_config_via(struct wd_softc *sc) /* Check the signature. */ if (info->magic != VIA_MAGIC) { DPRINTF(("%s: VIA V-RAID signature check failed\n", - sc->sc_dev.dv_xname)); + device_xname(sc->sc_dev))); error = ESRCH; goto out; } @@ -173,7 +173,7 @@ ata_raid_read_config_via(struct wd_softc *sc) checksum += *ptr++; if (checksum != info->checksum) { DPRINTF(("%s: VIA V-RAID checksum failed 0x%02x != 0x%02x\n", - sc->sc_dev.dv_xname, checksum, info->checksum)); + device_xname(sc->sc_dev), checksum, info->checksum)); error = ESRCH; goto out; } @@ -212,8 +212,8 @@ ata_raid_read_config_via(struct wd_softc *sc) break; default: - aprint_error("%s: unknown VIA V-RAID type 0x%02x\n", - sc->sc_dev.dv_xname, info->type); + aprint_error_dev(sc->sc_dev, + "unknown VIA V-RAID type 0x%02x\n", info->type); error = EINVAL; goto out; } @@ -235,18 +235,18 @@ ata_raid_read_config_via(struct wd_softc *sc) if (aai->aai_interleave == 0) aai->aai_interleave = aai->aai_capacity; - atabus = (struct atabus_softc *) device_parent(&sc->sc_dev); + atabus = device_private(device_parent(sc->sc_dev)); drive = atabus->sc_chan->ch_channel; if (drive >= aai->aai_ndisks) { - aprint_error("%s: drive number %d doesn't make sense within " - "%d-disk array\n", - sc->sc_dev.dv_xname, drive, aai->aai_ndisks); + aprint_error_dev(sc->sc_dev, + "drive number %d doesn't make sense within %d-disk " + "array\n", drive, aai->aai_ndisks); error = EINVAL; goto out; } adi = &aai->aai_disks[drive]; - adi->adi_dev = &sc->sc_dev; + adi->adi_dev = sc->sc_dev; adi->adi_status = ADI_S_ONLINE | ADI_S_ASSIGNED; adi->adi_sectors = aai->aai_capacity; adi->adi_compsize = info->disk_sectors; diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c index 8b5ed667cf3..5d93d079498 100644 --- a/sys/dev/ata/ata_wdc.c +++ b/sys/dev/ata/ata_wdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_wdc.c,v 1.87 2007/10/19 11:59:36 ad Exp $ */ +/* $NetBSD: ata_wdc.c,v 1.88 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.87 2007/10/19 11:59:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.88 2008/03/18 20:46:36 cube Exp $"); #include "opt_ata.h" @@ -194,7 +194,7 @@ wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer) const char *errstring; ATADEBUG_PRINT(("wdc_ata_bio_start %s:%d:%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive), + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive), DEBUG_XFERS); /* Do control operations specially. */ @@ -302,13 +302,13 @@ ready: return; ctrltimeout: printf("%s:%d:%d: %s timed out\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, errstring); ata_bio->error = TIMEOUT; goto ctrldone; ctrlerror: printf("%s:%d:%d: %s ", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, errstring); if (chp->ch_status & WDCS_DWF) { printf("drive fault\n"); @@ -342,7 +342,7 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer) #endif ATADEBUG_PRINT(("_wdc_ata_bio_start %s:%d:%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive), + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive), DEBUG_INTR | DEBUG_XFERS); #if NATA_DMA || NATA_PIOBM @@ -554,7 +554,7 @@ again: if (wdc_wait_for_drq(chp, ATA_DELAY, AT_POLL) != 0) { printf("%s:%d:%d: timeout waiting for DRQ, " "st=0x%02x, err=0x%02x\n", - atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, chp->ch_status, chp->ch_error); if (wdc_ata_err(drvp, ata_bio) != WDC_ATA_ERR) ata_bio->error = TIMEOUT; @@ -601,7 +601,7 @@ intr: return; timeout: printf("%s:%d:%d: not ready, st=0x%02x, err=0x%02x\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, chp->ch_status, chp->ch_error); if (wdc_ata_err(drvp, ata_bio) != WDC_ATA_ERR) ata_bio->error = TIMEOUT; @@ -619,14 +619,14 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) int drv_err; ATADEBUG_PRINT(("wdc_ata_bio_intr %s:%d:%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive), + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive), DEBUG_INTR | DEBUG_XFERS); /* Is it not a transfer, but a control operation? */ if (drvp->state < READY) { printf("%s:%d:%d: bad state %d in wdc_ata_bio_intr\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, drvp->state); panic("wdc_ata_bio_intr: bad state"); } @@ -654,7 +654,7 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) if (irq && (xfer->c_flags & C_TIMEOU) == 0) return 0; /* IRQ was not for us */ printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, xfer->c_bcount, xfer->c_skip); ata_bio->error = TIMEOUT; wdc_ata_bio_done(chp, xfer); @@ -678,7 +678,8 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) if (wdcwait(chp, WDCS_DRDY | WDCS_DRQ, WDCS_DRDY, ATA_DELAY, ATA_POLL) == WDCWAIT_TOUT) { printf("%s:%d:%d: polled transfer timed out " - "(st=0x%x)\n", atac->atac_dev.dv_xname, + "(st=0x%x)\n", + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, chp->ch_status); ata_bio->error = TIMEOUT; @@ -694,7 +695,8 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) if (chp->ch_status & WDCS_DRQ) { if (drv_err != WDC_ATA_ERR) { printf("%s:%d:%d: intr with DRQ (st=0x%x)\n", - atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(atac->atac_dev), + chp->ch_channel, xfer->c_drive, chp->ch_status); ata_bio->error = TIMEOUT; drv_err = WDC_ATA_ERR; @@ -717,7 +719,7 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) if ((ata_bio->flags & ATA_READ) != 0) { if ((chp->ch_status & WDCS_DRQ) != WDCS_DRQ) { printf("%s:%d:%d: read intr before drq\n", - atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive); ata_bio->error = TIMEOUT; wdc_ata_bio_done(chp, xfer); @@ -795,8 +797,8 @@ wdc_ata_bio_done(struct ata_channel *chp, struct ata_xfer *xfer) int drive = xfer->c_drive; ATADEBUG_PRINT(("wdc_ata_bio_done %s:%d:%d: flags 0x%x\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, - (u_int)xfer->c_flags), + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, + xfer->c_drive, (u_int)xfer->c_flags), DEBUG_XFERS); callout_stop(&chp->ch_callout); diff --git a/sys/dev/ata/atavar.h b/sys/dev/ata/atavar.h index b5e5bd0688b..8ac43f8055c 100644 --- a/sys/dev/ata/atavar.h +++ b/sys/dev/ata/atavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.75 2007/12/09 20:27:54 jmcneill Exp $ */ +/* $NetBSD: atavar.h,v 1.76 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -98,7 +98,7 @@ struct ata_queue { /* ATA bus instance state information. */ struct atabus_softc { - struct device sc_dev; + device_t sc_dev; struct ata_channel *sc_chan; int sc_flags; #define ATABUSCF_OPEN 0x01 @@ -185,7 +185,7 @@ struct ata_drive_datas { /* Callbacks into the drive's driver. */ void (*drv_done)(void *); /* transfer is done */ - struct device *drv_softc; /* ATA drives softc, if any */ + device_t drv_softc; /* ATA drives softc, if any */ void *chnl_softc; /* channel softc */ }; @@ -380,7 +380,7 @@ struct ata_channel { * XXX There is still some lingering wdc-centricity here. */ struct atac_softc { - struct device atac_dev; /* generic device info */ + device_t atac_dev; /* generic device info */ int atac_cap; /* controller capabilities */ diff --git a/sys/dev/ata/sata_subr.c b/sys/dev/ata/sata_subr.c index 6cbfe781d02..91929662635 100644 --- a/sys/dev/ata/sata_subr.c +++ b/sys/dev/ata/sata_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: sata_subr.c,v 1.9 2007/12/11 11:38:15 lukem Exp $ */ +/* $NetBSD: sata_subr.c,v 1.10 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ * Common functions for Serial ATA. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.9 2007/12/11 11:38:15 lukem Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sata_subr.c,v 1.10 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -121,22 +121,22 @@ sata_reset_interface(struct ata_channel *chp, bus_space_tag_t sata_t, case SStatus_DET_DEV_NE: aprint_error("%s port %d: device connected, but " "communication not established\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel); break; case SStatus_DET_OFFLINE: aprint_error("%s port %d: PHY offline\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel); break; case SStatus_DET_DEV: aprint_normal("%s port %d: device present, speed: %s\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, sata_speed(sstatus)); break; default: aprint_error("%s port %d: unknown SStatus: 0x%08x\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, sstatus); } return(sstatus & SStatus_DET_mask); diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index a8306c970f5..acf9286a1d0 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.359 2008/02/29 21:51:38 bouyer Exp $ */ +/* $NetBSD: wd.c,v 1.360 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.359 2008/02/29 21:51:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.360 2008/03/18 20:46:36 cube Exp $"); #include "opt_ata.h" @@ -143,7 +143,7 @@ void wdperror(const struct wd_softc *); static bool wd_suspend(device_t PMF_FN_PROTO); static int wd_standby(struct wd_softc *, int); -CFATTACH_DECL(wd, sizeof(struct wd_softc), +CFATTACH_DECL_NEW(wd, sizeof(struct wd_softc), wdprobe, wdattach, wddetach, wdactivate); extern struct cfdriver wd_cd; @@ -299,12 +299,14 @@ wdprobe(struct device *parent, struct cfdata *match, void *aux) void wdattach(struct device *parent, struct device *self, void *aux) { - struct wd_softc *wd = (void *)self; + struct wd_softc *wd = device_private(self); struct ata_device *adev= aux; int i, blank; char tbuf[41], pbuf[9], c, *p, *q; const struct wd_quirk *wdq; + wd->sc_dev = self; + ATADEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE); callout_init(&wd->sc_restart_ch, 0); bufq_alloc(&wd->sc_q, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK); @@ -316,13 +318,13 @@ wdattach(struct device *parent, struct device *self, void *aux) wd->drvp = adev->adev_drv_data; wd->drvp->drv_done = wddone; - wd->drvp->drv_softc = &wd->sc_dev; + wd->drvp->drv_softc = wd->sc_dev; aprint_naive("\n"); /* read our drive info */ if (wd_get_params(wd, AT_WAIT, &wd->sc_params) != 0) { - aprint_error("\n%s: IDENTIFY failed\n", wd->sc_dev.dv_xname); + aprint_error("\n%s: IDENTIFY failed\n", device_xname(self)); return; } @@ -352,7 +354,7 @@ wdattach(struct device *parent, struct device *self, void *aux) char sbuf[sizeof(WD_QUIRK_FMT) + 64]; bitmask_snprintf(wd->sc_quirks, WD_QUIRK_FMT, sbuf, sizeof(sbuf)); - aprint_normal("%s: quirks %s\n", wd->sc_dev.dv_xname, sbuf); + aprint_normal_dev(self, "quirks %s\n", sbuf); } if ((wd->sc_params.atap_multi & 0xff) > 1) { @@ -361,8 +363,8 @@ wdattach(struct device *parent, struct device *self, void *aux) wd->sc_multi = 1; } - aprint_verbose("%s: drive supports %d-sector PIO transfers,", - wd->sc_dev.dv_xname, wd->sc_multi); + aprint_verbose_dev(self, "drive supports %d-sector PIO transfers,", + wd->sc_multi); /* 48-bit LBA addressing */ if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) @@ -398,9 +400,9 @@ wdattach(struct device *parent, struct device *self, void *aux) wd->sc_params.atap_sectors; } format_bytes(pbuf, sizeof(pbuf), wd->sc_capacity * DEV_BSIZE); - aprint_normal("%s: %s, %d cyl, %d head, %d sec, " + aprint_normal_dev(self, "%s, %d cyl, %d head, %d sec, " "%d bytes/sect x %llu sectors\n", - self->dv_xname, pbuf, + pbuf, (wd->sc_flags & WDF_LBA) ? (int)(wd->sc_capacity / (wd->sc_params.atap_heads * wd->sc_params.atap_sectors)) : wd->sc_params.atap_cylinders, @@ -408,17 +410,17 @@ wdattach(struct device *parent, struct device *self, void *aux) DEV_BSIZE, (unsigned long long)wd->sc_capacity); ATADEBUG_PRINT(("%s: atap_dmatiming_mimi=%d, atap_dmatiming_recom=%d\n", - self->dv_xname, wd->sc_params.atap_dmatiming_mimi, + device_xname(self), wd->sc_params.atap_dmatiming_mimi, wd->sc_params.atap_dmatiming_recom), DEBUG_PROBE); /* * Initialize and attach the disk structure. */ /* we fill in dk_info later */ - disk_init(&wd->sc_dk, wd->sc_dev.dv_xname, &wddkdriver); + disk_init(&wd->sc_dk, device_xname(wd->sc_dev), &wddkdriver); disk_attach(&wd->sc_dk); wd->sc_wdc_bio.lp = wd->sc_dk.dk_label; #if NRND > 0 - rnd_attach_source(&wd->rnd_source, wd->sc_dev.dv_xname, + rnd_attach_source(&wd->rnd_source, device_xname(wd->sc_dev), RND_TYPE_DISK, 0); #endif @@ -461,7 +463,7 @@ wdactivate(struct device *self, enum devact act) int wddetach(struct device *self, int flags) { - struct wd_softc *sc = (struct wd_softc *)self; + struct wd_softc *sc = device_private(self); int s, bmaj, cmaj, i, mn; /* locate the major number */ @@ -520,12 +522,13 @@ wddetach(struct device *self, int flags) void wdstrategy(struct buf *bp) { - struct wd_softc *wd = device_lookup(&wd_cd, WDUNIT(bp->b_dev)); + struct wd_softc *wd = + device_private(device_lookup(&wd_cd, WDUNIT(bp->b_dev))); struct disklabel *lp = wd->sc_dk.dk_label; daddr_t blkno; int s; - ATADEBUG_PRINT(("wdstrategy (%s)\n", wd->sc_dev.dv_xname), + ATADEBUG_PRINT(("wdstrategy (%s)\n", device_xname(wd->sc_dev)), DEBUG_XFERS); /* Valid request? */ @@ -617,7 +620,7 @@ wdstart(void *arg) struct wd_softc *wd = arg; struct buf *bp = NULL; - ATADEBUG_PRINT(("wdstart %s\n", wd->sc_dev.dv_xname), + ATADEBUG_PRINT(("wdstart %s\n", device_xname(wd->sc_dev)), DEBUG_XFERS); while (wd->openings > 0) { @@ -639,7 +642,8 @@ static void wd_split_mod15_write(struct buf *bp) { struct buf *obp = bp->b_private; - struct wd_softc *sc = wd_cd.cd_devs[DISKUNIT(obp->b_dev)]; + struct wd_softc *sc = + device_private(wd_cd.cd_devs[DISKUNIT(obp->b_dev)]); if (__predict_false(bp->b_error != 0)) { /* @@ -772,13 +776,13 @@ __wdstart(struct wd_softc *wd, struct buf *bp) void wddone(void *v) { - struct wd_softc *wd = v; + struct wd_softc *wd = device_private(v); struct buf *bp = wd->sc_bp; const char *errmsg; int do_perror = 0; int nblks; - ATADEBUG_PRINT(("wddone %s\n", wd->sc_dev.dv_xname), + ATADEBUG_PRINT(("wddone %s\n", device_xname(wd->sc_dev)), DEBUG_XFERS); if (bp == NULL) return; @@ -863,8 +867,8 @@ retry2: break; case NOERROR: noerror: if ((wd->sc_wdc_bio.flags & ATA_CORR) || wd->retries > 0) - printf("%s: soft error (corrected)\n", - wd->sc_dev.dv_xname); + aprint_error_dev(wd->sc_dev, + "soft error (corrected)\n"); break; case ERR_NODEV: bp->b_error = EIO; @@ -892,7 +896,7 @@ wdrestart(void *v) struct buf *bp = wd->sc_bp; int s; - ATADEBUG_PRINT(("wdrestart %s\n", wd->sc_dev.dv_xname), + ATADEBUG_PRINT(("wdrestart %s\n", device_xname(wd->sc_dev)), DEBUG_XFERS); s = splbio(); __wdstart(v, bp); @@ -922,11 +926,11 @@ wdopen(dev_t dev, int flag, int fmt, struct lwp *l) int part, error; ATADEBUG_PRINT(("wdopen\n"), DEBUG_FUNCS); - wd = device_lookup(&wd_cd, WDUNIT(dev)); + wd = device_private(device_lookup(&wd_cd, WDUNIT(dev))); if (wd == NULL) return (ENXIO); - if (! device_is_active(&wd->sc_dev)) + if (! device_is_active(wd->sc_dev)) return (ENODEV); part = WDPART(dev); @@ -1005,7 +1009,8 @@ wdopen(dev_t dev, int flag, int fmt, struct lwp *l) int wdclose(dev_t dev, int flag, int fmt, struct lwp *l) { - struct wd_softc *wd = device_lookup(&wd_cd, WDUNIT(dev)); + struct wd_softc *wd = + device_private(device_lookup(&wd_cd, WDUNIT(dev))); int part = WDPART(dev); ATADEBUG_PRINT(("wdclose\n"), DEBUG_FUNCS); @@ -1100,7 +1105,7 @@ wdgetdisklabel(struct wd_softc *wd) wd->drvp->drive_flags |= DRIVE_RESET; splx(s); } - errstring = readdisklabel(MAKEWDDEV(0, device_unit(&wd->sc_dev), + errstring = readdisklabel(MAKEWDDEV(0, device_unit(wd->sc_dev), RAW_PART), wdstrategy, lp, wd->sc_dk.dk_cpulabel); if (errstring) { @@ -1115,11 +1120,11 @@ wdgetdisklabel(struct wd_softc *wd) wd->drvp->drive_flags |= DRIVE_RESET; splx(s); } - errstring = readdisklabel(MAKEWDDEV(0, device_unit(&wd->sc_dev), + errstring = readdisklabel(MAKEWDDEV(0, device_unit(wd->sc_dev), RAW_PART), wdstrategy, lp, wd->sc_dk.dk_cpulabel); } if (errstring) { - printf("%s: %s\n", wd->sc_dev.dv_xname, errstring); + aprint_error_dev(wd->sc_dev, "%s\n", errstring); return; } @@ -1150,7 +1155,7 @@ wdperror(const struct wd_softc *wd) int i; const char *sep = ""; - const char *devname = wd->sc_dev.dv_xname; + const char *devname = device_xname(wd->sc_dev); struct ata_drive_datas *drvp = wd->drvp; int errno = wd->sc_wdc_bio.r_error; @@ -1176,7 +1181,8 @@ wdperror(const struct wd_softc *wd) int wdioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l) { - struct wd_softc *wd = device_lookup(&wd_cd, WDUNIT(dev)); + struct wd_softc *wd = + device_private(device_lookup(&wd_cd, WDUNIT(dev))); int error = 0, s; #ifdef __HAVE_OLD_DISKLABEL struct disklabel *newlabel = NULL; @@ -1471,7 +1477,7 @@ wdioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l) return (EBADF); /* If the ioctl happens here, the parent is us. */ - strcpy(dkw->dkw_parent, wd->sc_dev.dv_xname); + strcpy(dkw->dkw_parent, device_xname(wd->sc_dev)); return (dkwedge_add(dkw)); } @@ -1483,7 +1489,7 @@ wdioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l) return (EBADF); /* If the ioctl happens here, the parent is us. */ - strcpy(dkw->dkw_parent, wd->sc_dev.dv_xname); + strcpy(dkw->dkw_parent, device_xname(wd->sc_dev)); return (dkwedge_del(dkw)); } @@ -1563,7 +1569,7 @@ wdsize(dev_t dev) ATADEBUG_PRINT(("wdsize\n"), DEBUG_FUNCS); - wd = device_lookup(&wd_cd, WDUNIT(dev)); + wd = device_private(device_lookup(&wd_cd, WDUNIT(dev))); if (wd == NULL) return (-1); @@ -1602,7 +1608,7 @@ wddump(dev_t dev, daddr_t blkno, void *va, size_t size) return EFAULT; wddoingadump = 1; - wd = device_lookup(&wd_cd, WDUNIT(dev)); + wd = device_private(device_lookup(&wd_cd, WDUNIT(dev))); if (wd == NULL) return (ENXIO); @@ -1758,7 +1764,7 @@ wd_params_to_properties(struct wd_softc *wd, struct ataparams *params) prop_dictionary_set(disk_info, "geometry", geom); prop_object_release(geom); - prop_dictionary_set(device_properties(&wd->sc_dev), + prop_dictionary_set(device_properties(wd->sc_dev), "disk-info", disk_info); /* @@ -1855,15 +1861,14 @@ wd_setcache(struct wd_softc *wd, int bits) else ata_c.r_features = WDSF_WRITE_CACHE_DS; if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { - printf("%s: wd_setcache command not complete\n", - wd->sc_dev.dv_xname); + aprint_error_dev(wd->sc_dev, + "wd_setcache command not complete\n"); return EIO; } if (ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { char sbuf[sizeof(at_errbits) + 64]; bitmask_snprintf(ata_c.flags, at_errbits, sbuf, sizeof(sbuf)); - printf("%s: wd_setcache: status=%s\n", wd->sc_dev.dv_xname, - sbuf); + aprint_error_dev(wd->sc_dev, "wd_setcache: status=%s\n", sbuf); return EIO; } return 0; @@ -1881,7 +1886,7 @@ wd_standby(struct wd_softc *wd, int flags) ata_c.flags = flags; ata_c.timeout = 30000; /* 30s timeout */ if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { - aprint_error_dev(&wd->sc_dev, + aprint_error_dev(wd->sc_dev, "standby immediate command didn't complete\n"); return EIO; } @@ -1892,7 +1897,7 @@ wd_standby(struct wd_softc *wd, int flags) if (ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { char sbuf[sizeof(at_errbits) + 64]; bitmask_snprintf(ata_c.flags, at_errbits, sbuf, sizeof(sbuf)); - aprint_error_dev(&wd->sc_dev, "wd_standby: status=%s\n", sbuf); + aprint_error_dev(wd->sc_dev, "wd_standby: status=%s\n", sbuf); return EIO; } return 0; @@ -1922,8 +1927,8 @@ wd_flushcache(struct wd_softc *wd, int flags) ata_c.flags = flags; ata_c.timeout = 30000; /* 30s timeout */ if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { - printf("%s: flush cache command didn't complete\n", - wd->sc_dev.dv_xname); + aprint_error_dev(wd->sc_dev, + "flush cache command didn't complete\n"); return EIO; } if (ata_c.flags & AT_ERROR) { @@ -1933,7 +1938,7 @@ wd_flushcache(struct wd_softc *wd, int flags) if (ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { char sbuf[sizeof(at_errbits) + 64]; bitmask_snprintf(ata_c.flags, at_errbits, sbuf, sizeof(sbuf)); - printf("%s: wd_flushcache: status=%s\n", wd->sc_dev.dv_xname, + aprint_error_dev(wd->sc_dev, "wd_flushcache: status=%s\n", sbuf); return EIO; } diff --git a/sys/dev/ata/wdvar.h b/sys/dev/ata/wdvar.h index cf214492d9d..93a2e9406eb 100644 --- a/sys/dev/ata/wdvar.h +++ b/sys/dev/ata/wdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wdvar.h,v 1.35 2008/02/28 14:40:17 drochner Exp $ */ +/* $NetBSD: wdvar.h,v 1.36 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -38,7 +38,7 @@ struct wd_softc { /* General disk infos */ - struct device sc_dev; + device_t sc_dev; struct disk sc_dk; struct bufq_state *sc_q; struct callout sc_restart_ch; diff --git a/sys/dev/cardbus/njata_cardbus.c b/sys/dev/cardbus/njata_cardbus.c index 49c79ac3cc7..041014e356a 100644 --- a/sys/dev/cardbus/njata_cardbus.c +++ b/sys/dev/cardbus/njata_cardbus.c @@ -1,4 +1,4 @@ -/* $Id: njata_cardbus.c,v 1.5 2007/10/19 11:59:39 ad Exp $ */ +/* $Id: njata_cardbus.c,v 1.6 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 ITOH Yasufumi <itohy@NetBSD.org>. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: njata_cardbus.c,v 1.5 2007/10/19 11:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: njata_cardbus.c,v 1.6 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,13 +64,11 @@ struct njata32_cardbus_softc { static const struct njata32_cardbus_product *njata_cardbus_lookup (const struct cardbus_attach_args *); -static int njata_cardbus_match(struct device *, struct cfdata *, - void *); -static void njata_cardbus_attach(struct device *, struct device *, - void *); +static int njata_cardbus_match(device_t, cfdata_t, void *); +static void njata_cardbus_attach(device_t, device_t, void *); static int njata_cardbus_detach(struct device *, int); -CFATTACH_DECL(njata_cardbus, sizeof(struct njata32_cardbus_softc), +CFATTACH_DECL_NEW(njata_cardbus, sizeof(struct njata32_cardbus_softc), njata_cardbus_match, njata_cardbus_attach, njata_cardbus_detach, NULL); static const struct njata32_cardbus_product { @@ -97,8 +95,7 @@ static const struct njata32_cardbus_product { }; static const struct njata32_cardbus_product * -njata_cardbus_lookup(ca) - const struct cardbus_attach_args *ca; +njata_cardbus_lookup(const struct cardbus_attach_args *ca) { const struct njata32_cardbus_product *p; @@ -113,8 +110,7 @@ njata_cardbus_lookup(ca) } static int -njata_cardbus_match(struct device *parent, - struct cfdata *match, void *aux) +njata_cardbus_match(device_t parent, cfdata_t match, void *aux) { struct cardbus_attach_args *ca = aux; @@ -125,11 +121,10 @@ njata_cardbus_match(struct device *parent, } static void -njata_cardbus_attach(struct device *parent, struct device *self, - void *aux) +njata_cardbus_attach(device_t parent, device_t self, void *aux) { struct cardbus_attach_args *ca = aux; - struct njata32_cardbus_softc *csc = (void *)self; + struct njata32_cardbus_softc *csc = device_private(self); struct njata32_softc *sc = &csc->sc_njata32; const struct njata32_cardbus_product *prod; cardbus_devfunc_t ct = ca->ca_ct; @@ -139,10 +134,11 @@ njata_cardbus_attach(struct device *parent, struct device *self, int csr; uint8_t latency = 0x20; + sc->sc_wdcdev.sc_atac.atac_dev = self; if ((prod = njata_cardbus_lookup(ca)) == NULL) panic("njata_cardbus_attach"); - printf(": Workbit NinjaATA-32 IDE controller\n"); + aprint_normal(": Workbit NinjaATA-32 IDE controller\n"); csc->sc_ct = ct; csc->sc_tag = ca->ca_tag; @@ -172,7 +168,7 @@ njata_cardbus_attach(struct device *parent, struct device *self, goto try_io; } #ifdef NJATA32_DEBUG - printf("%s: memory space mapped, size %u\n", + aprint_normal("%s: memory space mapped, size %u\n", NJATA32NAME(sc), (unsigned)csc->sc_regmap_size); #endif csr |= PCI_COMMAND_MEM_ENABLE; @@ -184,14 +180,14 @@ njata_cardbus_attach(struct device *parent, struct device *self, PCI_MAPREG_TYPE_IO, 0, &NJATA32_REGT(sc), &NJATA32_REGH(sc), NULL, &csc->sc_regmap_size) == 0) { #ifdef NJATA32_DEBUG - printf("%s: io space mapped, size %u\n", + aprint_normal("%s: io space mapped, size %u\n", NJATA32NAME(sc), (unsigned)csc->sc_regmap_size); #endif csr |= PCI_COMMAND_IO_ENABLE; sc->sc_flags = NJATA32_IO_MAPPED; (*ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_IO_ENABLE); } else { - printf("%s: unable to map device registers\n", + aprint_error("%s: unable to map device registers\n", NJATA32NAME(sc)); return; } @@ -225,22 +221,21 @@ njata_cardbus_attach(struct device *parent, struct device *self, sc->sc_ih = cardbus_intr_establish(cc, cf, ca->ca_intrline, IPL_BIO, njata32_intr, sc); if (sc->sc_ih == NULL) { - printf("%s: unable to establish interrupt at %d\n", + aprint_error("%s: unable to establish interrupt at %d\n", NJATA32NAME(sc), ca->ca_intrline); return; } - printf("%s: interrupting at %d\n", NJATA32NAME(sc), ca->ca_intrline); + aprint_normal("%s: interrupting at %d\n", NJATA32NAME(sc), + ca->ca_intrline); /* attach */ njata32_attach(sc); } static int -njata_cardbus_detach(self, flags) - struct device *self; - int flags; +njata_cardbus_detach(device_t self, int flags) { - struct njata32_cardbus_softc *csc = (void *) self; + struct njata32_cardbus_softc *csc = device_private(self); struct njata32_softc *sc = &csc->sc_njata32; int rv; diff --git a/sys/dev/ic/ahcisata_core.c b/sys/dev/ic/ahcisata_core.c index 0602dd4b38e..2c3896fb560 100644 --- a/sys/dev/ic/ahcisata_core.c +++ b/sys/dev/ic/ahcisata_core.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.12 2008/02/11 08:23:48 xtraeme Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.13 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.12 2008/02/11 08:23:48 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.13 2008/03/18 20:46:36 cube Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -1204,7 +1204,7 @@ ahci_atapibus_attach(struct atabus_softc * ata_sc) /* * Fill in the scsipi_adapter. */ - adapt->adapt_dev = &atac->atac_dev; + adapt->adapt_dev = atac->atac_dev; adapt->adapt_nchannels = atac->atac_nchannels; adapt->adapt_request = ahci_atapi_scsipi_request; adapt->adapt_minphys = ahci_atapi_minphys; @@ -1222,7 +1222,7 @@ ahci_atapibus_attach(struct atabus_softc * ata_sc) chan->chan_max_periph = 1; chan->chan_ntargets = 1; chan->chan_nluns = 1; - chp->atapibus = config_found_ia(&ata_sc->sc_dev, "atapi", chan, + chp->atapibus = config_found_ia(ata_sc->sc_dev, "atapi", chan, atapiprint); } @@ -1243,7 +1243,7 @@ void ahci_atapi_kill_pending(struct scsipi_periph *periph) { struct atac_softc *atac = - (void *)periph->periph_channel->chan_adapter->adapt_dev; + device_private(periph->periph_channel->chan_adapter->adapt_dev); struct ata_channel *chp = atac->atac_channels[periph->periph_channel->chan_channel]; @@ -1257,7 +1257,7 @@ ahci_atapi_scsipi_request(struct scsipi_channel *chan, struct scsipi_adapter *adapt = chan->chan_adapter; struct scsipi_periph *periph; struct scsipi_xfer *sc_xfer; - struct ahci_softc *sc = (void *)adapt->adapt_dev; + struct ahci_softc *sc = device_private(adapt->adapt_dev); struct atac_softc *atac = &sc->sc_atac; struct ata_xfer *xfer; int channel = chan->chan_channel; @@ -1268,7 +1268,7 @@ ahci_atapi_scsipi_request(struct scsipi_channel *chan, sc_xfer = arg; periph = sc_xfer->xs_periph; drive = periph->periph_target; - if (!device_is_active(&atac->atac_dev)) { + if (!device_is_active(atac->atac_dev)) { sc_xfer->error = XS_DRIVER_STUFFUP; scsipi_done(sc_xfer); return; @@ -1494,7 +1494,8 @@ ahci_atapi_probe_device(struct atapibus_softc *sc, int target) struct scsipi_periph *periph; struct ataparams ids; struct ataparams *id = &ids; - struct ahci_softc *ahcic = (void *)chan->chan_adapter->adapt_dev; + struct ahci_softc *ahcic = + device_private(chan->chan_adapter->adapt_dev); struct atac_softc *atac = &ahcic->sc_atac; struct ata_channel *chp = atac->atac_channels[chan->chan_channel]; struct ata_drive_datas *drvp = &chp->ch_drive[target]; @@ -1525,7 +1526,7 @@ ahci_atapi_probe_device(struct atapibus_softc *sc, int target) periph = scsipi_alloc_periph(M_NOWAIT); if (periph == NULL) { printf("%s: unable to allocate periph for drive %d\n", - sc->sc_dev.dv_xname, target); + device_xname(&sc->sc_dev), target); return; } periph->periph_dev = NULL; diff --git a/sys/dev/ic/ahcisatavar.h b/sys/dev/ic/ahcisatavar.h index 52cc543c2ae..59917b0aa06 100644 --- a/sys/dev/ic/ahcisatavar.h +++ b/sys/dev/ic/ahcisatavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisatavar.h,v 1.3 2008/02/11 08:23:48 xtraeme Exp $ */ +/* $NetBSD: ahcisatavar.h,v 1.4 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -78,7 +78,7 @@ struct ahci_softc { } sc_channels[AHCI_MAX_PORTS]; }; -#define AHCINAME(sc) ((sc)->sc_atac.atac_dev.dv_xname) +#define AHCINAME(sc) (device_xname((sc)->sc_atac.atac_dev)) #define AHCI_CMDH_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \ (sc)->sc_cmd_hdrd, \ diff --git a/sys/dev/ic/ninjaata32.c b/sys/dev/ic/ninjaata32.c index e4b3fb9399d..6ec14b3054a 100644 --- a/sys/dev/ic/ninjaata32.c +++ b/sys/dev/ic/ninjaata32.c @@ -1,4 +1,4 @@ -/* $NetBSD: ninjaata32.c,v 1.9 2007/10/19 11:59:57 ad Exp $ */ +/* $NetBSD: ninjaata32.c,v 1.10 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 ITOH Yasufumi <itohy@NetBSD.org>. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ninjaata32.c,v 1.9 2007/10/19 11:59:57 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ninjaata32.c,v 1.10 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -74,9 +74,7 @@ static const uint8_t njata32_timing_pio[NJATA32_MODE_MAX_PIO + 1] = { }; static void -njata32_init(sc, nosleep) - struct njata32_softc *sc; - int nosleep; /* can't sleep (during cold boot and in interrupt) */ +njata32_init(struct njata32_softc *sc, int nosleep) { /* disable interrupts */ @@ -107,8 +105,7 @@ njata32_init(sc, nosleep) } void -njata32_attach(sc) - struct njata32_softc *sc; +njata32_attach(struct njata32_softc *sc) { bus_addr_t dmaaddr; int i, devno, error; @@ -120,7 +117,7 @@ njata32_attach(sc) if ((error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct njata32_dma_page), PAGE_SIZE, 0, &sc->sc_sgt_seg, 1, &sc->sc_sgt_nsegs, BUS_DMA_NOWAIT)) != 0) { - printf("%s: unable to allocate sgt page, error = %d\n", + aprint_error("%s: unable to allocate sgt page, error = %d\n", NJATA32NAME(sc), error); return; } @@ -128,7 +125,7 @@ njata32_attach(sc) sc->sc_sgt_nsegs, sizeof(struct njata32_dma_page), (void **)&sc->sc_sgtpg, BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) { - printf("%s: unable to map sgt page, error = %d\n", + aprint_error("%s: unable to map sgt page, error = %d\n", NJATA32NAME(sc), error); goto fail1; } @@ -136,14 +133,14 @@ njata32_attach(sc) sizeof(struct njata32_dma_page), 1, sizeof(struct njata32_dma_page), 0, BUS_DMA_NOWAIT, &sc->sc_dmamap_sgt)) != 0) { - printf("%s: unable to create sgt DMA map, error = %d\n", + aprint_error("%s: unable to create sgt DMA map, error = %d\n", NJATA32NAME(sc), error); goto fail2; } if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_sgt, sc->sc_sgtpg, sizeof(struct njata32_dma_page), NULL, BUS_DMA_NOWAIT)) != 0) { - printf("%s: unable to load sgt DMA map, error = %d\n", + aprint_error("%s: unable to load sgt DMA map, error = %d\n", NJATA32NAME(sc), error); goto fail3; } @@ -163,8 +160,8 @@ njata32_attach(sc) BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &sc->sc_dev[devno].d_dmamap_xfer); if (error) { - printf("%s: failed to create DMA map (error = %d)\n", - NJATA32NAME(sc), error); + aprint_error("%s: failed to create DMA map " + "(error = %d)\n", NJATA32NAME(sc), error); goto fail4; } } @@ -226,7 +223,7 @@ njata32_attach(sc) /* use flags value as busmaster wait */ if ((sc->sc_atawait = - (uint8_t)device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags)) + (uint8_t)device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags)) aprint_normal("%s: ATA wait = %#x\n", NJATA32NAME(sc), sc->sc_atawait); @@ -251,14 +248,12 @@ fail1: bus_dmamem_free(sc->sc_dmat, &sc->sc_sgt_seg, sc->sc_sgt_nsegs); } int -njata32_detach(sc, flags) - struct njata32_softc *sc; - int flags; +njata32_detach(struct njata32_softc *sc, int flags) { int rv, devno; if (sc->sc_flags & NJATA32_CMDPG_MAPPED) { - if ((rv = wdcdetach(&sc->sc_wdcdev.sc_atac.atac_dev, flags))) + if ((rv = wdcdetach(sc->sc_wdcdev.sc_atac.atac_dev, flags))) return rv; /* free DMA resource */ @@ -277,8 +272,7 @@ njata32_detach(sc, flags) } static void -njata32_irqack(chp) - struct ata_channel *chp; +njata32_irqack(struct ata_channel *chp) { struct njata32_softc *sc = (void *)chp->ch_atac; @@ -288,13 +282,11 @@ njata32_irqack(chp) } static void -njata32_clearirq(chp, irq) - struct ata_channel *chp; - int irq; +njata32_clearirq(struct ata_channel *chp, int irq) { struct njata32_softc *sc = (void *)chp->ch_atac; - printf("%s: unhandled intr: irq %#x, bm %#x, ", + aprint_error("%s: unhandled intr: irq %#x, bm %#x, ", NJATA32NAME(sc), irq, bus_space_read_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_BM)); @@ -303,7 +295,7 @@ njata32_clearirq(chp, irq) njata32_irqack(chp); /* clear device interrupt */ - printf("err %#x, seccnt %#x, cyl %#x, sdh %#x, ", + aprint_normal("err %#x, seccnt %#x, cyl %#x, sdh %#x, ", bus_space_read_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_WD_ERROR), bus_space_read_1(NJATA32_REGT(sc), NJATA32_REGH(sc), @@ -314,14 +306,13 @@ njata32_clearirq(chp, irq) NJATA32_REG_WD_CYL_HI) << 8), bus_space_read_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_WD_SDH)); - printf("status %#x\n", + aprint_normal("status %#x\n", bus_space_read_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_WD_STATUS)); } static void -njata32_setup_channel(chp) - struct ata_channel *chp; +njata32_setup_channel(struct ata_channel *chp) { struct njata32_softc *sc = (void *)chp->ch_atac; struct ata_drive_datas *drvp; diff --git a/sys/dev/ic/ninjaata32var.h b/sys/dev/ic/ninjaata32var.h index e6c503f76ea..47119a43589 100644 --- a/sys/dev/ic/ninjaata32var.h +++ b/sys/dev/ic/ninjaata32var.h @@ -1,4 +1,4 @@ -/* $NetBSD: ninjaata32var.h,v 1.3 2006/10/01 12:11:52 itohy Exp $ */ +/* $NetBSD: ninjaata32var.h,v 1.4 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 ITOH Yasufumi <itohy@NetBSD.org>. @@ -29,7 +29,7 @@ #ifndef _NJATA32VAR_H_ #define _NJATA32VAR_H_ -#define NJATA32NAME(sc) (sc->sc_wdcdev.sc_atac.atac_dev.dv_xname) +#define NJATA32NAME(sc) (device_xname(sc->sc_wdcdev.sc_atac.atac_dev)) /* ??? */ #define NJATA32_MAX_XFER (64 * 1024) diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c index 4492c328f98..9bfb150a358 100644 --- a/sys/dev/ic/wdc.c +++ b/sys/dev/ic/wdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.252 2008/01/28 18:17:05 dyoung Exp $ */ +/* $NetBSD: wdc.c,v 1.253 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.252 2008/01/28 18:17:05 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.253 2008/03/18 20:46:36 cube Exp $"); #include "opt_ata.h" @@ -242,7 +242,7 @@ wdc_sataprobe(struct ata_channel *chp) wdr->cmd_iohs[wd_cyl_hi], 0); ATADEBUG_PRINT(("%s: port %d: scnt=0x%x sn=0x%x " "cl=0x%x ch=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, scnt, sn, cl, ch), DEBUG_PROBE); /* * scnt and sn are supposed to be 0x1 for ATAPI, but in some @@ -338,7 +338,7 @@ wdc_drvprobe(struct ata_channel *chp) splx(s); ATADEBUG_PRINT(("%s:%d: wait DRDY st0 0x%x st1 0x%x\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, st0, st1), DEBUG_PROBE); /* Wait a bit, some devices are weird just after a reset. */ @@ -401,7 +401,7 @@ wdc_drvprobe(struct ata_channel *chp) ~(DRIVE_ATA | DRIVE_ATAPI); splx(s); ATADEBUG_PRINT(("%s:%d:%d: IDENTIFY failed (%d)\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, i, error), DEBUG_PROBE); if ((chp->ch_drive[i].drive_flags & DRIVE_OLD) == 0) continue; @@ -425,7 +425,7 @@ wdc_drvprobe(struct ata_channel *chp) wdr->cmd_iohs[wd_cyl_lo], 0) != 0xa5) { ATADEBUG_PRINT(("%s:%d:%d: register " "writability failed\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, i), DEBUG_PROBE); s = splbio(); chp->ch_drive[i].drive_flags &= ~DRIVE_OLD; @@ -434,7 +434,7 @@ wdc_drvprobe(struct ata_channel *chp) } if (wdc_wait_for_ready(chp, 10000, 0) == WDCWAIT_TOUT) { ATADEBUG_PRINT(("%s:%d:%d: not ready\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, i), DEBUG_PROBE); s = splbio(); chp->ch_drive[i].drive_flags &= ~DRIVE_OLD; @@ -446,7 +446,7 @@ wdc_drvprobe(struct ata_channel *chp) delay(10); /* 400ns delay */ if (wdc_wait_for_ready(chp, 10000, 0) == WDCWAIT_TOUT) { ATADEBUG_PRINT(("%s:%d:%d: WDCC_RECAL failed\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, i), DEBUG_PROBE); s = splbio(); chp->ch_drive[i].drive_flags &= ~DRIVE_OLD; @@ -516,7 +516,7 @@ wdcprobe1(struct ata_channel *chp, int poll) } ATADEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, st0, st1), DEBUG_PROBE); if (st0 == 0xff || st0 == WDSD_IBM) @@ -536,7 +536,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x02) { ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo: " "got 0x%x != 0x02\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x01; @@ -548,7 +548,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo: " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x01; @@ -560,7 +560,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 0 wd_sector: " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x01; @@ -572,7 +572,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x02) { ATADEBUG_PRINT(("%s:%d drive 0 wd_sector: " "got 0x%x != 0x02\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x01; @@ -582,7 +582,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo(2): " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x01; @@ -601,7 +601,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x02) { ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo: " "got 0x%x != 0x02\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x02; @@ -613,7 +613,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo: " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x02; @@ -625,7 +625,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 1 wd_sector: " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x02; @@ -637,7 +637,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x02) { ATADEBUG_PRINT(("%s:%d drive 1 wd_sector: " "got 0x%x != 0x02\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x02; @@ -647,7 +647,7 @@ wdcprobe1(struct ata_channel *chp, int poll) if (cl != 0x01) { ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo(2): " "got 0x%x != 0x01\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, cl), DEBUG_PROBE); ret_value &= ~0x02; @@ -694,7 +694,7 @@ wdcprobe1(struct ata_channel *chp, int poll) ret_value = __wdcwait_reset(chp, ret_value, poll); ATADEBUG_PRINT(("%s:%d: after reset, ret_value=0x%d\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, ret_value), DEBUG_PROBE); /* if reset failed, there's nothing here */ @@ -727,7 +727,7 @@ wdcprobe1(struct ata_channel *chp, int poll) ATADEBUG_PRINT(("%s:%d:%d: after reset, sc=0x%x sn=0x%x " "cl=0x%x ch=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive, sc, sn, cl, ch), DEBUG_PROBE); /* * sc & sn are supposted to be 0x1 for ATAPI but in some cases @@ -833,7 +833,7 @@ wdcdetach(device_t self, int flags) if (chp->atabus == NULL) continue; ATADEBUG_PRINT(("wdcdetach: %s: detaching %s\n", - atac->atac_dev.dv_xname, chp->atabus->dv_xname), + device_xname(atac->atac_dev), device_xname(chp->atabus)), DEBUG_DETACH); if ((error = config_detach(chp->atabus, flags)) != 0) return error; @@ -872,7 +872,7 @@ wdcintr(void *arg) struct ata_xfer *xfer; int ret; - if (!device_is_active(&atac->atac_dev)) { + if (!device_is_active(atac->atac_dev)) { ATADEBUG_PRINT(("wdcintr: deactivated controller\n"), DEBUG_INTR); return (0); @@ -922,8 +922,8 @@ wdc_reset_drive(struct ata_drive_datas *drvp, int flags) struct ata_channel *chp = drvp->chnl_softc; ATADEBUG_PRINT(("wdc_reset_drive %s:%d for drive %d\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive), - DEBUG_FUNCS); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, + drvp->drive), DEBUG_FUNCS); ata_reset_channel(chp, flags); } @@ -1041,13 +1041,13 @@ wdcreset(struct ata_channel *chp, int poll) drv_mask2 = __wdcwait_reset(chp, drv_mask1, (poll == RESET_SLEEP) ? 0 : 1); if (drv_mask2 != drv_mask1) { - printf("%s channel %d: reset failed for", - atac->atac_dev.dv_xname, chp->ch_channel); + aprint_error("%s channel %d: reset failed for", + device_xname(atac->atac_dev), chp->ch_channel); if ((drv_mask1 & 0x01) != 0 && (drv_mask2 & 0x01) == 0) - printf(" drive 0"); + aprint_normal(" drive 0"); if ((drv_mask1 & 0x02) != 0 && (drv_mask2 & 0x02) == 0) - printf(" drive 1"); - printf("\n"); + aprint_normal(" drive 1"); + aprint_normal("\n"); } bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT); return (drv_mask1 != drv_mask2) ? 1 : 0; @@ -1175,15 +1175,15 @@ __wdcwait_reset(struct ata_channel *chp, int drv_mask, int poll) end: ATADEBUG_PRINT(("%s:%d:0: after reset, sc=0x%x sn=0x%x " "cl=0x%x ch=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, sc0, sn0, cl0, ch0), DEBUG_PROBE); ATADEBUG_PRINT(("%s:%d:1: after reset, sc=0x%x sn=0x%x " "cl=0x%x ch=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, sc1, sn1, cl1, ch1), DEBUG_PROBE); ATADEBUG_PRINT(("%s:%d: wdcwait_reset() end, st0=0x%x st1=0x%x\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, st0, st1), DEBUG_PROBE); return drv_mask; @@ -1202,7 +1202,7 @@ __wdcwait(struct ata_channel *chp, int mask, int bits, int timeout) int xtime = 0; ATADEBUG_PRINT(("__wdcwait %s:%d\n", - chp->ch_atac->atac_dev.dv_xname, + device_xname(chp->ch_atac->atac_dev), chp->ch_channel), DEBUG_STATUS); chp->ch_error = 0; @@ -1237,12 +1237,12 @@ __wdcwait(struct ata_channel *chp, int mask, int bits, int timeout) struct ata_xfer *xfer = chp->ch_queue->active_xfer; if (xfer == NULL) printf("%s channel %d: warning: busy-wait took %dus\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, - WDCDELAY * xtime); + device_xname(chp->ch_atac->atac_dev), + chp->ch_channel, WDCDELAY * xtime); else printf("%s:%d:%d: warning: busy-wait took %dus\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, - xfer->c_drive, + device_xname(chp->ch_atac->atac_dev), + chp->ch_channel, xfer->c_drive, WDCDELAY * xtime); } #endif @@ -1375,8 +1375,8 @@ wdc_exec_command(struct ata_drive_datas *drvp, struct ata_command *ata_c) int s, ret; ATADEBUG_PRINT(("wdc_exec_command %s:%d:%d\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive), - DEBUG_FUNCS); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, + drvp->drive), DEBUG_FUNCS); /* set up an xfer and queue. Wait for completion */ xfer = ata_get_xfer(ata_c->flags & AT_WAIT ? ATAXF_CANSLEEP : @@ -1432,7 +1432,8 @@ __wdccommand_start(struct ata_channel *chp, struct ata_xfer *xfer) struct ata_command *ata_c = xfer->c_cmd; ATADEBUG_PRINT(("__wdccommand_start %s:%d:%d\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive), + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, + xfer->c_drive), DEBUG_FUNCS); if (wdc->select) @@ -1510,8 +1511,8 @@ __wdccommand_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) again: ATADEBUG_PRINT(("__wdccommand_intr %s:%d:%d\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive), - DEBUG_INTR); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, + xfer->c_drive), DEBUG_INTR); /* * after a ATAPI_SOFT_RESET, the device will have released the bus. * Reselect again, it doesn't hurt for others commands, and the time @@ -1585,7 +1586,7 @@ __wdccommand_done(struct ata_channel *chp, struct ata_xfer *xfer) struct ata_command *ata_c = xfer->c_cmd; ATADEBUG_PRINT(("__wdccommand_done %s:%d:%d flags 0x%x\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, ata_c->flags), DEBUG_FUNCS); @@ -1596,7 +1597,7 @@ __wdccommand_done(struct ata_channel *chp, struct ata_xfer *xfer) ata_c->r_error = chp->ch_error; } if ((ata_c->flags & AT_READREG) != 0 && - device_is_active(&atac->atac_dev) && + device_is_active(atac->atac_dev) && (ata_c->flags & (AT_ERROR | AT_DF)) == 0) { ata_c->r_head = bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0); @@ -1678,9 +1679,9 @@ wdccommand(struct ata_channel *chp, u_int8_t drive, u_int8_t command, struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; ATADEBUG_PRINT(("wdccommand %s:%d:%d: command=0x%x cylin=%d head=%d " - "sector=%d count=%d features=%d\n", chp->ch_atac->atac_dev.dv_xname, - chp->ch_channel, drive, command, cylin, head, sector, count, - features), DEBUG_FUNCS); + "sector=%d count=%d features=%d\n", + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive, + command, cylin, head, sector, count, features), DEBUG_FUNCS); if (wdc->select) wdc->select(chp,drive); @@ -1714,7 +1715,7 @@ wdccommandext(struct ata_channel *chp, u_int8_t drive, u_int8_t command, struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; ATADEBUG_PRINT(("wdccommandext %s:%d:%d: command=0x%x blkno=%d " - "count=%d\n", chp->ch_atac->atac_dev.dv_xname, + "count=%d\n", device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive, command, (u_int32_t) blkno, count), DEBUG_FUNCS); @@ -1778,8 +1779,8 @@ wdccommandshort(struct ata_channel *chp, int drive, int command) struct wdc_regs *wdr = &wdc->regs[chp->ch_channel]; ATADEBUG_PRINT(("wdccommandshort %s:%d:%d command 0x%x\n", - chp->ch_atac->atac_dev.dv_xname, chp->ch_channel, drive, command), - DEBUG_FUNCS); + device_xname(chp->ch_atac->atac_dev), chp->ch_channel, drive, + command), DEBUG_FUNCS); if (wdc->select) wdc->select(chp,drive); @@ -1798,10 +1799,10 @@ __wdcerror(struct ata_channel *chp, const char *msg) struct ata_xfer *xfer = chp->ch_queue->active_xfer; if (xfer == NULL) - printf("%s:%d: %s\n", atac->atac_dev.dv_xname, chp->ch_channel, - msg); + aprint_error("%s:%d: %s\n", device_xname(atac->atac_dev), + chp->ch_channel, msg); else - printf("%s:%d:%d: %s\n", atac->atac_dev.dv_xname, + aprint_error("%s:%d:%d: %s\n", device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, msg); } diff --git a/sys/dev/ic/wdc_upc.c b/sys/dev/ic/wdc_upc.c index 93d9babe8ec..d4926ef2624 100644 --- a/sys/dev/ic/wdc_upc.c +++ b/sys/dev/ic/wdc_upc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_upc.c,v 1.24 2007/10/19 12:00:05 ad Exp $ */ +/* $NetBSD: wdc_upc.c,v 1.25 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2000 Ben Harris * All rights reserved. @@ -28,7 +28,7 @@ /* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.24 2007/10/19 12:00:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.25 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -44,8 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.24 2007/10/19 12:00:05 ad Exp $"); #include <dev/ic/wdcreg.h> #include <dev/ic/wdcvar.h> -static int wdc_upc_match(struct device *, struct cfdata *, void *); -static void wdc_upc_attach(struct device *, struct device *, void *); +static int wdc_upc_match(device_t, cfdata_t, void *); +static void wdc_upc_attach(device_t, device_t, void *); struct wdc_upc_softc { struct wdc_softc sc_wdc; @@ -55,11 +55,11 @@ struct wdc_upc_softc { struct wdc_regs sc_wdc_regs; }; -CFATTACH_DECL(wdc_upc, sizeof(struct wdc_upc_softc), +CFATTACH_DECL_NEW(wdc_upc, sizeof(struct wdc_upc_softc), wdc_upc_match, wdc_upc_attach, NULL, NULL); static int -wdc_upc_match(struct device *parent, struct cfdata *cf, void *aux) +wdc_upc_match(device_t parent, cfdata_t cf, void *aux) { /* upc_submatch does it all anyway */ @@ -67,13 +67,14 @@ wdc_upc_match(struct device *parent, struct cfdata *cf, void *aux) } static void -wdc_upc_attach(struct device *parent, struct device *self, void *aux) +wdc_upc_attach(device_t parent, device_t self, void *aux) { - struct wdc_upc_softc *sc = (struct wdc_upc_softc *)self; + struct wdc_upc_softc *sc = device_private(self); struct wdc_regs *wdr; struct upc_attach_args *ua = aux; int i; + sc->sc_wdc.sc_atac.atac_dev = self; sc->sc_wdc.regs = wdr = &sc->sc_wdc_regs; sc->sc_wdc.sc_atac.atac_cap = ATAC_CAP_DATA16; @@ -92,8 +93,8 @@ wdc_upc_attach(struct device *parent, struct device *self, void *aux) for (i = 0; i < WDC_NREG; i++) { if (bus_space_subregion(ua->ua_iot, ua->ua_ioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: can't subregion I/O space\n", - sc->sc_wdc.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdc.sc_atac.atac_dev, + "can't subregion I/O space\n"); return; } } diff --git a/sys/dev/isa/wdc_isa.c b/sys/dev/isa/wdc_isa.c index 2d1aa3ed059..857dd78b22e 100644 --- a/sys/dev/isa/wdc_isa.c +++ b/sys/dev/isa/wdc_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_isa.c,v 1.53 2008/01/10 07:44:08 dyoung Exp $ */ +/* $NetBSD: wdc_isa.c,v 1.54 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_isa.c,v 1.53 2008/01/10 07:44:08 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_isa.c,v 1.54 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -74,11 +74,11 @@ struct wdc_isa_softc { int sc_drq; }; -static int wdc_isa_probe(device_t , struct cfdata *, void *); +static int wdc_isa_probe(device_t , cfdata_t, void *); static void wdc_isa_attach(device_t, device_t, void *); static int wdc_isa_detach(device_t, int); -CFATTACH_DECL2(wdc_isa, sizeof(struct wdc_isa_softc), +CFATTACH_DECL2_NEW(wdc_isa, sizeof(struct wdc_isa_softc), wdc_isa_probe, wdc_isa_attach, wdc_isa_detach, NULL, NULL, wdc_childdetached); @@ -90,7 +90,7 @@ static int wdc_isa_dma_finish(void*, int, int, int); #endif static int -wdc_isa_probe(device_t parent, struct cfdata *match, void *aux) +wdc_isa_probe(device_t parent, cfdata_t match, void *aux) { struct ata_channel ch; struct isa_attach_args *ia = aux; @@ -180,6 +180,7 @@ wdc_isa_attach(device_t parent, device_t self, void *aux) int wdc_cf_flags = device_cfdata(self)->cf_flags; int i; + sc->sc_wdcdev.sc_atac.atac_dev = self; sc->sc_wdcdev.regs = wdr = &sc->wdc_regs; wdr->cmd_iot = ia->ia_iot; wdr->ctl_iot = ia->ia_iot; @@ -189,7 +190,7 @@ wdc_isa_attach(device_t parent, device_t self, void *aux) bus_space_map(wdr->ctl_iot, ia->ia_io[0].ir_addr + WDC_ISA_AUXREG_OFFSET, WDC_ISA_AUXREG_NPORTS, 0, &wdr->ctl_ioh)) { - printf(": couldn't map registers\n"); + aprint_error(": couldn't map registers\n"); return; } @@ -197,7 +198,7 @@ wdc_isa_attach(device_t parent, device_t self, void *aux) if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - printf(": couldn't subregion registers\n"); + aprint_error(": couldn't subregion registers\n"); return; } } @@ -236,7 +237,7 @@ wdc_isa_attach(device_t parent, device_t self, void *aux) sc->ata_channel.ch_ndrive = 2; wdc_init_shadow_regs(&sc->ata_channel); - printf("\n"); + aprint_normal("\n"); sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_BIO, wdcintr, &sc->ata_channel); @@ -251,23 +252,24 @@ wdc_isa_dma_setup(struct wdc_isa_softc *sc) bus_size_t maxsize; if ((maxsize = isa_dmamaxsize(sc->sc_ic, sc->sc_drq)) < MAXPHYS) { - printf("%s: max DMA size %lu is less than required %d\n", - sc->sc_wdcdev.sc_dev.dv_xname, (u_long)maxsize, MAXPHYS); + aprint_error_dev(sc_wdcdev.sc_atac.atac_dev, + "max DMA size %lu is less than required %d\n", + (u_long)maxsize, MAXPHYS); sc->sc_wdcdev.sc_atac.atac_cap &= ~ATAC_CAP_DMA; return; } if (isa_drq_alloc(sc->sc_ic, sc->sc_drq) != 0) { - printf("%s: can't reserve drq %d\n", - sc->sc_wdcdev.sc_dev.dv_xname, sc->sc_drq); + aprint_error_dev(sc_wdcdev.sc_atac.atac_dev, + "can't reserve drq %d\n", sc->sc_drq); sc->sc_wdcdev.sc_atac.atac_cap &= ~ATAC_CAP_DMA; return; } if (isa_dmamap_create(sc->sc_ic, sc->sc_drq, MAXPHYS, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { - printf("%s: can't create map for drq %d\n", - sc->sc_wdcdev.sc_dev.dv_xname, sc->sc_drq); + aprint_error_dev(sc_wdcdev.sc_atac.atac_dev, + "can't create map for drq %d\n", sc->sc_drq); sc->sc_wdcdev.sc_atac.atac_cap &= ~ATAC_CAP_DMA; } } diff --git a/sys/dev/isapnp/wdc_isapnp.c b/sys/dev/isapnp/wdc_isapnp.c index a083aa37f7f..76a59f4371f 100644 --- a/sys/dev/isapnp/wdc_isapnp.c +++ b/sys/dev/isapnp/wdc_isapnp.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_isapnp.c,v 1.37 2007/10/19 12:00:33 ad Exp $ */ +/* $NetBSD: wdc_isapnp.c,v 1.38 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_isapnp.c,v 1.37 2007/10/19 12:00:33 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_isapnp.c,v 1.38 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -69,10 +69,10 @@ struct wdc_isapnp_softc { int sc_drq; }; -static int wdc_isapnp_probe(struct device *, struct cfdata *, void *); -static void wdc_isapnp_attach(struct device *, struct device *, void *); +static int wdc_isapnp_probe(device_t, cfdata_t, void *); +static void wdc_isapnp_attach(device_t, device_t, void *); -CFATTACH_DECL(wdc_isapnp, sizeof(struct wdc_isapnp_softc), +CFATTACH_DECL_NEW(wdc_isapnp, sizeof(struct wdc_isapnp_softc), wdc_isapnp_probe, wdc_isapnp_attach, NULL, NULL); #ifdef notyet @@ -82,8 +82,7 @@ static void wdc_isapnp_dma_finish(void *); #endif static int -wdc_isapnp_probe(struct device *parent, struct cfdata *match, - void *aux) +wdc_isapnp_probe(device_t parent, cfdata_t match, void *aux) { int pri, variant; @@ -94,8 +93,7 @@ wdc_isapnp_probe(struct device *parent, struct cfdata *match, } static void -wdc_isapnp_attach(struct device *parent, struct device *self, - void *aux) +wdc_isapnp_attach(device_t parent, device_t self, void *aux) { struct wdc_isapnp_softc *sc = device_private(self); struct wdc_regs *wdr; @@ -107,17 +105,18 @@ wdc_isapnp_attach(struct device *parent, struct device *self, ipa->ipa_nmem32 != 0 || ipa->ipa_nirq != 1 || ipa->ipa_ndrq > 1) { - printf(": unexpected configuration\n"); + aprint_error(": unexpected configuration\n"); return; } if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) { - printf(": couldn't map registers\n"); + aprint_error(": couldn't map registers\n"); return; } - printf(": %s %s\n", ipa->ipa_devident, ipa->ipa_devclass); + aprint_normal(": %s %s\n", ipa->ipa_devident, ipa->ipa_devclass); + sc->sc_wdcdev.sc_atac.atac_dev = self; sc->sc_wdcdev.regs = wdr = &sc->wdc_regs; wdr->cmd_iot = ipa->ipa_iot; wdr->ctl_iot = ipa->ipa_iot; @@ -138,7 +137,7 @@ wdc_isapnp_attach(struct device *parent, struct device *self, if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - printf(": couldn't subregion registers\n"); + aprint_error(": couldn't subregion registers\n"); return; } } @@ -181,8 +180,8 @@ wdc_isapnp_dma_setup(struct wdc_isapnp_softc *sc) if (isa_dmamap_create(sc->sc_ic, sc->sc_drq, MAXPHYS, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { - printf("%s: can't create map for drq %d\n", - sc->sc_wdcdev.sc_dev.dv_xname, sc->sc_drq); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "can't create map for drq %d\n", sc->sc_drq); sc->sc_wdcdev.sc_atac.atac_cap &= ~ATAC_CAP_DMA; } } diff --git a/sys/dev/ofisa/wdc_ofisa.c b/sys/dev/ofisa/wdc_ofisa.c index 1ee2424dc11..b41f3bd1f86 100644 --- a/sys/dev/ofisa/wdc_ofisa.c +++ b/sys/dev/ofisa/wdc_ofisa.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_ofisa.c,v 1.29 2007/10/19 12:00:38 ad Exp $ */ +/* $NetBSD: wdc_ofisa.c,v 1.30 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright 1997, 1998 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.29 2007/10/19 12:00:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.30 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -66,14 +66,14 @@ struct wdc_ofisa_softc { void *sc_ih; }; -static int wdc_ofisa_probe(struct device *, struct cfdata *, void *); -static void wdc_ofisa_attach(struct device *, struct device *, void *); +static int wdc_ofisa_probe(device_t, cfdata_t, void *); +static void wdc_ofisa_attach(device_t, device_t, void *); -CFATTACH_DECL(wdc_ofisa, sizeof(struct wdc_ofisa_softc), +CFATTACH_DECL_NEW(wdc_ofisa, sizeof(struct wdc_ofisa_softc), wdc_ofisa_probe, wdc_ofisa_attach, NULL, NULL); static int -wdc_ofisa_probe(struct device *parent, struct cfdata *cf, void *aux) +wdc_ofisa_probe(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; static const char *const compatible_strings[] = { "pnpPNP,600", NULL }; @@ -89,7 +89,7 @@ wdc_ofisa_probe(struct device *parent, struct cfdata *cf, void *aux) } static void -wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) +wdc_ofisa_attach(device_t parent, device_t self, void *aux) { struct wdc_ofisa_softc *sc = device_private(self); struct wdc_regs *wdr; @@ -106,6 +106,7 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) * We expect exactly two register regions and one interrupt. */ + sc->sc_wdcdev.sc_atac.atac_dev = self; sc->sc_wdcdev.regs = wdr = &sc->wdc_regs; n = ofisa_reg_get(aa->oba.oba_phandle, reg, 2); @@ -113,11 +114,11 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) n = wdc_ofisa_md_reg_fixup(parent, self, aux, reg, 2, n); #endif if (n != 2) { - printf(": error getting register data\n"); + aprint_error(": error getting register data\n"); return; } if (reg[0].len != 8 || reg[1].len != 2) { - printf(": weird register size (%lu/%lu, expected 8/2)\n", + aprint_error(": weird register size (%lu/%lu, expected 8/2)\n", (unsigned long)reg[0].len, (unsigned long)reg[1].len); return; } @@ -127,7 +128,7 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) n = wdc_ofisa_md_intr_fixup(parent, self, aux, &intr, 1, n); #endif if (n != 1) { - printf(": error getting interrupt data\n"); + aprint_error(": error getting interrupt data\n"); return; } @@ -136,7 +137,7 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) if (bus_space_map(wdr->cmd_iot, reg[0].addr, 8, 0, &ioh) || bus_space_map(wdr->ctl_iot, reg[1].addr, 1, 0, &wdr->ctl_ioh)) { - printf(": can't map register spaces\n"); + aprint_error(": can't map register spaces\n"); return; } wdr->cmd_baseioh = ioh; @@ -144,7 +145,7 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) for (n = 0; n < WDC_NREG; n++) { if (bus_space_subregion(wdr->cmd_iot, ioh, n, n == 0 ? 4 : 1, &wdr->cmd_iohs[n]) != 0) { - printf(": can't subregion register space\n"); + aprint_error(": can't subregion register space\n"); return; } } @@ -152,7 +153,7 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) sc->sc_ih = isa_intr_establish(aa->ic, intr.irq, intr.share, IPL_BIO, wdcintr, &sc->sc_channel); - printf("\n"); + aprint_normal("\n"); sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16; sc->sc_chanlist[0] = &sc->sc_channel; sc->sc_wdcdev.sc_atac.atac_channels = sc->sc_chanlist; @@ -167,11 +168,11 @@ wdc_ofisa_attach(struct device *parent, struct device *self, void *aux) wdcattach(&sc->sc_channel); #if 0 - printf("%s: registers: ", sc->sc_dev.dv_xname); + aprint_verbose_dev(self, "registers: "); ofisa_reg_print(reg, 2); - printf("\n"); - printf("%s: interrupts: ", sc->sc_dev.dv_xname); + aprint_verbose("\n"); + aprint_verbose_dev(self, "interrupts: "); ofisa_intr_print(&intr, 1); - printf("\n"); + aprint_verbose("\n"); #endif } diff --git a/sys/dev/pci/acardide.c b/sys/dev/pci/acardide.c index 5e734abef7a..f52e9033637 100644 --- a/sys/dev/pci/acardide.c +++ b/sys/dev/pci/acardide.c @@ -1,4 +1,4 @@ -/* $NetBSD: acardide.c,v 1.21 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: acardide.c,v 1.22 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2001 Izumi Tsutsui. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acardide.c,v 1.21 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acardide.c,v 1.22 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -44,10 +44,10 @@ static void acard_setup_channel(struct ata_channel*); static int acard_pci_intr(void *); #endif -static int acardide_match(struct device *, struct cfdata *, void *); -static void acardide_attach(struct device *, struct device *, void *); +static int acardide_match(device_t, cfdata_t, void *); +static void acardide_attach(device_t, device_t, void *); -CFATTACH_DECL(acardide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(acardide, sizeof(struct pciide_softc), acardide_match, acardide_attach, NULL, NULL); static const struct pciide_product_desc pciide_acard_products[] = { @@ -84,8 +84,7 @@ static const struct pciide_product_desc pciide_acard_products[] = { }; static int -acardide_match(struct device *parent, struct cfdata *match, - void *aux) +acardide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -97,10 +96,12 @@ acardide_match(struct device *parent, struct cfdata *match, } static void -acardide_attach(struct device *parent, struct device *self, void *aux) +acardide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_acard_products)); @@ -132,8 +133,8 @@ acard_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1); } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -321,7 +322,7 @@ acard_pci_intr(void *arg) crv = wdcintr(wdc_cp); if (crv == 0) { printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), i); bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0, dmastat); } else if (crv == 1) diff --git a/sys/dev/pci/aceride.c b/sys/dev/pci/aceride.c index 08e43c64ea6..3a34510acd3 100644 --- a/sys/dev/pci/aceride.c +++ b/sys/dev/pci/aceride.c @@ -1,4 +1,4 @@ -/* $NetBSD: aceride.c,v 1.24 2008/01/01 14:57:06 chris Exp $ */ +/* $NetBSD: aceride.c,v 1.25 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.24 2008/01/01 14:57:06 chris Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.25 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,15 +47,15 @@ static void acer_chip_map(struct pciide_softc*, struct pci_attach_args*); static void acer_setup_channel(struct ata_channel*); static int acer_pci_intr(void *); -static int aceride_match(struct device *, struct cfdata *, void *); -static void aceride_attach(struct device *, struct device *, void *); +static int aceride_match(device_t, cfdata_t, void *); +static void aceride_attach(device_t, device_t, void *); struct aceride_softc { struct pciide_softc pciide_sc; struct pci_attach_args pcib_pa; }; -CFATTACH_DECL(aceride, sizeof(struct aceride_softc), +CFATTACH_DECL_NEW(aceride, sizeof(struct aceride_softc), aceride_match, aceride_attach, NULL, NULL); static const struct pciide_product_desc pciide_acer_products[] = { @@ -72,8 +72,7 @@ static const struct pciide_product_desc pciide_acer_products[] = { }; static int -aceride_match(struct device *parent, struct cfdata *match, - void *aux) +aceride_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -87,14 +86,15 @@ aceride_match(struct device *parent, struct cfdata *match, } static void -aceride_attach(struct device *parent, struct device *self, void *aux) +aceride_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_acer_products)); - } static int @@ -125,8 +125,8 @@ acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -177,7 +177,7 @@ acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) bool force_compat_mode; bool property_is_set; property_is_set = prop_dictionary_get_bool( - device_properties(&sc->sc_wdcdev.sc_atac.atac_dev), + device_properties(sc->sc_wdcdev.sc_atac.atac_dev), "ali1543-ide-force-compat-mode", &force_compat_mode); if (property_is_set && force_compat_mode) { @@ -203,8 +203,8 @@ acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (rev == 0xC3) { /* install reset bug workaround */ if (pci_find_device(&acer_sc->pcib_pa, acer_pcib_match) == 0) { - printf("%s: WARNING: can't find pci-isa bridge\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "WARNING: can't find pci-isa bridge\n"); } else sc->sc_wdcdev.reset = acer_do_reset; } @@ -215,8 +215,8 @@ acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chansetup(sc, channel, interface) == 0) continue; if ((interface & PCIIDE_CHAN_EN(channel)) == 0) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } @@ -365,8 +365,9 @@ acer_pci_intr(void *arg) if (chids & ACER_CHIDS_INT(i)) { crv = wdcintr(wdc_cp); if (crv == 0) { - printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + aprint_error("%s:%d: bogus intr\n", + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), i); pciide_irqack(wdc_cp); } else rv = 1; diff --git a/sys/dev/pci/ahcisata_pci.c b/sys/dev/pci/ahcisata_pci.c index 0b87dd5e8dd..74e34615862 100644 --- a/sys/dev/pci/ahcisata_pci.c +++ b/sys/dev/pci/ahcisata_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_pci.c,v 1.8 2008/02/29 06:13:39 dyoung Exp $ */ +/* $NetBSD: ahcisata_pci.c,v 1.9 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.8 2008/02/29 06:13:39 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.9 2008/03/18 20:46:36 cube Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -50,23 +50,22 @@ __KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.8 2008/02/29 06:13:39 dyoung Exp #include <dev/ic/ahcisatavar.h> struct ahci_pci_softc { - struct ahci_softc ah_sc; /* must come first, struct device */ + struct ahci_softc ah_sc; pci_chipset_tag_t sc_pc; pcitag_t sc_pcitag; }; -static int ahci_pci_match(struct device *, struct cfdata *, void *); -static void ahci_pci_attach(struct device *, struct device *, void *); +static int ahci_pci_match(device_t, cfdata_t, void *); +static void ahci_pci_attach(device_t, device_t, void *); static bool ahci_pci_resume(device_t PMF_FN_PROTO); -CFATTACH_DECL(ahcisata_pci, sizeof(struct ahci_pci_softc), +CFATTACH_DECL_NEW(ahcisata_pci, sizeof(struct ahci_pci_softc), ahci_pci_match, ahci_pci_attach, NULL, NULL); static int -ahci_pci_match(struct device *parent, struct cfdata *match, - void *aux) +ahci_pci_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; bus_space_tag_t regt; @@ -96,10 +95,10 @@ ahci_pci_match(struct device *parent, struct cfdata *match, } static void -ahci_pci_attach(struct device *parent, struct device *self, void *aux) +ahci_pci_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct ahci_pci_softc *psc = (struct ahci_pci_softc *)self; + struct ahci_pci_softc *psc = device_private(self); struct ahci_softc *sc = &psc->ah_sc; bus_size_t size; char devinfo[256]; @@ -110,7 +109,7 @@ ahci_pci_attach(struct device *parent, struct device *self, void *aux) if (pci_mapreg_map(pa, AHCI_PCI_ABAR, PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_ahcit, &sc->sc_ahcih, NULL, &size) != 0) { - aprint_error("%s: can't map ahci registers\n", AHCINAME(sc)); + aprint_error_dev(self, "can't map ahci registers\n"); return; } psc->sc_pc = pa->pa_pc; diff --git a/sys/dev/pci/artsata.c b/sys/dev/pci/artsata.c index b82d850fd29..c24e5d370e8 100644 --- a/sys/dev/pci/artsata.c +++ b/sys/dev/pci/artsata.c @@ -1,4 +1,4 @@ -/* $NetBSD: artsata.c,v 1.16 2007/07/19 21:53:15 dsl Exp $ */ +/* $NetBSD: artsata.c,v 1.17 2008/03/18 20:46:36 cube Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: artsata.c,v 1.16 2007/07/19 21:53:15 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: artsata.c,v 1.17 2008/03/18 20:46:36 cube Exp $"); #include "opt_pciide.h" @@ -58,8 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: artsata.c,v 1.16 2007/07/19 21:53:15 dsl Exp $"); static void artisea_chip_map(struct pciide_softc*, struct pci_attach_args *); -static int artsata_match(struct device *, struct cfdata *, void *); -static void artsata_attach(struct device *, struct device *, void *); +static int artsata_match(device_t, cfdata_t, void *); +static void artsata_attach(device_t, device_t, void *); static const struct pciide_product_desc pciide_artsata_products[] = { { PCI_PRODUCT_INTEL_31244, @@ -96,12 +96,11 @@ static const struct artisea_cmd_map artisea_dpa_cmd_map[] = #define ARTISEA_NUM_CHAN 4 -CFATTACH_DECL(artsata, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(artsata, sizeof(struct pciide_softc), artsata_match, artsata_attach, NULL, NULL); static int -artsata_match(struct device *parent, struct cfdata *match, - void *aux) +artsata_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -113,10 +112,12 @@ artsata_match(struct device *parent, struct cfdata *match, } static void -artsata_attach(struct device *parent, struct device *self, void *aux) +artsata_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_artsata_products)); @@ -139,21 +140,20 @@ artisea_mapregs(struct pci_attach_args *pa, struct pciide_channel *cp, if (sc->sc_pci_ih == NULL) { if (pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map native-PCI interrupt\n"); goto bad; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); sc->sc_pci_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO, pci_intr, sc); if (sc->sc_pci_ih != NULL) { - aprint_normal("%s: using %s for native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "using %s for native-PCI interrupt\n", intrstr ? intrstr : "unknown interrupt"); } else { - aprint_error( - "%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) aprint_normal(" at %s", intrstr); aprint_normal("\n"); @@ -165,16 +165,16 @@ artisea_mapregs(struct pci_attach_args *pa, struct pciide_channel *cp, if (bus_space_subregion (sc->sc_ba5_st, sc->sc_ba5_sh, ARTISEA_DPA_PORT_BASE(wdc_cp->ch_channel), 0x200, &wdr->cmd_baseioh) != 0) { - aprint_error("%s: couldn't map %s channel cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel cmd regs\n", cp->name); goto bad; } wdr->ctl_iot = sc->sc_ba5_st; if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, ARTISEA_SUPDDCTLR, 1, &cp->ctl_baseioh) != 0) { - aprint_error("%s: couldn't map %s channel ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel ctl regs\n", cp->name); goto bad; } wdr->ctl_ioh = cp->ctl_baseioh; @@ -184,9 +184,9 @@ artisea_mapregs(struct pci_attach_args *pa, struct pciide_channel *cp, if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, artisea_dpa_cmd_map[i].offset, artisea_dpa_cmd_map[i].size, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s channel " - "cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s channel cmd regs\n", + cp->name); goto bad; } } @@ -199,27 +199,24 @@ artisea_mapregs(struct pci_attach_args *pa, struct pciide_channel *cp, if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, ARTISEA_SUPERSET_DPA_OFF + ARTISEA_SUPDSSSR, 1, &wdr->sata_status) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_status regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_status regs\n", wdc_cp->ch_channel); goto bad; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, ARTISEA_SUPERSET_DPA_OFF + ARTISEA_SUPDSSER, 1, &wdr->sata_error) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_error regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_error regs\n", wdc_cp->ch_channel); goto bad; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, ARTISEA_SUPERSET_DPA_OFF + ARTISEA_SUPDSSCR, 1, &wdr->sata_control) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_control regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_control regs\n", wdc_cp->ch_channel); goto bad; } @@ -247,7 +244,7 @@ artisea_chansetup(struct pciide_softc *sc, int channel, if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s %s channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cp->name); return 0; } return 1; @@ -261,8 +258,8 @@ artisea_mapreg_dma(struct pciide_softc *sc, struct pci_attach_args *pa) u_int32_t dma_ctl; u_int32_t cacheline_len; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); sc->sc_dma_ok = 1; @@ -293,7 +290,7 @@ artisea_mapreg_dma(struct pciide_softc *sc, struct pci_attach_args *pa) sc->sc_dma_iot = sc->sc_ba5_st; sc->sc_dmat = pa->pa_dmat; - if (device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & + if (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & PCIIDE_OPTIONS_NODMA) { aprint_verbose( ", but unused (forced off by config file)\n"); @@ -336,8 +333,8 @@ artisea_chip_map_dpa(struct pciide_softc *sc, struct pci_attach_args *pa) interface = PCI_INTERFACE(pa->pa_class); - aprint_normal("%s: interface wired in DPA mode\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "interface wired in DPA mode\n"); if (pci_mapreg_map(pa, ARTISEA_PCI_DPA_BASE, PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, NULL) != 0) @@ -374,8 +371,8 @@ artisea_chip_map_dpa(struct pciide_softc *sc, struct pci_attach_args *pa) if ((bus_space_read_4 (sc->sc_ba5_st, sc->sc_ba5_sh, ARTISEA_DPA_PORT_BASE(0) + ARTISEA_SUPERSET_DPA_OFF + ARTISEA_SUPDPFR) & SUPDPFR_SSCEN) != 0) { - aprint_error("%s: Spread-specturm clocking not supported by device\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "Spread-specturm clocking not supported by device\n"); return; } @@ -412,8 +409,8 @@ artisea_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) return; } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); #ifdef PCIIDE_I31244_DISABLEDMA if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_31244 && PCI_REVISION(pa->pa_class) == 0) { diff --git a/sys/dev/pci/cmdide.c b/sys/dev/pci/cmdide.c index 499edfc4d56..c91efcffcfd 100644 --- a/sys/dev/pci/cmdide.c +++ b/sys/dev/pci/cmdide.c @@ -1,4 +1,4 @@ -/* $NetBSD: cmdide.c,v 1.27 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: cmdide.c,v 1.28 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.27 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.28 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -43,10 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.27 2007/02/09 21:55:27 ad Exp $"); #include <dev/pci/pciide_cmd_reg.h> -static int cmdide_match(struct device *, struct cfdata *, void *); -static void cmdide_attach(struct device *, struct device *, void *); +static int cmdide_match(device_t, cfdata_t, void *); +static void cmdide_attach(device_t, device_t, void *); -CFATTACH_DECL(cmdide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(cmdide, sizeof(struct pciide_softc), cmdide_match, cmdide_attach, NULL, NULL); static void cmd_chip_map(struct pciide_softc*, struct pci_attach_args*); @@ -100,8 +100,7 @@ static const struct pciide_product_desc pciide_cmd_products[] = { }; static int -cmdide_match(struct device *parent, struct cfdata *match, - void *aux) +cmdide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -113,10 +112,12 @@ cmdide_match(struct device *parent, struct cfdata *match, } static void -cmdide_attach(struct device *parent, struct device *self, void *aux) +cmdide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_cmd_products)); @@ -174,13 +175,13 @@ cmd_channel_map(struct pci_attach_args *pa, struct pciide_softc *sc, if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s %s channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cp->name); return; } cp->ata_channel.ch_ndrive = 2; - aprint_normal("%s: %s channel %s to %s mode\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel %s to %s mode\n", cp->name, (interface & PCIIDE_INTERFACE_SETTABLE(channel)) ? "configured" : "wired", (interface & PCIIDE_INTERFACE_PCI(channel)) ? @@ -192,8 +193,8 @@ cmd_channel_map(struct pci_attach_args *pa, struct pciide_softc *sc, * the whole device */ if (channel != 0 && (ctrl & CMD_CTRL_2PORT) == 0) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; return; } @@ -223,8 +224,9 @@ cmd_pci_intr(void *arg) (i == 1 && (secirq & CMD_ARTTIM23_IRQ))) { crv = wdcintr(wdc_cp); if (crv == 0) { - printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + aprint_error("%s:%d: bogus intr\n", + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), i); sc->sc_wdcdev.irqack(wdc_cp); } else rv = 1; @@ -253,8 +255,8 @@ cmd_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) return; #endif - aprint_normal("%s: hardware does not support DMA\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "hardware does not support DMA\n"); sc->sc_dma_ok = 0; sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanarray; @@ -290,8 +292,8 @@ cmd0643_9_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) return; #endif - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -467,8 +469,8 @@ cmd680_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -527,7 +529,7 @@ cmd680_channel_map(struct pci_attach_args *pa, struct pciide_softc *sc, if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s %s channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cp->name); return; } cp->ata_channel.ch_ndrive = 2; @@ -537,8 +539,8 @@ cmd680_channel_map(struct pci_attach_args *pa, struct pciide_softc *sc, for (i = 0; i < sizeof(init_val); i++) pciide_pci_write(sc->sc_pc, sc->sc_tag, reg + i, init_val[i]); - aprint_normal("%s: %s channel %s to %s mode\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel %s to %s mode\n", cp->name, (interface & PCIIDE_INTERFACE_SETTABLE(channel)) ? "configured" : "wired", (interface & PCIIDE_INTERFACE_PCI(channel)) ? diff --git a/sys/dev/pci/cypide.c b/sys/dev/pci/cypide.c index f54c4417f23..a01edde5960 100644 --- a/sys/dev/pci/cypide.c +++ b/sys/dev/pci/cypide.c @@ -1,4 +1,4 @@ -/* $NetBSD: cypide.c,v 1.20 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: cypide.c,v 1.21 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cypide.c,v 1.20 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cypide.c,v 1.21 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,10 +47,10 @@ __KERNEL_RCSID(0, "$NetBSD: cypide.c,v 1.20 2007/02/09 21:55:27 ad Exp $"); static void cy693_chip_map(struct pciide_softc*, struct pci_attach_args*); static void cy693_setup_channel(struct ata_channel*); -static int cypide_match(struct device *, struct cfdata *, void *); -static void cypide_attach(struct device *, struct device *, void *); +static int cypide_match(device_t, cfdata_t, void *); +static void cypide_attach(device_t, device_t, void *); -CFATTACH_DECL(cypide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(cypide, sizeof(struct pciide_softc), cypide_match, cypide_attach, NULL, NULL); static const struct pciide_product_desc pciide_cypress_products[] = { @@ -67,8 +67,7 @@ static const struct pciide_product_desc pciide_cypress_products[] = { }; static int -cypide_match(struct device *parent, struct cfdata *match, - void *aux) +cypide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -82,10 +81,12 @@ cypide_match(struct device *parent, struct cfdata *match, } static void -cypide_attach(struct device *parent, struct device *self, void *aux) +cypide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_cypress_products)); @@ -112,24 +113,24 @@ cy693_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) } else if (pa->pa_function == 2) { sc->sc_cy_compatchan = 1; } else { - aprint_error("%s: unexpected PCI function %d\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, pa->pa_function); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "unexpected PCI function %d\n", pa->pa_function); return; } if (interface & PCIIDE_INTERFACE_BUS_MASTER_DMA) { - aprint_verbose("%s: bus-master DMA support present\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present\n"); pciide_mapreg_dma(sc, pa); } else { - aprint_normal("%s: hardware does not support DMA\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "hardware does not support DMA\n"); sc->sc_dma_ok = 0; } sc->sc_cy_handle = cy82c693_init(pa->pa_iot); if (sc->sc_cy_handle == NULL) { - aprint_error("%s: unable to map hyperCache control registers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "unable to map hyperCache control registers\n"); sc->sc_dma_ok = 0; } @@ -159,11 +160,11 @@ cy693_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s primary channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev)); return; } - aprint_normal("%s: primary channel %s to ", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "primary channel %s to ", (interface & PCIIDE_INTERFACE_SETTABLE(0)) ? "configured" : "wired"); if (interface & PCIIDE_INTERFACE_PCI(0)) { diff --git a/sys/dev/pci/geodeide.c b/sys/dev/pci/geodeide.c index 484ebeb07e9..64bb9b1f569 100644 --- a/sys/dev/pci/geodeide.c +++ b/sys/dev/pci/geodeide.c @@ -1,4 +1,4 @@ -/* $NetBSD: geodeide.c,v 1.14 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: geodeide.c,v 1.15 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2004 Manuel Bouyer. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: geodeide.c,v 1.14 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: geodeide.c,v 1.15 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -56,10 +56,10 @@ static void geodeide_chip_map(struct pciide_softc *, static void geodeide_setup_channel(struct ata_channel *); static int geodeide_dma_init(void *, int, int, void *, size_t, int); -static int geodeide_match(struct device *, struct cfdata *, void *); -static void geodeide_attach(struct device *, struct device *, void *); +static int geodeide_match(device_t, cfdata_t, void *); +static void geodeide_attach(device_t, device_t, void *); -CFATTACH_DECL(geodeide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(geodeide, sizeof(struct pciide_softc), geodeide_match, geodeide_attach, NULL, NULL); static const struct pciide_product_desc pciide_geode_products[] = { @@ -81,8 +81,7 @@ static const struct pciide_product_desc pciide_geode_products[] = { }; static int -geodeide_match(struct device *parent, struct cfdata *match, - void *aux) +geodeide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -96,10 +95,12 @@ geodeide_match(struct device *parent, struct cfdata *match, } static void -geodeide_attach(struct device *parent, struct device *self, void *aux) +geodeide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (void *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_geode_products)); @@ -115,8 +116,8 @@ geodeide_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); if (sc->sc_dma_ok) { diff --git a/sys/dev/pci/hptide.c b/sys/dev/pci/hptide.c index 25aa182a16a..970baecdc28 100644 --- a/sys/dev/pci/hptide.c +++ b/sys/dev/pci/hptide.c @@ -1,4 +1,4 @@ -/* $NetBSD: hptide.c,v 1.24 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: hptide.c,v 1.25 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hptide.c,v 1.24 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hptide.c,v 1.25 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -45,10 +45,10 @@ static void hpt_chip_map(struct pciide_softc*, struct pci_attach_args*); static void hpt_setup_channel(struct ata_channel*); static int hpt_pci_intr(void *); -static int hptide_match(struct device *, struct cfdata *, void *); -static void hptide_attach(struct device *, struct device *, void *); +static int hptide_match(device_t, cfdata_t, void *); +static void hptide_attach(device_t, device_t, void *); -CFATTACH_DECL(hptide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(hptide, sizeof(struct pciide_softc), hptide_match, hptide_attach, NULL, NULL); static const struct pciide_product_desc pciide_triones_products[] = { @@ -85,8 +85,7 @@ static const struct pciide_product_desc pciide_triones_products[] = { }; static int -hptide_match(struct device *parent, struct cfdata *match, - void *aux) +hptide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -98,10 +97,12 @@ hptide_match(struct device *parent, struct cfdata *match, } static void -hptide_attach(struct device *parent, struct device *self, void *aux) +hptide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_triones_products)); @@ -120,8 +121,8 @@ hpt_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) return; revision = PCI_REVISION(pa->pa_class); - aprint_normal("%s: Triones/Highpoint ", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "Triones/Highpoint "); switch (sc->sc_pp->ide_product) { case PCI_PRODUCT_TRIONES_HPT302: aprint_normal("HPT302 IDE Controller\n"); @@ -174,8 +175,8 @@ hpt_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) interface |= PCIIDE_INTERFACE_PCI(1); } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -215,7 +216,9 @@ hpt_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) HPT370_CTRL1(i)) & HPT370_CTRL1_EN) == 0) { aprint_normal( "%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), + cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } @@ -230,8 +233,10 @@ hpt_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) else if (pa->pa_function == 1) compatchan = 1; else { - aprint_error("%s: unexpected PCI function %d\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, pa->pa_function); + aprint_error_dev( + sc->sc_wdcdev.sc_atac.atac_dev, + "unexpected PCI function %d\n", + pa->pa_function); return; } } @@ -375,7 +380,7 @@ hpt_setup_channel(struct ata_channel *chp) pci_conf_write(sc->sc_pc, sc->sc_tag, HPT_IDETIM(chp->ch_channel, drive), after); ATADEBUG_PRINT(("%s: bus speed register set to 0x%08x " - "(BIOS 0x%08x)\n", drvp->drv_softc->dv_xname, + "(BIOS 0x%08x)\n", device_xname(drvp->drv_softc), after, before), DEBUG_PROBE); } if (idedma_ctl != 0) { @@ -404,8 +409,8 @@ hpt_pci_intr(void *arg) wdc_cp = &cp->ata_channel; crv = wdcintr(wdc_cp); if (crv == 0) { - printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + aprint_error("%s:%d: bogus intr\n", + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), i); bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0, dmastat); } else diff --git a/sys/dev/pci/iteide.c b/sys/dev/pci/iteide.c index cc233c937bf..cdda9bc42c8 100644 --- a/sys/dev/pci/iteide.c +++ b/sys/dev/pci/iteide.c @@ -1,4 +1,4 @@ -/* $NetBSD: iteide.c,v 1.8 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: iteide.c,v 1.9 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iteide.c,v 1.8 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iteide.c,v 1.9 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -45,10 +45,10 @@ __KERNEL_RCSID(0, "$NetBSD: iteide.c,v 1.8 2007/02/09 21:55:27 ad Exp $"); static void ite_chip_map(struct pciide_softc*, struct pci_attach_args*); static void ite_setup_channel(struct ata_channel*); -static int iteide_match(struct device *, struct cfdata *, void *); -static void iteide_attach(struct device *, struct device *, void *); +static int iteide_match(device_t, cfdata_t, void *); +static void iteide_attach(device_t, device_t, void *); -CFATTACH_DECL(iteide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(iteide, sizeof(struct pciide_softc), iteide_match, iteide_attach, NULL, NULL); static const struct pciide_product_desc pciide_ite_products[] = { @@ -70,8 +70,7 @@ static const struct pciide_product_desc pciide_ite_products[] = { }; static int -iteide_match(struct device *parent, struct cfdata *match, - void *aux) +iteide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ITE && @@ -83,10 +82,12 @@ iteide_match(struct device *parent, struct cfdata *match, } static void -iteide_attach(struct device *parent, struct device *self, void *aux) +iteide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_ite_products)); @@ -108,14 +109,14 @@ ite_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) cfg = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_CFG); modectl = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_MODE); ATADEBUG_PRINT(("%s: cfg=0x%x, modectl=0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cfg & IT_CFG_MASK, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cfg & IT_CFG_MASK, modectl & IT_MODE_MASK), DEBUG_PROBE); if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -155,7 +156,7 @@ ite_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) cfg = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_CFG); modectl = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_MODE); ATADEBUG_PRINT(("%s: cfg=0x%x, modectl=0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cfg & IT_CFG_MASK, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cfg & IT_CFG_MASK, modectl & IT_MODE_MASK), DEBUG_PROBE); } @@ -175,7 +176,7 @@ ite_setup_channel(struct ata_channel *chp) modectl = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_MODE); tim = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_TIM(channel)); ATADEBUG_PRINT(("%s:%d: tim=0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, tim), DEBUG_PROBE); /* Setup DMA if needed */ @@ -249,7 +250,7 @@ pio: } ATADEBUG_PRINT(("%s: tim=0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, tim), DEBUG_PROBE); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), tim), DEBUG_PROBE); pci_conf_write(sc->sc_pc, sc->sc_tag, IT_CFG, cfg); pci_conf_write(sc->sc_pc, sc->sc_tag, IT_MODE, modectl); diff --git a/sys/dev/pci/ixpide.c b/sys/dev/pci/ixpide.c index d3419fc6a65..36446402dcc 100644 --- a/sys/dev/pci/ixpide.c +++ b/sys/dev/pci/ixpide.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixpide.c,v 1.10 2007/09/10 10:35:54 cube Exp $ */ +/* $NetBSD: ixpide.c,v 1.11 2008/03/18 20:46:36 cube Exp $ */ /* * Copyright (c) 2004 The NetBSD Foundation. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixpide.c,v 1.10 2007/09/10 10:35:54 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixpide.c,v 1.11 2008/03/18 20:46:36 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -41,13 +41,13 @@ __KERNEL_RCSID(0, "$NetBSD: ixpide.c,v 1.10 2007/09/10 10:35:54 cube Exp $"); #include <dev/pci/pciidevar.h> #include <dev/pci/pciide_ixp_reg.h> -static int ixpide_match(struct device *, struct cfdata *, void *); -static void ixpide_attach(struct device *, struct device *, void *); +static int ixpide_match(device_t, cfdata_t, void *); +static void ixpide_attach(device_t, device_t, void *); static void ixp_chip_map(struct pciide_softc *, struct pci_attach_args *); static void ixp_setup_channel(struct ata_channel *); -CFATTACH_DECL(ixpide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(ixpide, sizeof(struct pciide_softc), ixpide_match, ixpide_attach, NULL, NULL); static const char ixpdesc[] = "ATI Technologies IXP IDE Controller"; @@ -65,8 +65,7 @@ static const struct pciide_product_desc pciide_ixpide_products[] = { }; static int -ixpide_match(struct device *parent, struct cfdata *cfdata, - void *aux) +ixpide_match(device_t parent, cfdata_t cfdata, void *aux) { struct pci_attach_args *pa = (struct pci_attach_args *)aux; @@ -79,10 +78,12 @@ ixpide_match(struct device *parent, struct cfdata *cfdata, } static void -ixpide_attach(struct device *parent, struct device *self, void *aux) +ixpide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_ixpide_products)); @@ -99,8 +100,8 @@ ixp_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); diff --git a/sys/dev/pci/jmide.c b/sys/dev/pci/jmide.c index 27755e00593..5b0e471792e 100644 --- a/sys/dev/pci/jmide.c +++ b/sys/dev/pci/jmide.c @@ -1,4 +1,4 @@ -/* $NetBSD: jmide.c,v 1.3 2008/02/11 08:23:48 xtraeme Exp $ */ +/* $NetBSD: jmide.c,v 1.4 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: jmide.c,v 1.3 2008/02/11 08:23:48 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: jmide.c,v 1.4 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,8 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: jmide.c,v 1.3 2008/02/11 08:23:48 xtraeme Exp $"); static const struct jmide_product *jmide_lookup(pcireg_t); -static int jmide_match(struct device *, struct cfdata *, void *); -static void jmide_attach(struct device *, struct device *, void *); +static int jmide_match(device_t, cfdata_t, void *); +static void jmide_attach(device_t, device_t, void *); static int jmide_intr(void *); static void jmpata_chip_map(struct pciide_softc*, struct pci_attach_args*); @@ -117,9 +117,9 @@ struct jmahci_attach_args { bus_space_handle_t jma_ahcih; }; -#define JM_NAME(sc) (sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev.dv_xname) +#define JM_NAME(sc) (device_xname(sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev)) -CFATTACH_DECL(jmide, sizeof(struct jmide_softc), +CFATTACH_DECL_NEW(jmide, sizeof(struct jmide_softc), jmide_match, jmide_attach, NULL, NULL); static const struct jmide_product * @@ -134,8 +134,7 @@ jmide_lookup(pcireg_t id) { } static int -jmide_match(struct device *parent, struct cfdata *match, - void *aux) +jmide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -147,10 +146,10 @@ jmide_match(struct device *parent, struct cfdata *match, } static void -jmide_attach(struct device *parent, struct device *self, void *aux) +jmide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct jmide_softc *sc = (struct jmide_softc *)self; + struct jmide_softc *sc = device_private(self); const struct jmide_product *jp; char devinfo[256]; const char *intrstr; @@ -162,6 +161,8 @@ jmide_attach(struct device *parent, struct device *self, void *aux) struct pciide_product_desc *pp; int ahci_used = 0; + sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev = self; + jp = jmide_lookup(pa->pa_id); if (jp == NULL) { printf("jmide_attach: WTF?\n"); @@ -224,7 +225,7 @@ jmide_attach(struct device *parent, struct device *self, void *aux) JM_NAME(sc)); } else { sc->sc_ahci = config_found_ia( - &sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev, + sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev, "jmide_hl", &jma, jmahci_print); } /* diff --git a/sys/dev/pci/optiide.c b/sys/dev/pci/optiide.c index 8178ebd731f..809e1119294 100644 --- a/sys/dev/pci/optiide.c +++ b/sys/dev/pci/optiide.c @@ -1,4 +1,4 @@ -/* $NetBSD: optiide.c,v 1.15 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: optiide.c,v 1.16 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: optiide.c,v 1.15 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: optiide.c,v 1.16 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,10 +51,10 @@ __KERNEL_RCSID(0, "$NetBSD: optiide.c,v 1.15 2007/02/09 21:55:27 ad Exp $"); static void opti_chip_map(struct pciide_softc*, struct pci_attach_args*); static void opti_setup_channel(struct ata_channel*); -static int optiide_match(struct device *, struct cfdata *, void *); -static void optiide_attach(struct device *, struct device *, void *); +static int optiide_match(device_t, cfdata_t, void *); +static void optiide_attach(device_t, device_t, void *); -CFATTACH_DECL(optiide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(optiide, sizeof(struct pciide_softc), optiide_match, optiide_attach, NULL, NULL); static const struct pciide_product_desc pciide_opti_products[] = { @@ -81,8 +81,7 @@ static const struct pciide_product_desc pciide_opti_products[] = { }; static int -optiide_match(struct device *parent, struct cfdata *match, - void *aux) +optiide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -96,10 +95,12 @@ optiide_match(struct device *parent, struct cfdata *match, } static void -optiide_attach(struct device *parent, struct device *self, void *aux) +optiide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_opti_products)); @@ -118,8 +119,8 @@ opti_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); /* * XXXSCW: @@ -163,8 +164,8 @@ opti_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) continue; if (channel == 1 && (init_ctrl & OPTI_INIT_CONTROL_CH2_DISABLE) != 0) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c index 207dbd6cc74..7669b4a39fe 100644 --- a/sys/dev/pci/pciide.c +++ b/sys/dev/pci/pciide.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciide.c,v 1.215 2006/11/16 01:33:09 christos Exp $ */ +/* $NetBSD: pciide.c,v 1.216 2008/03/18 20:46:37 cube Exp $ */ /* @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pciide.c,v 1.215 2006/11/16 01:33:09 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciide.c,v 1.216 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> @@ -83,15 +83,14 @@ __KERNEL_RCSID(0, "$NetBSD: pciide.c,v 1.215 2006/11/16 01:33:09 christos Exp $" #include <dev/pci/pciidereg.h> #include <dev/pci/pciidevar.h> -int pciide_match(struct device *, struct cfdata *, void *); -void pciide_attach(struct device *, struct device *, void *); +int pciide_match(device_t, cfdata_t, void *); +void pciide_attach(device_t, device_t, void *); -CFATTACH_DECL(pciide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(pciide, sizeof(struct pciide_softc), pciide_match, pciide_attach, NULL, NULL); int -pciide_match(struct device *parent, struct cfdata *match, - void *aux) +pciide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -109,10 +108,12 @@ pciide_match(struct device *parent, struct cfdata *match, } void -pciide_attach(struct device *parent, struct device *self, void *aux) +pciide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, NULL); } diff --git a/sys/dev/pci/pciide_common.c b/sys/dev/pci/pciide_common.c index 3b05ff9dccf..f9883ac591d 100644 --- a/sys/dev/pci/pciide_common.c +++ b/sys/dev/pci/pciide_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciide_common.c,v 1.37 2007/03/04 06:02:25 christos Exp $ */ +/* $NetBSD: pciide_common.c,v 1.38 2008/03/18 20:46:37 cube Exp $ */ /* @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.37 2007/03/04 06:02:25 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.38 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -152,8 +152,8 @@ pciide_common_attach(sc, pa, pp) /* if displaydev == NULL, printf is done in chip-specific map */ if (displaydev) - aprint_normal("%s: %s (rev. 0x%02x)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, displaydev, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s (rev. 0x%02x)\n", displaydev, PCI_REVISION(pa->pa_class)); sc->sc_pc = pa->pa_pc; @@ -193,8 +193,8 @@ pciide_chipen(sc, pa) if ((pa->pa_flags & PCI_FLAGS_IO_ENABLED) == 0) { csr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG); - aprint_normal("%s: device disabled (at %s)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "device disabled (at %s)\n", (csr & PCI_COMMAND_IO_ENABLE) == 0 ? "device" : "bridge"); return 0; @@ -221,16 +221,16 @@ pciide_mapregs_compat(pa, cp, compatchan, cmdsizep, ctlsizep) wdr->cmd_iot = pa->pa_iot; if (bus_space_map(wdr->cmd_iot, PCIIDE_COMPAT_CMD_BASE(compatchan), PCIIDE_COMPAT_CMD_SIZE, 0, &wdr->cmd_baseioh) != 0) { - aprint_error("%s: couldn't map %s channel cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel cmd regs\n", cp->name); goto bad; } wdr->ctl_iot = pa->pa_iot; if (bus_space_map(wdr->ctl_iot, PCIIDE_COMPAT_CTL_BASE(compatchan), PCIIDE_COMPAT_CTL_SIZE, 0, &wdr->ctl_ioh) != 0) { - aprint_error("%s: couldn't map %s channel ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel ctl regs\n", cp->name); bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, PCIIDE_COMPAT_CMD_SIZE); goto bad; @@ -239,9 +239,9 @@ pciide_mapregs_compat(pa, cp, compatchan, cmdsizep, ctlsizep) for (i = 0; i < WDC_NREG; i++) { if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s channel " - "cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s channel cmd regs\n", + cp->name); goto bad; } } @@ -273,24 +273,23 @@ pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr) if (sc->sc_pci_ih == NULL) { if (pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map native-PCI interrupt\n"); goto bad; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); sc->sc_pci_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO, pci_intr, sc); if (sc->sc_pci_ih != NULL) { - aprint_normal("%s: using %s for native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "using %s for native-PCI interrupt\n", intrstr ? intrstr : "unknown interrupt"); } else { - aprint_error( - "%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) - aprint_normal(" at %s", intrstr); - aprint_normal("\n"); + aprint_error(" at %s", intrstr); + aprint_error("\n"); goto bad; } } @@ -298,16 +297,16 @@ pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr) if (pci_mapreg_map(pa, PCIIDE_REG_CMD_BASE(wdc_cp->ch_channel), PCI_MAPREG_TYPE_IO, 0, &wdr->cmd_iot, &wdr->cmd_baseioh, NULL, cmdsizep) != 0) { - aprint_error("%s: couldn't map %s channel cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel cmd regs\n", cp->name); goto bad; } if (pci_mapreg_map(pa, PCIIDE_REG_CTL_BASE(wdc_cp->ch_channel), PCI_MAPREG_TYPE_IO, 0, &wdr->ctl_iot, &cp->ctl_baseioh, NULL, ctlsizep) != 0) { - aprint_error("%s: couldn't map %s channel ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel ctl regs\n", cp->name); bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, *cmdsizep); goto bad; @@ -319,8 +318,8 @@ pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr) */ if (bus_space_subregion(wdr->ctl_iot, cp->ctl_baseioh, 2, 1, &wdr->ctl_ioh) != 0) { - aprint_error("%s: unable to subregion %s channel ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "unable to subregion %s channel ctl regs\n", cp->name); bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, *cmdsizep); bus_space_unmap(wdr->cmd_iot, cp->ctl_baseioh, *ctlsizep); @@ -330,9 +329,9 @@ pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr) for (i = 0; i < WDC_NREG; i++) { if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s channel " - "cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s channel cmd regs\n", + cp->name); goto bad; } } @@ -410,7 +409,7 @@ pciide_mapreg_dma(sc, pa) sc->sc_wdcdev.dma_finish = pciide_dma_finish; } - if (device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & + if (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & PCIIDE_OPTIONS_NODMA) { aprint_verbose( ", but unused (forced off by config file)"); @@ -556,16 +555,18 @@ pciide_dma_table_setup(sc, channel, drive) if ((error = bus_dmamem_alloc(sc->sc_dmat, dma_table_size, IDEDMA_TBL_ALIGN, IDEDMA_TBL_ALIGN, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) { - aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "allocate", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "allocate", drive, error); return error; } if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, dma_table_size, (void **)&dma_maps->dma_table, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { - aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "map", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "map", drive, error); return error; } ATADEBUG_PRINT(("pciide_dma_table_setup: table at %p len %lu, " @@ -575,16 +576,18 @@ pciide_dma_table_setup(sc, channel, drive) if ((error = bus_dmamap_create(sc->sc_dmat, dma_table_size, 1, dma_table_size, IDEDMA_TBL_ALIGN, BUS_DMA_NOWAIT, &dma_maps->dmamap_table)) != 0) { - aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "create", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "create", drive, error); return error; } if ((error = bus_dmamap_load(sc->sc_dmat, dma_maps->dmamap_table, dma_maps->dma_table, dma_table_size, NULL, BUS_DMA_NOWAIT)) != 0) { - aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "load", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "load", drive, error); return error; } ATADEBUG_PRINT(("pciide_dma_table_setup: phy addr of table 0x%lx\n", @@ -595,8 +598,9 @@ pciide_dma_table_setup(sc, channel, drive) NIDEDMA_TABLES(sc), sc->sc_dma_maxsegsz, sc->sc_dma_boundary, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &dma_maps->dmamap_xfer)) != 0) { - aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "create xfer", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "create xfer", drive, error); return error; } return 0; @@ -619,8 +623,9 @@ pciide_dma_dmamap_setup(sc, channel, drive, databuf, datalen, flags) databuf, datalen, NULL, BUS_DMA_NOWAIT | BUS_DMA_STREAMING | ((flags & WDC_DMA_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)); if (error) { - printf(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel, "load xfer", drive, error); + aprint_error(dmaerrfmt, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + "load xfer", drive, error); return error; } @@ -748,15 +753,16 @@ pciide_dma_finish(v, channel, drive, force) bus_dmamap_unload(sc->sc_dmat, dma_maps->dmamap_xfer); if ((status & IDEDMA_CTL_ERR) != 0 && force != WDC_DMAEND_ABRT_QUIET) { - printf("%s:%d:%d: bus-master DMA error: status=0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel, drive, - status); + aprint_error("%s:%d:%d: bus-master DMA error: status=0x%x\n", + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, + drive, status); error |= WDC_DMAST_ERR; } if ((status & IDEDMA_CTL_INTR) == 0 && force != WDC_DMAEND_ABRT_QUIET) { - printf("%s:%d:%d: bus-master DMA error: missing interrupt, " - "status=0x%x\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error("%s:%d:%d: bus-master DMA error: missing " + "interrupt, status=0x%x\n", + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, drive, status); error |= WDC_DMAST_NOIRQ; } @@ -798,12 +804,12 @@ pciide_chansetup(sc, channel, interface) if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s %s channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cp->name); return 0; } cp->ata_channel.ch_ndrive = 2; - aprint_verbose("%s: %s channel %s to %s mode\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name, + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel %s to %s mode\n", cp->name, (interface & PCIIDE_INTERFACE_SETTABLE(channel)) ? "configured" : "wired", (interface & PCIIDE_INTERFACE_PCI(channel)) ? @@ -846,13 +852,13 @@ pciide_map_compat_intr(pa, cp, compatchan) #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH cp->ih = - pciide_machdep_compat_intr_establish(&sc->sc_wdcdev.sc_atac.atac_dev, + pciide_machdep_compat_intr_establish(sc->sc_wdcdev.sc_atac.atac_dev, pa, compatchan, pciide_compat_intr, cp); if (cp->ih == NULL) { #endif - aprint_error("%s: no compatibility interrupt for use by %s " - "channel\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "no compatibility interrupt for use by %s " + "channel\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH } @@ -881,10 +887,10 @@ default_chip_map(sc, pa) if (interface & PCIIDE_INTERFACE_BUS_MASTER_DMA) { #if NATA_DMA - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); if (sc->sc_pp == &default_product_desc && - (device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & + (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & PCIIDE_OPTIONS_DMA) == 0) { aprint_verbose(", but unused (no driver support)"); sc->sc_dma_ok = 0; @@ -895,12 +901,13 @@ default_chip_map(sc, pa) "support"); } #else - aprint_verbose("%s: bus-master DMA support present, but unused (no driver support)", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present, but unused (no driver " + "support)"); #endif /* NATA_DMA */ } else { - aprint_verbose("%s: hardware does not support DMA", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "hardware does not support DMA"); #if NATA_DMA sc->sc_dma_ok = 0; #endif @@ -971,9 +978,8 @@ default_chip_map(sc, pa) PCI_COMMAND_STATUS_REG, csr); next: if (failreason) { - aprint_error("%s: %s channel ignored (%s)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name, - failreason); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (%s)\n", cp->name, failreason); cp->ata_channel.ch_flags |= ATACH_DISABLED; bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, cmdsize); @@ -1004,7 +1010,8 @@ next: aprint_error( "%s:%d:%d: can't allocate DMA maps, " "using PIO transfers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), channel, drive); sc->sc_dma_ok = 0; sc->sc_wdcdev.sc_atac.atac_cap &= ~ATAC_CAP_DMA; diff --git a/sys/dev/pci/pdcide.c b/sys/dev/pci/pdcide.c index 4899b21a369..c0c379ccb12 100644 --- a/sys/dev/pci/pdcide.c +++ b/sys/dev/pci/pdcide.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdcide.c,v 1.25 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: pdcide.c,v 1.26 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pdcide.c,v 1.25 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pdcide.c,v 1.26 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,10 +49,10 @@ static int pdc20265_pci_intr(void *); static void pdc20262_dma_start(void *, int, int); static int pdc20262_dma_finish(void *, int, int, int); -static int pdcide_match(struct device *, struct cfdata *, void *); -static void pdcide_attach(struct device *, struct device *, void *); +static int pdcide_match(device_t, cfdata_t, void *); +static void pdcide_attach(device_t, device_t, void *); -CFATTACH_DECL(pdcide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(pdcide, sizeof(struct pciide_softc), pdcide_match, pdcide_attach, NULL, NULL); static const struct pciide_product_desc pciide_promise_products[] = { @@ -119,8 +119,7 @@ static const struct pciide_product_desc pciide_promise_products[] = { }; static int -pdcide_match(struct device *parent, struct cfdata *match, - void *aux) +pdcide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -132,10 +131,12 @@ pdcide_match(struct device *parent, struct cfdata *match, } static void -pdcide_attach(struct device *parent, struct device *self, void *aux) +pdcide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_promise_products)); @@ -211,8 +212,8 @@ pdc202xx_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (st & PDC2xx_STATE_NATIVE) interface |= PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1); - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -312,8 +313,8 @@ pdc202xx_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) continue; if ((st & (PDC_IS_262(sc) ? PDC262_STATE_EN(channel):PDC246_STATE_EN(channel))) == 0) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } @@ -342,7 +343,7 @@ pdc202xx_setup_channel(struct ata_channel *chp) idedma_ctl = 0; ATADEBUG_PRINT(("pdc202xx_setup_channel %s: scr 0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC262_U66)), DEBUG_PROBE); @@ -373,7 +374,7 @@ pdc202xx_setup_channel(struct ata_channel *chp) bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC262_U66, scr); ATADEBUG_PRINT(("pdc202xx_setup_channel %s:%d: ATAPI 0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel, bus_space_read_4(sc->sc_dma_iot, sc->sc_dma_ioh, PDC262_ATAPI(channel))), DEBUG_PROBE); if (chp->ch_drive[0].drive_flags & DRIVE_ATAPI || @@ -431,7 +432,7 @@ pdc202xx_setup_channel(struct ata_channel *chp) } ATADEBUG_PRINT(("pdc202xx_setup_channel: %s:%d:%d " "timings 0x%x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), chp->ch_channel, drive, mode), DEBUG_PROBE); pci_conf_write(sc->sc_pc, sc->sc_tag, PDC2xx_TIM(chp->ch_channel, drive), mode); @@ -514,9 +515,9 @@ pdc202xx_pci_intr(void *arg) if (scr & PDC2xx_SCR_INT(i)) { crv = wdcintr(wdc_cp); if (crv == 0) - printf("%s:%d: bogus intr (reg 0x%x)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - i, scr); + aprint_error("%s:%d: bogus intr (reg 0x%x)\n", + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), i, scr); else rv = 1; } @@ -557,8 +558,8 @@ pdc20265_pci_intr(void *arg) continue; crv = wdcintr(wdc_cp); if (crv == 0) - printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + aprint_error("%s:%d: bogus intr\n", + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), i); else rv = 1; } diff --git a/sys/dev/pci/pdcsata.c b/sys/dev/pci/pdcsata.c index aee4f43fb08..4a9980c5a25 100644 --- a/sys/dev/pci/pdcsata.c +++ b/sys/dev/pci/pdcsata.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdcsata.c,v 1.15 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: pdcsata.c,v 1.16 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 2004, Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pdcsata.c,v 1.15 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pdcsata.c,v 1.16 2008/03/18 20:46:37 cube Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -71,10 +71,10 @@ static void pdc203xx_combo_probe(struct ata_channel *); static int pdcsata_pci_intr(void *); static void pdcsata_do_reset(struct ata_channel *, int); -static int pdcsata_match(struct device *, struct cfdata *, void *); -static void pdcsata_attach(struct device *, struct device *, void *); +static int pdcsata_match(device_t, cfdata_t, void *); +static void pdcsata_attach(device_t, device_t, void *); -CFATTACH_DECL(pdcsata, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(pdcsata, sizeof(struct pciide_softc), pdcsata_match, pdcsata_attach, NULL, NULL); static const struct pciide_product_desc pciide_pdcsata_products[] = { @@ -201,8 +201,7 @@ static const struct pciide_product_desc pciide_pdcsata_products[] = { }; static int -pdcsata_match(struct device *parent, struct cfdata *match, - void *aux) +pdcsata_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -214,10 +213,12 @@ pdcsata_match(struct device *parent, struct cfdata *match, } static void -pdcsata_attach(struct device *parent, struct device *self, void *aux) +pdcsata_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_pdcsata_products)); @@ -239,8 +240,8 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) * the usual IDE registers are mapped in I/O space, with offsets. */ if (pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map interrupt\n"); return; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); @@ -248,23 +249,23 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) intrhandle, IPL_BIO, pdcsata_pci_intr, sc); if (sc->sc_pci_ih == NULL) { - aprint_error("%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) aprint_normal(" at %s", intrstr); aprint_normal("\n"); return; } - aprint_normal("%s: interrupting at %s\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - intrstr ? intrstr : "unknown interrupt"); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "interrupting at %s\n", + intrstr ? intrstr : "unknown interrupt"); sc->sc_dma_ok = (pci_mapreg_map(pa, PCIIDE_REG_BUS_MASTER_DMA, PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_dma_iot, &sc->sc_dma_ioh, NULL, &dmasize) == 0); if (!sc->sc_dma_ok) { - aprint_error("%s: couldn't map bus-master DMA registers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map bus-master DMA registers\n"); pci_intr_disestablish(pa->pa_pc, sc->sc_pci_ih); return; } @@ -274,15 +275,15 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pci_mapreg_map(pa, PDC203xx_BAR_IDEREGS, PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, NULL) != 0) { - aprint_error("%s: couldn't map IDE registers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map IDE registers\n"); bus_space_unmap(sc->sc_dma_iot, sc->sc_dma_ioh, dmasize); pci_intr_disestablish(pa->pa_pc, sc->sc_pci_ih); return; } - aprint_verbose("%s: bus-master DMA support present\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16; if (sc->sc_dma_ok) { sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DMA | ATAC_CAP_UDMA; @@ -381,7 +382,8 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s channel %d: " "can't allocate memory for command queue\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), + channel); goto next_channel; } wdc_cp = &cp->ata_channel; @@ -392,18 +394,16 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, 0x0238 + (channel << 7), 1, &wdr->ctl_ioh) != 0) { - aprint_error("%s: couldn't map channel %d ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d ctl regs\n", channel); goto next_channel; } for (i = 0; i < WDC_NREG; i++) { if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, 0x0200 + (i << 2) + (channel << 7), i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't map channel %d cmd " - "regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d cmd regs\n", channel); goto next_channel; } @@ -421,7 +421,8 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) &cp->dma_iohs[IDEDMA_CMD]) != 0) { aprint_normal("%s channel %d: can't subregion DMA " "registers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), + channel); goto next_channel; } if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, @@ -429,7 +430,8 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) &cp->dma_iohs[IDEDMA_TBL]) != 0) { aprint_normal("%s channel %d: can't subregion DMA " "registers\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), + channel); goto next_channel; } @@ -442,27 +444,27 @@ pdcsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, PDC205_SSTATUS(channel), 1, &wdr->sata_status) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_status regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel); + aprint_error_dev( + sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d " + "sata_status regs\n", channel); goto next_channel; } if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, PDC205_SERROR(channel), 1, &wdr->sata_error) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_error regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel); + aprint_error_dev( + sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d " + "sata_error regs\n", channel); goto next_channel; } if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, PDC205_SCONTROL(channel), 1, &wdr->sata_control) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_control regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - channel); + aprint_error_dev( + sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d " + "sata_control regs\n", channel); goto next_channel; } } @@ -543,9 +545,9 @@ pdcsata_pci_intr(void *arg) } crv = wdcintr(wdc_cp); if (crv == 0) { - printf("%s:%d: bogus intr (reg 0x%x)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - i, scr); + aprint_error("%s:%d: bogus intr (reg 0x%x)\n", + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), i, scr); } else rv = 1; } @@ -637,5 +639,4 @@ pdcsata_do_reset(struct ata_channel *chp, int poll) status = bus_space_read_4(sc->sc_ba5_st, sc->sc_ba5_sh, chanbase); wdc_do_reset(chp, poll); - } diff --git a/sys/dev/pci/piixide.c b/sys/dev/pci/piixide.c index 1278e534a93..2e9d608e3d9 100644 --- a/sys/dev/pci/piixide.c +++ b/sys/dev/pci/piixide.c @@ -1,4 +1,4 @@ -/* $NetBSD: piixide.c,v 1.45 2008/02/29 06:13:39 dyoung Exp $ */ +/* $NetBSD: piixide.c,v 1.46 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: piixide.c,v 1.45 2008/02/29 06:13:39 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: piixide.c,v 1.46 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -52,8 +52,8 @@ static int piix_dma_init(void *, int, int, void *, size_t, int); static bool piixide_resume(device_t PMF_FN_PROTO); static bool piixide_suspend(device_t PMF_FN_PROTO); -static int piixide_match(struct device *, struct cfdata *, void *); -static void piixide_attach(struct device *, struct device *, void *); +static int piixide_match(device_t, cfdata_t, void *); +static void piixide_attach(device_t, device_t, void *); static const struct pciide_product_desc pciide_intel_products[] = { { PCI_PRODUCT_INTEL_82092AA, @@ -253,12 +253,11 @@ static const struct pciide_product_desc pciide_intel_products[] = { } }; -CFATTACH_DECL(piixide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(piixide, sizeof(struct pciide_softc), piixide_match, piixide_attach, NULL, NULL); static int -piixide_match(struct device *parent, struct cfdata *match, - void *aux) +piixide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -270,10 +269,12 @@ piixide_match(struct device *parent, struct cfdata *match, } static void -piixide_attach(struct device *parent, struct device *self, void *aux) +piixide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_intel_products)); @@ -320,8 +321,8 @@ piix_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -422,8 +423,8 @@ piix_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if ((PIIX_IDETIM_READ(idetim, channel) & PIIX_IDETIM_IDE) == 0) { #if 1 - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; #else @@ -824,8 +825,8 @@ piixsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); diff --git a/sys/dev/pci/rccide.c b/sys/dev/pci/rccide.c index d59024ee9aa..4b0901d5bcc 100644 --- a/sys/dev/pci/rccide.c +++ b/sys/dev/pci/rccide.c @@ -1,4 +1,4 @@ -/* $NetBSD: rccide.c,v 1.17 2007/10/24 23:08:07 xtraeme Exp $ */ +/* $NetBSD: rccide.c,v 1.18 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 2003 By Noon Software, Inc. All rights reserved. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rccide.c,v 1.17 2007/10/24 23:08:07 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rccide.c,v 1.18 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -43,10 +43,10 @@ static void serverworks_setup_channel(struct ata_channel *); static int serverworks_pci_intr(void *); static int serverworkscsb6_pci_intr(void *); -static int rccide_match(struct device *, struct cfdata *, void *); -static void rccide_attach(struct device *, struct device *, void *); +static int rccide_match(device_t, cfdata_t, void *); +static void rccide_attach(device_t, device_t, void *); -CFATTACH_DECL(rccide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(rccide, sizeof(struct pciide_softc), rccide_match, rccide_attach, NULL, NULL); static const struct pciide_product_desc pciide_serverworks_products[] = { @@ -83,8 +83,7 @@ static const struct pciide_product_desc pciide_serverworks_products[] = { }; static int -rccide_match(struct device *parent, struct cfdata *match, - void *aux) +rccide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -99,10 +98,12 @@ rccide_match(struct device *parent, struct cfdata *match, } static void -rccide_attach(struct device *parent, struct device *self, void *aux) +rccide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (void *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_serverworks_products)); @@ -120,8 +121,8 @@ serverworks_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -278,8 +279,8 @@ serverworks_pci_intr(arg) wdc_cp = &cp->ata_channel; crv = wdcintr(wdc_cp); if (crv == 0) { - printf("%s:%d: bogus intr\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, i); + aprint_error("%s:%d: bogus intr\n", + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), i); bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0, dmastat); } else diff --git a/sys/dev/pci/satalink.c b/sys/dev/pci/satalink.c index dca52ba87ca..898b8e61fe0 100644 --- a/sys/dev/pci/satalink.c +++ b/sys/dev/pci/satalink.c @@ -1,4 +1,4 @@ -/* $NetBSD: satalink.c,v 1.35 2007/12/27 15:14:23 ws Exp $ */ +/* $NetBSD: satalink.c,v 1.36 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: satalink.c,v 1.35 2007/12/27 15:14:23 ws Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satalink.c,v 1.36 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -263,10 +263,10 @@ static const struct { /* Interrupt steering bit in BA5[0x200]. */ #define IDEDMA_CMD_INT_STEER (1U << 1) -static int satalink_match(struct device *, struct cfdata *, void *); -static void satalink_attach(struct device *, struct device *, void *); +static int satalink_match(device_t, cfdata_t, void *); +static void satalink_attach(device_t, device_t, void *); -CFATTACH_DECL(satalink, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(satalink, sizeof(struct pciide_softc), satalink_match, satalink_attach, NULL, NULL); static void sii3112_chip_map(struct pciide_softc*, struct pci_attach_args*); @@ -303,8 +303,7 @@ static const struct pciide_product_desc pciide_satalink_products[] = { }; static int -satalink_match(struct device *parent, struct cfdata *match, - void *aux) +satalink_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -316,10 +315,12 @@ satalink_match(struct device *parent, struct cfdata *match, } static void -satalink_attach(struct device *parent, struct device *self, void *aux) +satalink_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_satalink_products)); @@ -443,20 +444,20 @@ sii3112_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) delay(50 * 1000); if (scs_cmd & SCS_CMD_BA5_EN) { - aprint_verbose("%s: SATALink BA5 register space enabled\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "SATALink BA5 register space enabled\n"); if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x14, PCI_MAPREG_TYPE_MEM| PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, NULL) != 0) - aprint_error("%s: unable to map SATALink BA5 " - "register space\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "unable to map SATALink BA5 register space\n"); else sc->sc_ba5_en = 1; } else { - aprint_verbose("%s: SATALink BA5 register space disabled\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "SATALink BA5 register space disabled\n"); cfgctl = pci_conf_read(pa->pa_pc, pa->pa_tag, SII3112_PCI_CFGCTL); @@ -464,8 +465,8 @@ sii3112_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) cfgctl | CFGCTL_BA5INDEN); } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -534,7 +535,7 @@ sii3114_mapreg_dma(struct pciide_softc *sc, struct pci_attach_args *pa) sc->sc_wdcdev.dma_start = pciide_dma_start; sc->sc_wdcdev.dma_finish = pciide_dma_finish; - if (device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & + if (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & PCIIDE_OPTIONS_NODMA) { aprint_verbose( ", but unused (forced off by config file)"); @@ -603,7 +604,7 @@ sii3114_chansetup(struct pciide_softc *sc, int channel) if (cp->ata_channel.ch_queue == NULL) { aprint_error("%s %s channel: " "can't allocate memory for command queue", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + device_xname(sc->sc_wdcdev.sc_atac.atac_dev), cp->name); return (0); } return (1); @@ -624,8 +625,8 @@ sii3114_mapchan(struct pciide_channel *cp) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, satalink_ba5_regmap[wdc_cp->ch_channel].ba5_IDE_TF0, 9, &wdr->cmd_baseioh) != 0) { - aprint_error("%s: couldn't subregion %s cmd base\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s cmd base\n", cp->name); goto bad; } @@ -633,8 +634,8 @@ sii3114_mapchan(struct pciide_channel *cp) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, satalink_ba5_regmap[wdc_cp->ch_channel].ba5_IDE_TF8, 1, &cp->ctl_baseioh) != 0) { - aprint_error("%s: couldn't subregion %s ctl base\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s ctl base\n", cp->name); goto bad; } wdr->ctl_ioh = cp->ctl_baseioh; @@ -643,9 +644,9 @@ sii3114_mapchan(struct pciide_channel *cp) if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s channel " - "cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s channel cmd regs\n", + cp->name); goto bad; } } @@ -704,14 +705,14 @@ sii3114_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, NULL) != 0) { - aprint_error("%s: unable to map SATALink BA5 " - "register space\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "unable to map SATALink BA5 register space\n"); return; } sc->sc_ba5_en = 1; - aprint_verbose("%s: %dMHz PCI bus\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - (scs_cmd & SCS_CMD_M66EN) ? 66 : 33); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%dMHz PCI bus\n", (scs_cmd & SCS_CMD_M66EN) ? 66 : 33); /* * Set the Interrupt Steering bit in the IDEDMA_CMD register of @@ -721,8 +722,8 @@ sii3114_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) */ BA5_WRITE_4(sc, 2, ba5_IDEDMA_CMD, IDEDMA_CMD_INT_STEER); - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); sii3114_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -748,8 +749,8 @@ sii3114_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) /* Map and establish the interrupt handler. */ if (pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map native-PCI interrupt\n"); return; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); @@ -757,12 +758,12 @@ sii3114_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) /* XXX */ pciide_pci_intr, sc); if (sc->sc_pci_ih != NULL) { - aprint_normal("%s: using %s for native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - intrstr ? intrstr : "unknown interrupt"); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "using %s for native-PCI interrupt\n", + intrstr ? intrstr : "unknown interrupt"); } else { - aprint_error("%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) aprint_normal(" at %s", intrstr); aprint_normal("\n"); @@ -833,14 +834,14 @@ sii3112_drv_probe(struct ata_channel *chp) break; case SStatus_DET_DEV_NE: - aprint_error("%s: port %d: device connected, but " - "communication not established\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, chp->ch_channel); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "port %d: device connected, but " + "communication not established\n", chp->ch_channel); break; case SStatus_DET_OFFLINE: - aprint_error("%s: port %d: PHY offline\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, chp->ch_channel); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "port %d: PHY offline\n", chp->ch_channel); break; case SStatus_DET_DEV: @@ -878,14 +879,16 @@ sii3112_drv_probe(struct ata_channel *chp) chp->ch_drive[0].drive_flags |= DRIVE_ATA; splx(s); - aprint_normal("%s: port %d: device present, speed: %s\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, chp->ch_channel, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "port %d: device present, speed: %s\n", + chp->ch_channel, sata_speed(sstatus)); break; default: - aprint_error("%s: port %d: unknown SStatus: 0x%08x\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, chp->ch_channel, sstatus); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "port %d: unknown SStatus: 0x%08x\n", + chp->ch_channel, sstatus); } } diff --git a/sys/dev/pci/siside.c b/sys/dev/pci/siside.c index 6bce4a3c057..cbe39b23334 100644 --- a/sys/dev/pci/siside.c +++ b/sys/dev/pci/siside.c @@ -1,4 +1,4 @@ -/* $NetBSD: siside.c,v 1.22 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: siside.c,v 1.23 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: siside.c,v 1.22 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: siside.c,v 1.23 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,10 +49,10 @@ static void sis96x_setup_channel(struct ata_channel *); static int sis_hostbr_match(struct pci_attach_args *); static int sis_south_match(struct pci_attach_args *); -static int siside_match(struct device *, struct cfdata *, void *); -static void siside_attach(struct device *, struct device *, void *); +static int siside_match(device_t, cfdata_t, void *); +static void siside_attach(device_t, device_t, void *); -CFATTACH_DECL(siside, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(siside, sizeof(struct pciide_softc), siside_match, siside_attach, NULL, NULL); static const struct pciide_product_desc pciide_sis_products[] = { @@ -84,8 +84,7 @@ static const struct pciide_product_desc pciide_sis_products[] = { }; static int -siside_match(struct device *parent, struct cfdata *match, - void *aux) +siside_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -97,14 +96,15 @@ siside_match(struct device *parent, struct cfdata *match, } static void -siside_attach(struct device *parent, struct device *self, void *aux) +siside_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_sis_products)); - } static struct sis_hostbr_type { @@ -227,8 +227,8 @@ sis_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_normal("%s: Silicon Integrated Systems ", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "Silicon Integrated Systems "); pci_find_device(NULL, sis_hostbr_match); if (sis_hostbr_type_match) { if (sis_hostbr_type_match->type == SIS_TYPE_SOUTH) { @@ -271,8 +271,8 @@ sis_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) } aprint_normal(" IDE controller (rev. 0x%02x)\n", PCI_REVISION(pa->pa_class)); - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -322,8 +322,8 @@ sis_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) continue; if ((channel == 0 && (sis_ctr0 & SIS_CTRL0_CHAN0_EN) == 0) || (channel == 1 && (sis_ctr0 & SIS_CTRL0_CHAN1_EN) == 0)) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } @@ -521,12 +521,12 @@ sis_sata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1); } - aprint_normal("%s: Silicon Integrated Systems 180/96X SATA controller (rev. 0x%02x)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - PCI_REVISION(pa->pa_class)); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "Silicon Integrated Systems 180/96X SATA controller " + "(rev. 0x%02x)\n", PCI_REVISION(pa->pa_class)); - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); diff --git a/sys/dev/pci/slide.c b/sys/dev/pci/slide.c index 0fe57cd21d6..d0f86bed97a 100644 --- a/sys/dev/pci/slide.c +++ b/sys/dev/pci/slide.c @@ -1,4 +1,4 @@ -/* $NetBSD: slide.c,v 1.18 2007/04/26 19:47:04 garbled Exp $ */ +/* $NetBSD: slide.c,v 1.19 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: slide.c,v 1.18 2007/04/26 19:47:04 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: slide.c,v 1.19 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,10 +51,10 @@ __KERNEL_RCSID(0, "$NetBSD: slide.c,v 1.18 2007/04/26 19:47:04 garbled Exp $"); static void sl82c105_chip_map(struct pciide_softc*, struct pci_attach_args*); static void sl82c105_setup_channel(struct ata_channel*); -static int slide_match(struct device *, struct cfdata *, void *); -static void slide_attach(struct device *, struct device *, void *); +static int slide_match(device_t, cfdata_t, void *); +static void slide_attach(device_t, device_t, void *); -CFATTACH_DECL(slide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(slide, sizeof(struct pciide_softc), slide_match, slide_attach, NULL, NULL); static const struct pciide_product_desc pciide_symphony_products[] = { @@ -84,8 +84,7 @@ static const struct pciide_product_desc pciide_winbond_products[] = { }; static int -slide_match(struct device *parent, struct cfdata *match, - void *aux) +slide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -101,12 +100,14 @@ slide_match(struct device *parent, struct cfdata *match, } static void -slide_attach(struct device *parent, struct device *self, void *aux) +slide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); const struct pciide_product_desc *pp = NULL; + sc->sc_wdcdev.sc_atac.atac_dev = self; + if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SYMPHONY) pp = pciide_lookup_product(pa->pa_id, pciide_symphony_products); if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_WINBOND) @@ -141,8 +142,8 @@ sl82c105_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); /* * Check to see if we're part of the Winbond 83c553 Southbridge. @@ -180,8 +181,8 @@ sl82c105_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) continue; if ((channel == 0 && (idecr & IDECR_P0EN) == 0) || (channel == 1 && (idecr & IDECR_P1EN) == 0)) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } diff --git a/sys/dev/pci/stpcide.c b/sys/dev/pci/stpcide.c index c9eba3bc700..f57f234db20 100644 --- a/sys/dev/pci/stpcide.c +++ b/sys/dev/pci/stpcide.c @@ -1,4 +1,4 @@ -/* $NetBSD: stpcide.c,v 1.17 2007/02/09 21:55:27 ad Exp $ */ +/* $NetBSD: stpcide.c,v 1.18 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 2003 Tohru Nishimura @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: stpcide.c,v 1.17 2007/02/09 21:55:27 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: stpcide.c,v 1.18 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -43,8 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: stpcide.c,v 1.17 2007/02/09 21:55:27 ad Exp $"); static void stpc_chip_map(struct pciide_softc *, struct pci_attach_args *); static void stpc_setup_channel(struct ata_channel *); -static int stpcide_match(struct device *, struct cfdata *, void *); -static void stpcide_attach(struct device *, struct device *, void *); +static int stpcide_match(device_t, cfdata_t, void *); +static void stpcide_attach(device_t, device_t, void *); const struct pciide_product_desc pciide_stpc_products[] = { { 0x0228, @@ -55,12 +55,11 @@ const struct pciide_product_desc pciide_stpc_products[] = { { 0, 0, NULL, NULL }, }; -CFATTACH_DECL(stpcide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(stpcide, sizeof(struct pciide_softc), stpcide_match, stpcide_attach, NULL, NULL); static int -stpcide_match(struct device *parent, struct cfdata *match, - void *aux) +stpcide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -72,10 +71,12 @@ stpcide_match(struct device *parent, struct cfdata *match, } static void -stpcide_attach(struct device *parent, struct device *self, void *aux) +stpcide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_stpc_products)); @@ -93,8 +94,8 @@ stpc_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16 | ATAC_CAP_DATA32; diff --git a/sys/dev/pci/svwsata.c b/sys/dev/pci/svwsata.c index 49b6d1d0e30..711d9813bdf 100644 --- a/sys/dev/pci/svwsata.c +++ b/sys/dev/pci/svwsata.c @@ -1,4 +1,4 @@ -/* $NetBSD: svwsata.c,v 1.9 2008/02/05 07:02:00 simonb Exp $ */ +/* $NetBSD: svwsata.c,v 1.10 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: svwsata.c,v 1.9 2008/02/05 07:02:00 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: svwsata.c,v 1.10 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -31,14 +31,14 @@ __KERNEL_RCSID(0, "$NetBSD: svwsata.c,v 1.9 2008/02/05 07:02:00 simonb Exp $"); #include <dev/pci/pciidevar.h> #include <dev/pci/pciide_svwsata_reg.h> -static int svwsata_match(struct device *, struct cfdata *, void *); -static void svwsata_attach(struct device *, struct device *, void *); +static int svwsata_match(device_t, cfdata_t, void *); +static void svwsata_attach(device_t, device_t, void *); static void svwsata_chip_map(struct pciide_softc *, struct pci_attach_args *); static void svwsata_mapreg_dma(struct pciide_softc *, struct pci_attach_args *); static void svwsata_mapchan(struct pciide_channel *); -CFATTACH_DECL(svwsata, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(svwsata, sizeof(struct pciide_softc), svwsata_match, svwsata_attach, NULL, NULL); static const struct pciide_product_desc pciide_svwsata_products[] = { @@ -75,8 +75,7 @@ static const struct pciide_product_desc pciide_svwsata_products[] = { }; static int -svwsata_match(struct device *parent, struct cfdata *match, - void *aux) +svwsata_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -89,10 +88,12 @@ svwsata_match(struct device *parent, struct cfdata *match, } static void -svwsata_attach(struct device *parent, struct device *self, void *aux) +svwsata_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (void *)self; + struct pciide_softc *sc = device_private(self); + + sc->sc_wdcdev.sc_atac.atac_dev = self; pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_svwsata_products)); @@ -126,8 +127,8 @@ svwsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) return; } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); svwsata_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -153,20 +154,20 @@ svwsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) /* Map and establish the interrupt handler. */ if(pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map native-PCI interrupt\n"); return; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); sc->sc_pci_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO, pciide_pci_intr, sc); if (sc->sc_pci_ih != NULL) { - aprint_normal("%s: using %s for native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "using %s for native-PCI interrupt\n", intrstr ? intrstr : "unknown interrupt"); } else { - aprint_error("%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) aprint_normal(" at %s", intrstr); aprint_normal("\n"); @@ -199,7 +200,7 @@ svwsata_mapreg_dma(struct pciide_softc *sc, struct pci_attach_args *pa) sc->sc_wdcdev.dma_start = pciide_dma_start; sc->sc_wdcdev.dma_finish = pciide_dma_finish; - if (device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & + if (device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags & PCIIDE_OPTIONS_NODMA) { aprint_normal( ", but unused (forced off by config file)"); @@ -253,8 +254,8 @@ svwsata_mapchan(struct pciide_channel *cp) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, (wdc_cp->ch_channel << 8) + SVWSATA_TF0, SVWSATA_TF8 - SVWSATA_TF0, &wdr->cmd_baseioh) != 0) { - aprint_error("%s: couldn't map %s cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s cmd regs\n", cp->name); goto bad; } @@ -262,8 +263,8 @@ svwsata_mapchan(struct pciide_channel *cp) if (bus_space_subregion(sc->sc_ba5_st, sc->sc_ba5_sh, (wdc_cp->ch_channel << 8) + SVWSATA_TF8, 4, &cp->ctl_baseioh) != 0) { - aprint_error("%s: couldn't map %s ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s ctl regs\n", cp->name); goto bad; } wdr->ctl_ioh = cp->ctl_baseioh; @@ -272,9 +273,9 @@ svwsata_mapchan(struct pciide_channel *cp) if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i << 2, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s channel " - "cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s channel cmd regs\n", + cp->name); goto bad; } } @@ -288,27 +289,24 @@ svwsata_mapchan(struct pciide_channel *cp) if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 8) + SVWSATA_SSTATUS, 1, &wdr->sata_status) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_status regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_status regs\n", wdc_cp->ch_channel); goto bad; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 8) + SVWSATA_SERROR, 1, &wdr->sata_error) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_error regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_error regs\n", wdc_cp->ch_channel); goto bad; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 8) + SVWSATA_SCONTROL, 1, &wdr->sata_control) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_control regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_control regs\n", wdc_cp->ch_channel); goto bad; } diff --git a/sys/dev/pci/viaide.c b/sys/dev/pci/viaide.c index 26d10988d2f..42e9eb283c8 100644 --- a/sys/dev/pci/viaide.c +++ b/sys/dev/pci/viaide.c @@ -1,4 +1,4 @@ -/* $NetBSD: viaide.c,v 1.52 2008/02/29 06:13:39 dyoung Exp $ */ +/* $NetBSD: viaide.c,v 1.53 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.52 2008/02/29 06:13:39 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.53 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -63,14 +63,14 @@ static void via_sata_chip_map_new(struct pciide_softc *, struct pci_attach_args *); static void via_setup_channel(struct ata_channel *); -static int viaide_match(struct device *, struct cfdata *, void *); -static void viaide_attach(struct device *, struct device *, void *); +static int viaide_match(device_t, cfdata_t, void *); +static void viaide_attach(device_t, device_t, void *); static const struct pciide_product_desc * viaide_lookup(pcireg_t); static bool viaide_suspend(device_t PMF_FN_PROTO); static bool viaide_resume(device_t PMF_FN_PROTO); -CFATTACH_DECL(viaide, sizeof(struct pciide_softc), +CFATTACH_DECL_NEW(viaide, sizeof(struct pciide_softc), viaide_match, viaide_attach, NULL, NULL); static const struct pciide_product_desc pciide_amd_products[] = { @@ -355,8 +355,7 @@ viaide_lookup(pcireg_t id) } static int -viaide_match(struct device *parent, struct cfdata *match, - void *aux) +viaide_match(device_t parent, cfdata_t match, void *aux) { struct pci_attach_args *pa = aux; @@ -366,12 +365,14 @@ viaide_match(struct device *parent, struct cfdata *match, } static void -viaide_attach(struct device *parent, struct device *self, void *aux) +viaide_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa = aux; - struct pciide_softc *sc = (struct pciide_softc *)self; + struct pciide_softc *sc = device_private(self); const struct pciide_product_desc *pp; + sc->sc_wdcdev.sc_atac.atac_dev = self; + pp = viaide_lookup(pa->pa_id); if (pp == NULL) panic("viaide_attach"); @@ -448,8 +449,8 @@ via_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) goto unknown; pcib_id = pcib_pa.pa_id; pcib_class = pcib_pa.pa_class; - aprint_normal("%s: VIA Technologies ", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "VIA Technologies "); switch (PCI_PRODUCT(pcib_id)) { case PCI_PRODUCT_VIATECH_VT82C586_ISA: aprint_normal("VT82C586 (Apollo VP) "); @@ -558,8 +559,8 @@ unknown: panic("via_chip_map: unknown vendor"); } - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32; @@ -597,8 +598,8 @@ unknown: continue; if ((ideconf & APO_IDECONF_EN(channel)) == 0) { - aprint_normal("%s: %s channel ignored (disabled)\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "%s channel ignored (disabled)\n", cp->name); cp->ata_channel.ch_flags |= ATACH_DISABLED; continue; } @@ -619,7 +620,8 @@ via_mapchan(struct pci_attach_args *pa, struct pciide_channel *cp, wdc_cp = &cp->ata_channel; sc = CHAN_TO_PCIIDE(&cp->ata_channel); compat_nat_enable = prop_dictionary_get( - device_properties((struct device *)sc), "use-compat-native-irq"); + device_properties(sc->sc_wdcdev.sc_atac.atac_dev), + "use-compat-native-irq"); if (interface & PCIIDE_INTERFACE_PCI(wdc_cp->ch_channel)) { /* native mode with irq 14/15 requested? */ @@ -664,13 +666,13 @@ vt8231_mapregs_native(struct pci_attach_args *pa, struct pciide_channel *cp, if ((wdc_cp->ch_flags & ATACH_DISABLED) == 0) { #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH cp->ih = pciide_machdep_compat_intr_establish( - &sc->sc_wdcdev.sc_atac.atac_dev, pa, wdc_cp->ch_channel, + sc->sc_wdcdev.sc_atac.atac_dev, pa, wdc_cp->ch_channel, pci_intr, sc); if (cp->ih == NULL) { #endif - aprint_error("%s: no compatibility interrupt for " - "use by %s channel\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "no compatibility interrupt for " + "use by %s channel\n", cp->name); wdc_cp->ch_flags |= ATACH_DISABLED; #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH } @@ -779,7 +781,8 @@ via_setup_channel(struct ata_channel *chp) aprint_normal( "%s:%d:%d: multi-word DMA disabled due " "to chip revision\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + device_xname( + sc->sc_wdcdev.sc_atac.atac_dev), chp->ch_channel, drive); mode = drvp->PIO_mode; s = splbio(); @@ -832,8 +835,8 @@ via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa) if (pciide_chipen(sc, pa) == 0) return 0; - aprint_verbose("%s: bus-master DMA support present", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "bus-master DMA support present"); pciide_mapreg_dma(sc, pa); aprint_verbose("\n"); @@ -870,14 +873,14 @@ via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa) NULL, &satasize); break; default: - aprint_error("%s: couldn't map sata regs, unsupported" - "maptype (0x%x)\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map sata regs, unsupportedmaptype (0x%x)\n", maptype); return 0; } if (ret != 0) { - aprint_error("%s: couldn't map sata regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map sata regs\n"); return 0; } return 1; @@ -916,27 +919,24 @@ via_sata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa, if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << satareg_shift) + 0x0, 1, &wdr->sata_status) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_status regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_status regs\n", wdc_cp->ch_channel); continue; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << satareg_shift) + 0x4, 1, &wdr->sata_error) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_error regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_error regs\n", wdc_cp->ch_channel); continue; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << satareg_shift) + 0x8, 1, &wdr->sata_control) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_control regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_control regs\n", wdc_cp->ch_channel); continue; } @@ -988,24 +988,23 @@ via_sata_chip_map_new(struct pciide_softc *sc, struct pci_attach_args *pa) } if (pci_intr_map(pa, &intrhandle) != 0) { - aprint_error("%s: couldn't map native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map native-PCI interrupt\n"); return; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); sc->sc_pci_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO, pciide_pci_intr, sc); if (sc->sc_pci_ih == NULL) { - aprint_error( - "%s: couldn't establish native-PCI interrupt", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't establish native-PCI interrupt"); if (intrstr != NULL) aprint_error(" at %s", intrstr); aprint_error("\n"); return; } - aprint_normal("%s: using %s for native-PCI interrupt\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "using %s for native-PCI interrupt\n", intrstr ? intrstr : "unknown interrupt"); for (channel = 0; channel < sc->sc_wdcdev.sc_atac.atac_nchannels; @@ -1022,27 +1021,24 @@ via_sata_chip_map_new(struct pciide_softc *sc, struct pci_attach_args *pa) if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 6) + 0x0, 1, &wdr->sata_status) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_status regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_status regs\n", wdc_cp->ch_channel); continue; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 6) + 0x4, 1, &wdr->sata_error) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_error regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_error regs\n", wdc_cp->ch_channel); continue; } if (bus_space_subregion(wdr->sata_iot, wdr->sata_baseioh, (wdc_cp->ch_channel << 6) + 0x8, 1, &wdr->sata_control) != 0) { - aprint_error("%s: couldn't map channel %d " - "sata_control regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d sata_control regs\n", wdc_cp->ch_channel); continue; } @@ -1051,26 +1047,25 @@ via_sata_chip_map_new(struct pciide_softc *sc, struct pci_attach_args *pa) if (pci_mapreg_map(pa, (0x10 + (4 * (channel))), PCI_MAPREG_TYPE_IO, 0, &wdr->cmd_iot, &wdr->cmd_baseioh, NULL, &cmdsize) != 0) { - aprint_error("%s: couldn't map %s channel regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - cp->name); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map %s channel regs\n", cp->name); } wdr->ctl_iot = wdr->cmd_iot; for (i = 0; i < WDC_NREG; i++) { if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: couldn't subregion %s " - "channel cmd regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, - cp->name); + aprint_error_dev( + sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't subregion %s " + "channel cmd regs\n", cp->name); return; } } if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, WDC_NREG + 2, 1, &wdr->ctl_ioh) != 0) { - aprint_error("%s: couldn't map channel %d ctl regs\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, channel); + aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev, + "couldn't map channel %d ctl regs\n", channel); return; } wdc_init_shadow_regs(wdc_cp); diff --git a/sys/dev/pcmcia/wdc_pcmcia.c b/sys/dev/pcmcia/wdc_pcmcia.c index aea72b413d8..374e395d915 100644 --- a/sys/dev/pcmcia/wdc_pcmcia.c +++ b/sys/dev/pcmcia/wdc_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_pcmcia.c,v 1.109 2007/10/19 12:01:06 ad Exp $ */ +/* $NetBSD: wdc_pcmcia.c,v 1.110 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.109 2007/10/19 12:01:06 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.110 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -89,13 +89,13 @@ struct wdc_pcmcia_softc { #define bus_space_write_region_stream_4 bus_space_write_region_4 #endif /* __BUS_SPACE_HAS_STREAM_METHODS */ -static int wdc_pcmcia_match(struct device *, struct cfdata *, void *); +static int wdc_pcmcia_match(device_t, cfdata_t, void *); static int wdc_pcmcia_validate_config_io(struct pcmcia_config_entry *); static int wdc_pcmcia_validate_config_memory(struct pcmcia_config_entry *); -static void wdc_pcmcia_attach(struct device *, struct device *, void *); -static int wdc_pcmcia_detach(struct device *, int); +static void wdc_pcmcia_attach(device_t, device_t, void *); +static int wdc_pcmcia_detach(device_t, int); -CFATTACH_DECL(wdc_pcmcia, sizeof(struct wdc_pcmcia_softc), +CFATTACH_DECL_NEW(wdc_pcmcia, sizeof(struct wdc_pcmcia_softc), wdc_pcmcia_match, wdc_pcmcia_attach, wdc_pcmcia_detach, wdcactivate); static const struct wdc_pcmcia_product { @@ -169,15 +169,14 @@ static const struct wdc_pcmcia_product { static const size_t wdc_pcmcia_nproducts = sizeof(wdc_pcmcia_products) / sizeof(wdc_pcmcia_products[0]); -static int wdc_pcmcia_enable(struct device *, int); +static int wdc_pcmcia_enable(device_t, int); static void wdc_pcmcia_datain_memory(struct ata_channel *, int, void *, size_t); static void wdc_pcmcia_dataout_memory(struct ata_channel *, int, void *, size_t); static int -wdc_pcmcia_match(struct device *parent, struct cfdata *match, - void *aux) +wdc_pcmcia_match(device_t parent, cfdata_t match, void *aux) { struct pcmcia_attach_args *pa = aux; @@ -212,10 +211,9 @@ wdc_pcmcia_validate_config_memory(struct pcmcia_config_entry *cfe) } static void -wdc_pcmcia_attach(struct device *parent, struct device *self, - void *aux) +wdc_pcmcia_attach(device_t parent, device_t self, void *aux) { - struct wdc_pcmcia_softc *sc = (void *)self; + struct wdc_pcmcia_softc *sc = device_private(self); struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; struct wdc_regs *wdr; @@ -224,6 +222,7 @@ wdc_pcmcia_attach(struct device *parent, struct device *self, int i; int error; + sc->sc_wdcdev.sc_atac.atac_dev = self; sc->sc_pf = pa->pf; error = pcmcia_function_configure(pa->pf, @@ -233,8 +232,7 @@ wdc_pcmcia_attach(struct device *parent, struct device *self, error = pcmcia_function_configure(pa->pf, wdc_pcmcia_validate_config_memory); if (error) { - aprint_error("%s: configure failed, error=%d\n", self->dv_xname, - error); + aprint_error_dev(self, "configure failed, error=%d\n", error); return; } @@ -275,14 +273,13 @@ wdc_pcmcia_attach(struct device *parent, struct device *self, wdr->cmd_baseioh, offset + i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) { - aprint_error("%s: can't subregion I/O space\n", - self->dv_xname); + aprint_error_dev(self, "can't subregion I/O space\n"); goto fail; } } if (cfe->iftype == PCMCIA_IFTYPE_MEMORY) { - aprint_normal("%s: memory mapped mode\n", self->dv_xname); + aprint_normal_dev(self, "memory mapped mode\n"); wdr->data32iot = cfe->memspace[0].handle.memt; if (bus_space_subregion(cfe->memspace[0].handle.memt, cfe->memspace[0].handle.memh, offset + 1024, 1024, @@ -292,7 +289,7 @@ wdc_pcmcia_attach(struct device *parent, struct device *self, sc->sc_wdcdev.dataout_pio = wdc_pcmcia_dataout_memory; sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_NOIRQ; } else { - aprint_normal("%s: i/o mapped mode\n", self->dv_xname); + aprint_normal_dev(self, "i/o mapped mode\n"); wdr->data32iot = wdr->cmd_iot; wdr->data32ioh = wdr->cmd_iohs[wd_data]; sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA32; @@ -338,9 +335,9 @@ fail: } static int -wdc_pcmcia_detach(struct device *self, int flags) +wdc_pcmcia_detach(device_t self, int flags) { - struct wdc_pcmcia_softc *sc = (struct wdc_pcmcia_softc *)self; + struct wdc_pcmcia_softc *sc = device_private(self); int error; if (sc->sc_state != WDC_PCMCIA_ATTACHED) @@ -357,7 +354,7 @@ wdc_pcmcia_detach(struct device *self, int flags) static int wdc_pcmcia_enable(struct device *self, int onoff) { - struct wdc_pcmcia_softc *sc = (void *)self; + struct wdc_pcmcia_softc *sc = device_private(self); int error; if (onoff) { diff --git a/sys/dev/podulebus/dtide.c b/sys/dev/podulebus/dtide.c index 9e3a7882a68..de882adf133 100644 --- a/sys/dev/podulebus/dtide.c +++ b/sys/dev/podulebus/dtide.c @@ -1,4 +1,4 @@ -/* $NetBSD: dtide.c,v 1.24 2007/10/19 12:01:07 ad Exp $ */ +/* $NetBSD: dtide.c,v 1.25 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dtide.c,v 1.24 2007/10/19 12:01:07 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dtide.c,v 1.25 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> @@ -59,17 +59,17 @@ struct dtide_softc { bus_space_handle_t sc_magich; }; -static int dtide_match(struct device *, struct cfdata *, void *); -static void dtide_attach(struct device *, struct device *, void *); +static int dtide_match(device_t, cfdata_t, void *); +static void dtide_attach(device_t, device_t, void *); -CFATTACH_DECL(dtide, sizeof(struct dtide_softc), +CFATTACH_DECL_NEW(dtide, sizeof(struct dtide_softc), dtide_match, dtide_attach, NULL, NULL); static const int dtide_cmdoffsets[] = { DTIDE_CMDBASE0, DTIDE_CMDBASE1 }; static const int dtide_ctloffsets[] = { DTIDE_CTLBASE0, DTIDE_CTLBASE1 }; static int -dtide_match(struct device *parent, struct cfdata *cf, void *aux) +dtide_match(device_t parent, cfdata_t cf, void *aux) { struct podulebus_attach_args *pa = aux; @@ -77,7 +77,7 @@ dtide_match(struct device *parent, struct cfdata *cf, void *aux) } static void -dtide_attach(struct device *parent, struct device *self, void *aux) +dtide_attach(device_t parent, device_t self, void *aux) { struct podulebus_attach_args *pa = aux; struct dtide_softc *sc = device_private(self); @@ -86,6 +86,7 @@ dtide_attach(struct device *parent, struct device *self, void *aux) int i, j; bus_space_tag_t bst; + sc->sc_wdc.sc_atac.atac_dev = self; sc->sc_wdc.regs = sc->sc_wdc_regs; sc->sc_wdc.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_NOIRQ; @@ -96,7 +97,7 @@ dtide_attach(struct device *parent, struct device *self, void *aux) bus_space_map(pa->pa_fast_t, pa->pa_fast_base + DTIDE_MAGICBASE, 0, 1, &sc->sc_magich); podulebus_shift_tag(pa->pa_fast_t, DTIDE_REGSHIFT, &bst); - printf("\n"); + aprint_normal("\n"); for (i = 0; i < DTIDE_NCHANNELS; i++) { ch = sc->sc_chp[i] = &sc->sc_chan[i]; wdr = &sc->sc_wdc_regs[i]; diff --git a/sys/dev/podulebus/hcide.c b/sys/dev/podulebus/hcide.c index 528dd2871cd..a7fd548a69b 100644 --- a/sys/dev/podulebus/hcide.c +++ b/sys/dev/podulebus/hcide.c @@ -1,4 +1,4 @@ -/* $NetBSD: hcide.c,v 1.21 2007/10/19 12:01:07 ad Exp $ */ +/* $NetBSD: hcide.c,v 1.22 2008/03/18 20:46:37 cube Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hcide.c,v 1.21 2007/10/19 12:01:07 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hcide.c,v 1.22 2008/03/18 20:46:37 cube Exp $"); #include <sys/param.h> @@ -56,17 +56,17 @@ struct hcide_softc { struct wdc_regs sc_wdc_regs[HCIDE_NCHANNELS]; }; -static int hcide_match (struct device *, struct cfdata *, void *); -static void hcide_attach (struct device *, struct device *, void *); +static int hcide_match (device_t, cfdata_t, void *); +static void hcide_attach (device_t, device_t, void *); -CFATTACH_DECL(hcide, sizeof(struct hcide_softc), +CFATTACH_DECL_NEW(hcide, sizeof(struct hcide_softc), hcide_match, hcide_attach, NULL, NULL); static const int hcide_cmdoffsets[] = { HCIDE_CMD0, HCIDE_CMD1, HCIDE_CMD2 }; static const int hcide_ctloffsets[] = { HCIDE_CTL, HCIDE_CTL, HCIDE_CTL }; static int -hcide_match(struct device *parent, struct cfdata *cf, void *aux) +hcide_match(device_t parent, cfdata_t cf, void *aux) { struct podulebus_attach_args *pa = aux; @@ -77,7 +77,7 @@ hcide_match(struct device *parent, struct cfdata *cf, void *aux) } static void -hcide_attach(struct device *parent, struct device *self, void *aux) +hcide_attach(device_t parent, device_t self, void *aux) { struct hcide_softc *sc = device_private(self); struct wdc_regs *wdr; @@ -85,13 +85,14 @@ hcide_attach(struct device *parent, struct device *self, void *aux) struct ata_channel *ch; int i, j; + sc->sc_wdc.sc_atac.atac_dev = self; sc->sc_wdc.regs = sc->sc_wdc_regs; sc->sc_wdc.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_NOIRQ; sc->sc_wdc.sc_atac.atac_pio_cap = 0; /* XXX correct? */ sc->sc_wdc.sc_atac.atac_nchannels = HCIDE_NCHANNELS; sc->sc_wdc.sc_atac.atac_channels = sc->sc_chp; - printf("\n"); + aprint_normal("\n"); for (i = 0; i < HCIDE_NCHANNELS; i++) { ch = sc->sc_chp[i] = &sc->sc_chan[i]; wdr = &sc->sc_wdc_regs[i]; diff --git a/sys/dev/scsipi/atapi_wdc.c b/sys/dev/scsipi/atapi_wdc.c index a1d1e22da2d..2a4e0e36323 100644 --- a/sys/dev/scsipi/atapi_wdc.c +++ b/sys/dev/scsipi/atapi_wdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: atapi_wdc.c,v 1.105 2007/10/19 12:01:18 ad Exp $ */ +/* $NetBSD: atapi_wdc.c,v 1.106 2008/03/18 20:46:37 cube Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.105 2007/10/19 12:01:18 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.106 2008/03/18 20:46:37 cube Exp $"); #ifndef ATADEBUG #define ATADEBUG @@ -120,7 +120,7 @@ wdc_atapibus_attach(struct atabus_softc *ata_sc) /* * Fill in the scsipi_adapter. */ - adapt->adapt_dev = &atac->atac_dev; + adapt->adapt_dev = atac->atac_dev; adapt->adapt_nchannels = atac->atac_nchannels; adapt->adapt_request = wdc_atapi_scsipi_request; adapt->adapt_minphys = wdc_atapi_minphys; @@ -141,7 +141,7 @@ wdc_atapibus_attach(struct atabus_softc *ata_sc) chan->chan_ntargets = 2; chan->chan_nluns = 1; - chp->atapibus = config_found_ia(&ata_sc->sc_dev, "atapi", chan, + chp->atapibus = config_found_ia(ata_sc->sc_dev, "atapi", chan, atapiprint); } @@ -163,7 +163,7 @@ static void wdc_atapi_kill_pending(struct scsipi_periph *periph) { struct atac_softc *atac = - (void *)periph->periph_channel->chan_adapter->adapt_dev; + device_private(periph->periph_channel->chan_adapter->adapt_dev); struct ata_channel *chp = atac->atac_channels[periph->periph_channel->chan_channel]; @@ -196,7 +196,7 @@ static int wdc_atapi_get_params(struct scsipi_channel *chan, int drive, struct ataparams *id) { - struct wdc_softc *wdc = (void *)chan->chan_adapter->adapt_dev; + struct wdc_softc *wdc = device_private(chan->chan_adapter->adapt_dev); struct atac_softc *atac = &wdc->sc_atac; struct wdc_regs *wdr = &wdc->regs[chan->chan_channel]; struct ata_channel *chp = atac->atac_channels[chan->chan_channel]; @@ -218,13 +218,13 @@ wdc_atapi_get_params(struct scsipi_channel *chan, int drive, if (wdc_exec_command(&chp->ch_drive[drive], &ata_c) != ATACMD_COMPLETE) { printf("wdc_atapi_get_params: ATAPI_SOFT_RESET failed for" " drive %s:%d:%d: driver failed\n", - atac->atac_dev.dv_xname, chp->ch_channel, drive); + device_xname(atac->atac_dev), chp->ch_channel, drive); panic("wdc_atapi_get_params"); } if (ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { ATADEBUG_PRINT(("wdc_atapi_get_params: ATAPI_SOFT_RESET " "failed for drive %s:%d:%d: error 0x%x\n", - atac->atac_dev.dv_xname, chp->ch_channel, drive, + device_xname(atac->atac_dev), chp->ch_channel, drive, ata_c.r_error), DEBUG_PROBE); return -1; } @@ -237,7 +237,7 @@ wdc_atapi_get_params(struct scsipi_channel *chan, int drive, if (ata_get_params(&chp->ch_drive[drive], AT_WAIT, id) != 0) { ATADEBUG_PRINT(("wdc_atapi_get_params: ATAPI_IDENTIFY_DEVICE " "failed for drive %s:%d:%d: error 0x%x\n", - atac->atac_dev.dv_xname, chp->ch_channel, drive, + device_xname(atac->atac_dev), chp->ch_channel, drive, ata_c.r_error), DEBUG_PROBE); return -1; } @@ -251,7 +251,7 @@ wdc_atapi_probe_device(struct atapibus_softc *sc, int target) struct scsipi_periph *periph; struct ataparams ids; struct ataparams *id = &ids; - struct wdc_softc *wdc = (void *)chan->chan_adapter->adapt_dev; + struct wdc_softc *wdc = device_private(chan->chan_adapter->adapt_dev); struct atac_softc *atac = &wdc->sc_atac; struct ata_channel *chp = atac->atac_channels[chan->chan_channel]; struct ata_drive_datas *drvp = &chp->ch_drive[target]; @@ -273,7 +273,7 @@ wdc_atapi_probe_device(struct atapibus_softc *sc, int target) periph = scsipi_alloc_periph(M_NOWAIT); if (periph == NULL) { printf("%s: unable to allocate periph for drive %d\n", - sc->sc_dev.dv_xname, target); + device_xname(&sc->sc_dev), target); return; } periph->periph_dev = NULL; @@ -341,7 +341,7 @@ wdc_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, struct scsipi_adapter *adapt = chan->chan_adapter; struct scsipi_periph *periph; struct scsipi_xfer *sc_xfer; - struct wdc_softc *wdc = (void *)adapt->adapt_dev; + struct wdc_softc *wdc = device_private(adapt->adapt_dev); struct atac_softc *atac = &wdc->sc_atac; struct ata_xfer *xfer; int channel = chan->chan_channel; @@ -354,8 +354,9 @@ wdc_atapi_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, drive = periph->periph_target; ATADEBUG_PRINT(("wdc_atapi_scsipi_request %s:%d:%d\n", - atac->atac_dev.dv_xname, channel, drive), DEBUG_XFERS); - if (!device_is_active(&atac->atac_dev)) { + device_xname(atac->atac_dev), channel, drive), + DEBUG_XFERS); + if (!device_is_active(atac->atac_dev)) { sc_xfer->error = XS_DRIVER_STUFFUP; scsipi_done(sc_xfer); return; @@ -459,7 +460,7 @@ wdc_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer) const char *errstring; ATADEBUG_PRINT(("wdc_atapi_start %s:%d:%d, scsi flags 0x%x \n", - atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive, + device_xname(atac->atac_dev), chp->ch_channel, drvp->drive, sc_xfer->xs_control), DEBUG_XFERS); #if NATA_DMA if ((xfer->c_flags & C_DMA) && (drvp->n_xfers <= NXFER)) @@ -507,7 +508,7 @@ wdc_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer) */ printf("%s:%d:%d: PIO mode %d rejected, " "falling back to PIO mode 3\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, drvp->PIO_mode); if (drvp->PIO_mode > 3) @@ -545,7 +546,7 @@ wdc_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer) */ printf("%s:%d:%d: DMA mode %d rejected, " "falling back to DMA mode 0\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, drvp->DMA_mode); if (drvp->DMA_mode > 0) @@ -663,7 +664,7 @@ ready: return; timeout: printf("%s:%d:%d: %s timed out\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, errstring); sc_xfer->error = XS_TIMEOUT; bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT); @@ -672,7 +673,7 @@ timeout: return; error: printf("%s:%d:%d: %s ", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, errstring); printf("error (0x%x)\n", chp->ch_error); sc_xfer->error = XS_SHORTSENSE; @@ -702,14 +703,14 @@ wdc_atapi_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) void *cmd; ATADEBUG_PRINT(("wdc_atapi_intr %s:%d:%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive), + device_xname(atac->atac_dev), chp->ch_channel, drvp->drive), DEBUG_INTR); /* Is it not a transfer, but a control operation? */ if (drvp->state < READY) { printf("%s:%d:%d: bad state %d in wdc_atapi_intr\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, - drvp->state); + device_xname(atac->atac_dev), chp->ch_channel, + xfer->c_drive, drvp->state); panic("wdc_atapi_intr: bad state"); } /* @@ -749,8 +750,8 @@ wdc_atapi_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq) if (irq && (xfer->c_flags & C_TIMEOU) == 0) return 0; /* IRQ was not for us */ printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip=%d\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, - xfer->c_bcount, xfer->c_skip); + device_xname(atac->atac_dev), chp->ch_channel, + xfer->c_drive, xfer->c_bcount, xfer->c_skip); #if NATA_DMA if (xfer->c_flags & C_DMA) { ata_dmaerr(drvp, @@ -999,7 +1000,8 @@ wdc_atapi_phase_complete(struct ata_xfer *xfer) /* wait for DSC if needed */ if (drvp->drive_flags & DRIVE_ATAPIST) { ATADEBUG_PRINT(("wdc_atapi_phase_complete(%s:%d:%d) " - "polldsc %d\n", atac->atac_dev.dv_xname, chp->ch_channel, + "polldsc %d\n", device_xname(atac->atac_dev), + chp->ch_channel, xfer->c_drive, xfer->c_dscpoll), DEBUG_XFERS); #if 1 if (cold) @@ -1012,7 +1014,7 @@ wdc_atapi_phase_complete(struct ata_xfer *xfer) mstohz(sc_xfer->timeout)) { printf("%s:%d:%d: wait_for_dsc " "failed\n", - atac->atac_dev.dv_xname, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive); sc_xfer->error = XS_TIMEOUT; wdc_atapi_reset(chp, xfer); @@ -1079,7 +1081,7 @@ wdc_atapi_done(struct ata_channel *chp, struct ata_xfer *xfer) int drive = xfer->c_drive; ATADEBUG_PRINT(("wdc_atapi_done %s:%d:%d: flags 0x%x\n", - atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive, (u_int)xfer->c_flags), DEBUG_XFERS); callout_stop(&chp->ch_callout); /* mark controller inactive and free the command */ @@ -1110,7 +1112,7 @@ wdc_atapi_reset(struct ata_channel *chp, struct ata_xfer *xfer) drvp->state = 0; if (wdc_wait_for_unbusy(chp, WDC_RESET_WAIT, AT_POLL) != 0) { printf("%s:%d:%d: reset failed\n", - atac->atac_dev.dv_xname, chp->ch_channel, + device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive); sc_xfer->error = XS_SELTIMEOUT; } |
