Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Move the drive probing code out of atabusconfig() an...
details: https://anonhg.NetBSD.org/src/rev/3c27c4632c48
branches: trunk
changeset: 556921:3c27c4632c48
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Dec 30 17:18:11 2003 +0000
description:
Move the drive probing code out of atabusconfig() and into a new
wdc_drvprobe() function. wdc_drvprobe() is used if the controller
does not specify a custom one prior to calling wdcattach(). The
WDC_CAPABILITY_DRVPROBE bit is gone.
diffstat:
sys/dev/ic/wdc.c | 62 +++++++++++++++++++++++++++++--------------------
sys/dev/ic/wdcvar.h | 12 ++++----
sys/dev/pci/satalink.c | 12 ++-------
3 files changed, 45 insertions(+), 41 deletions(-)
diffs (242 lines):
diff -r 76f504080963 -r 3c27c4632c48 sys/dev/ic/wdc.c
--- a/sys/dev/ic/wdc.c Tue Dec 30 16:40:12 2003 +0000
+++ b/sys/dev/ic/wdc.c Tue Dec 30 17:18:11 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.163 2003/12/30 16:40:12 thorpej Exp $ */
+/* $NetBSD: wdc.c,v 1.164 2003/12/30 17:18:11 thorpej 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.163 2003/12/30 16:40:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.164 2003/12/30 17:18:11 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -190,30 +190,16 @@
* - try an ATA command on the master.
*/
-void
-atabusconfig(struct atabus_softc *atabus_sc)
+static void
+wdc_drvprobe(struct channel_softc *chp)
{
- struct channel_softc *chp = atabus_sc->sc_chan;
- int i, error, need_delref = 0;
struct ataparams params;
- struct atabus_initq *atabus_initq = NULL;
u_int8_t st0 = 0, st1 = 0;
+ int i, error;
- if ((error = wdc_addref(chp)) != 0) {
- aprint_error("%s: unable to enable controller\n",
- chp->wdc->sc_dev.dv_xname);
- goto out;
- }
- need_delref = 1;
-
- if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_DRVPROBE) != 0) {
- if ((*chp->wdc->drv_probe)(chp) == 0) {
- /* If no drives, abort attach here. */
- goto out;
- }
- } else if (wdcprobe1(chp, 0) == 0) {
- /* If no drives, abort attach here. */
- goto out;
+ if (wdcprobe1(chp, 0) == 0) {
+ /* No drives, abort the attach here. */
+ return;
}
/* for ATA/OLD drives, wait for DRDY, 3s timeout */
@@ -241,7 +227,7 @@
== 0 ||
(st1 & WDCS_DRDY)))
break;
- tsleep(&atabus_sc, PRIBIO, "atadrdy", 1);
+ tsleep(¶ms, PRIBIO, "atadrdy", 1);
}
if ((st0 & WDCS_DRDY) == 0)
chp->ch_drive[0].drive_flags &= ~(DRIVE_ATA|DRIVE_OLD);
@@ -274,17 +260,17 @@
/* Shortcut in case we've been shutdown */
if (chp->ch_flags & WDCF_SHUTDOWN)
- goto out;
+ return;
/* issue an identify, to try to detect ghosts */
error = ata_get_params(&chp->ch_drive[i],
AT_WAIT | AT_POLL, ¶ms);
if (error != CMD_OK) {
- tsleep(&atabus_sc, PRIBIO, "atacnf", mstohz(1000));
+ tsleep(¶ms, PRIBIO, "atacnf", mstohz(1000));
/* Shortcut in case we've been shutdown */
if (chp->ch_flags & WDCF_SHUTDOWN)
- goto out;
+ return;
error = ata_get_params(&chp->ch_drive[i],
AT_WAIT | AT_POLL, ¶ms);
@@ -349,6 +335,24 @@
}
}
}
+}
+
+void
+atabusconfig(struct atabus_softc *atabus_sc)
+{
+ struct channel_softc *chp = atabus_sc->sc_chan;
+ int i, error, need_delref = 0;
+ struct atabus_initq *atabus_initq = NULL;
+
+ if ((error = wdc_addref(chp)) != 0) {
+ aprint_error("%s: unable to enable controller\n",
+ chp->wdc->sc_dev.dv_xname);
+ goto out;
+ }
+ need_delref = 1;
+
+ /* Probe for the drives. */
+ (*chp->wdc->drv_probe)(chp);
WDCDEBUG_PRINT(("atabusattach: ch_drive_flags 0x%x 0x%x\n",
chp->ch_drive[0].drive_flags, chp->ch_drive[1].drive_flags),
@@ -359,6 +363,10 @@
(chp->ch_drive[1].drive_flags & DRIVE) == 0)
goto out;
+ /* Shortcut in case we've been shutdown */
+ if (chp->ch_flags & WDCF_SHUTDOWN)
+ goto out;
+
/* Make sure the devices probe in atabus order to avoid jitter. */
simple_lock(&atabus_interlock);
while(1) {
@@ -650,6 +658,8 @@
/* initialise global data */
callout_init(&chp->ch_callout);
+ if (chp->wdc->drv_probe == NULL)
+ chp->wdc->drv_probe = wdc_drvprobe;
if (inited == 0) {
/* Initialize the wdc_xfer pool. */
pool_init(&wdc_xfer_pool, sizeof(struct wdc_xfer), 0,
diff -r 76f504080963 -r 3c27c4632c48 sys/dev/ic/wdcvar.h
--- a/sys/dev/ic/wdcvar.h Tue Dec 30 16:40:12 2003 +0000
+++ b/sys/dev/ic/wdcvar.h Tue Dec 30 17:18:11 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdcvar.h,v 1.47 2003/12/30 16:28:37 thorpej Exp $ */
+/* $NetBSD: wdcvar.h,v 1.48 2003/12/30 17:18:11 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@@ -93,7 +93,8 @@
* are not independent.
*/
struct channel_queue *ch_queue;
- /* the channel kenrel thread */
+
+ /* the channel kernel thread */
struct proc *thread;
};
@@ -116,7 +117,6 @@
#define WDC_CAPABILITY_NOIRQ 0x1000 /* Controller never interrupts */
#define WDC_CAPABILITY_SELECT 0x2000 /* Controller selects target */
#define WDC_CAPABILITY_RAID 0x4000 /* Controller "supports" RAID */
-#define WDC_CAPABILITY_DRVPROBE 0x8000 /* Controller has smart drive probe */
u_int8_t PIO_cap; /* highest PIO mode supported */
u_int8_t DMA_cap; /* highest DMA mode supported */
u_int8_t UDMA_cap; /* highest UDMA mode supported */
@@ -128,6 +128,9 @@
*/
struct atapi_adapter sc_atapi_adapter;
+ /* Function used to probe for drives. */
+ void (*drv_probe) __P((struct channel_softc *));
+
/* if WDC_CAPABILITY_DMA set in 'cap' */
void *dma_arg;
int (*dma_init) __P((void *, int, int, void *, size_t,
@@ -155,9 +158,6 @@
/* if WDC_CAPABILITY_IRQACK set in 'cap' */
void (*irqack) __P((struct channel_softc *));
-
- /* if WDC_CAPABILITY_DRVPROBE is set in 'cap' */
- int (*drv_probe) __P((struct channel_softc *));
};
/*
diff -r 76f504080963 -r 3c27c4632c48 sys/dev/pci/satalink.c
--- a/sys/dev/pci/satalink.c Tue Dec 30 16:40:12 2003 +0000
+++ b/sys/dev/pci/satalink.c Tue Dec 30 17:18:11 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: satalink.c,v 1.6 2003/12/20 06:26:47 thorpej Exp $ */
+/* $NetBSD: satalink.c,v 1.7 2003/12/30 17:18:11 thorpej Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -266,7 +266,7 @@
static void sii3112_chip_map(struct pciide_softc*, struct pci_attach_args*);
static void sii3114_chip_map(struct pciide_softc*, struct pci_attach_args*);
-static int sii3112_drv_probe(struct channel_softc*);
+static void sii3112_drv_probe(struct channel_softc*);
static void sii3112_setup_channel(struct channel_softc*);
static const struct pciide_product_desc pciide_satalink_products[] = {
@@ -439,7 +439,6 @@
sc->sc_wdcdev.set_modes = sii3112_setup_channel;
/* We can use SControl and SStatus to probe for drives. */
- sc->sc_wdcdev.cap |= WDC_CAPABILITY_DRVPROBE;
sc->sc_wdcdev.drv_probe = sii3112_drv_probe;
sc->sc_wdcdev.channels = sc->wdc_chanarray;
@@ -680,7 +679,6 @@
sc->sc_wdcdev.set_modes = sii3112_setup_channel;
/* We can use SControl and SStatus to probe for drives. */
- sc->sc_wdcdev.cap |= WDC_CAPABILITY_DRVPROBE;
sc->sc_wdcdev.drv_probe = sii3112_drv_probe;
sc->sc_wdcdev.channels = sc->wdc_chanarray;
@@ -736,13 +734,12 @@
"<unknown 15>",
};
-static int
+static void
sii3112_drv_probe(struct channel_softc *chp)
{
struct pciide_channel *cp = (struct pciide_channel *)chp;
struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc;
uint32_t scontrol, sstatus;
- int rv = 0;
uint8_t scnt, sn, cl, ch;
/*
@@ -829,15 +826,12 @@
sc->sc_wdcdev.sc_dev.dv_xname, chp->channel,
sata_speed[(sstatus & SStatus_SPD_mask) >>
SStatus_SPD_shift]);
- rv |= (1 << 0);
break;
default:
aprint_error("%s: port %d: unknown SStatus: 0x%08x\n",
sc->sc_wdcdev.sc_dev.dv_xname, chp->channel, sstatus);
}
-
- return (rv);
}
static void
Home |
Main Index |
Thread Index |
Old Index