Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/dev/pcmcia
On Jan 11, 9:26am, thorpej%shagadelic.org@localhost (Jason Thorpe) wrote:
-- Subject: Re: CVS commit: src/sys/dev/pcmcia
| There should be a way to set max # of drives per channel, and I
| suggest you use that... the phantom drive is pretty annoying.
looking in wdc.c, not only ch_ndrive is hard-coded to 2, but there
are multiple XXX comments about ch_ndrive, and there are even 2 loops
that do:
for (drive = 0; drive < 2; drive++) {
}
Yes, it can all be fixed, but I will let the wdc experts do it. Here's
a patch:
Index: wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
retrieving revision 1.231
diff -u -u -r1.231 wdc.c
--- wdc.c 16 Nov 2005 23:39:08 -0000 1.231
+++ wdc.c 11 Jan 2006 18:20:11 -0000
@@ -223,7 +223,7 @@
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
u_int8_t st0 = 0, st1 = 0;
- int i, error, s;
+ int i, j, error, s;
if (wdcprobe1(chp, 0) == 0) {
/* No drives, abort the attach here. */
@@ -275,7 +275,7 @@
/* Wait a bit, some devices are weird just after a reset. */
delay(5000);
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < chp->ch_ndrive; i++) {
/* XXX This should be done by other code. */
chp->ch_drive[i].chnl_softc = chp;
chp->ch_drive[i].drive = i;
@@ -321,9 +321,8 @@
if (error == CMD_OK) {
/* If IDENTIFY succeeded, this is not an OLD ctrl */
s = splbio();
- /* XXXJRT ch_ndrive */
- chp->ch_drive[0].drive_flags &= ~DRIVE_OLD;
- chp->ch_drive[1].drive_flags &= ~DRIVE_OLD;
+ for (j = 0; j < chp->ch_ndrive; j++)
+ chp->ch_drive[j].drive_flags &= ~DRIVE_OLD;
splx(s);
} else {
s = splbio();
@@ -383,11 +382,9 @@
splx(s);
} else {
s = splbio();
- /* XXXJRT ch_ndrive */
- chp->ch_drive[0].drive_flags &=
- ~(DRIVE_ATA | DRIVE_ATAPI);
- chp->ch_drive[1].drive_flags &=
- ~(DRIVE_ATA | DRIVE_ATAPI);
+ for (j = 0; j < chp->ch_ndrive; j++)
+ chp->ch_drive[j].drive_flags &=
+ ~(DRIVE_ATA | DRIVE_ATAPI);
splx(s);
}
}
@@ -638,7 +635,7 @@
* be something here assume it's ATA or OLD. Ghost will be killed
* later in attach routine.
*/
- for (drive = 0; drive < 2; drive++) {
+ for (drive = 0; drive < chp->ch_ndrive; drive++) {
if ((ret_value & (0x01 << drive)) == 0)
continue;
if (wdc->select)
@@ -684,10 +681,12 @@
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
/*
- * Start out assuming 2 drives. This may change as we probe
- * drives.
+ * XXX: Compatibility
+ * If the driver did not specify how many drives, default to 2.
*/
- chp->ch_ndrive = 2;
+ if (chp->ch_ndrive == 0)
+ chp->ch_ndrive = 2;
+ KASSERT(chp->ch_ndrive < 3);
/* default data transfer methods */
if (wdc->datain_pio == NULL)
christos
Home |
Main Index |
Thread Index |
Old Index