wdcattach() currently doesn't initialize its ata_drive_datas fields
until late in the function, so a few pciide drv_probe routines need to
initialize it themselves.

Simply moving the initialization before calling drv_probe() lets us
get rid of this extra code.

Test reports from any machine with pciide(4)/wdc(4) is appreciated,
but especially if you have one of the following pciide chipsets (i.e.,
chipsets with affected drv_probe() code):

    ATI SB300 SATA (0x1002:0x436e)
    ATI SB400 SATA (0x1002:0x4379)
    ATI SB400 SATA (0x1002:0x437a)
    CMD Technology SiI3112 SATA (0x1095:0x3112)
    CMD Technology SiI3114 SATA (0x1095:0x3114)
    CMD Technology SiI3512 SATA (0x1095:0x3512)
    CMD Technology AAR-1210SA (0x1095:0x0240)
    Promise PDC20571 (0x105a:0x3571)
    Promise PDC20575 (0x105a:0x3d75)
    Promise PDC20579 (0x105a:0x3574)
    Promise PDC20771 (0x105a:0x3570)
    Promise PDC20775 (0x105a:0x3d73)
    Promise PDC40518 (0x105a:0x3d18)
    Promise PDC40519 (0x105a:0x3519)
    Promise PDC40718 (0x105a:0x3d17)
    Promise PDC40719 (0x105a:0x3515)
    Promise PDC40779 (0x105a:0x3577)
    ServerWorks Frodo4 SATA (0x1166:0x0241)
    ServerWorks Frodo8 SATA (0x1166:0x0242)
    ServerWorks HT-1000 SATA (0x1166:0x024a)
    ServerWorks HT-1000 SATA (0x1166:0x024b)
    ServerWorks K2 SATA (0x1166:0x0240)


Index: ic/wdc.c
===================================================================
RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/wdc.c,v
retrieving revision 1.114
diff -u -p -r1.114 wdc.c
--- ic/wdc.c    8 May 2011 17:33:56 -0000       1.114
+++ ic/wdc.c    8 May 2011 22:44:53 -0000
@@ -718,6 +718,11 @@ wdcattach(struct channel_softc *chp)
        if (!chp->_vtbl)
                chp->_vtbl = &wdc_default_vtbl;
 
+       for (i = 0; i < 2; i++) {
+               chp->ch_drive[i].chnl_softc = chp;
+               chp->ch_drive[i].drive = i;
+       }
+
        if (chp->wdc->drv_probe != NULL) {
                chp->wdc->drv_probe(chp);
        } else {
@@ -756,8 +761,6 @@ wdcattach(struct channel_softc *chp)
        for (i = 0; i < 2; i++) {
                struct ata_drive_datas *drvp = &chp->ch_drive[i];
 
-               drvp->chnl_softc = chp;
-               drvp->drive = i;
                /* If controller can't do 16bit flag the drives as 32bit */
                if ((chp->wdc->cap &
                    (WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32)) ==
Index: pci/pciide.c
===================================================================
RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/pci/pciide.c,v
retrieving revision 1.328
diff -u -p -r1.328 pciide.c
--- pci/pciide.c        27 Apr 2011 07:55:05 -0000      1.328
+++ pci/pciide.c        8 May 2011 22:46:35 -0000
@@ -4301,13 +4301,7 @@ sii3112_drv_probe(struct channel_softc *
        struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc;
        uint32_t scontrol, sstatus;
        uint8_t scnt, sn, cl, ch;
-       int i, s;
-
-       /* XXX This should be done by other code. */
-       for (i = 0; i < 2; i++) {
-               chp->ch_drive[i].chnl_softc = chp;
-               chp->ch_drive[i].drive = i;
-       }
+       int s;
 
        /*
         * The 3112 is a 2-port part, and only has one drive per channel
@@ -7103,13 +7097,7 @@ pdc205xx_drv_probe(struct channel_softc 
        bus_space_handle_t *iohs;
        u_int32_t scontrol, sstatus;
        u_int16_t scnt, sn, cl, ch;
-       int i, s;
-
-       /* XXX This should be done by other code. */
-       for (i = 0; i < 2; i++) {
-               chp->ch_drive[i].chnl_softc = chp;
-               chp->ch_drive[i].drive = i;
-       }
+       int s;
 
        SCONTROL_WRITE(ps, chp->channel, 0);
        delay(50*1000);
@@ -7763,13 +7751,7 @@ svwsata_drv_probe(struct channel_softc *
        int channel = chp->channel;
        uint32_t scontrol, sstatus;
        uint8_t scnt, sn, cl, ch;
-       int i, s;
-
-       /* XXX This should be done by other code. */
-       for (i = 0; i < 2; i++) {
-               chp->ch_drive[i].chnl_softc = chp;
-               chp->ch_drive[i].drive = i;
-       }
+       int s;
 
        /*
         * Request communication initialization sequence, any speed.

Reply via email to