ide: remove ->ide_dma_check (take 2)
[linux-2.6-block.git] / drivers / ide / cris / ide-cris.c
index 04636f7eaae77e206a5aa2b2b017d6a2be2d7a35..1ee078d43dbfbe34b68a7bbe26d613f51327c3d5 100644 (file)
@@ -664,7 +664,6 @@ cris_ide_inb(unsigned long reg)
        return (unsigned char)cris_ide_inw(reg);
 }
 
-static int cris_dma_check (ide_drive_t *drive);
 static int cris_dma_end (ide_drive_t *drive);
 static int cris_dma_setup (ide_drive_t *drive);
 static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command);
@@ -680,12 +679,10 @@ static void cris_dma_off(ide_drive_t *drive)
 {
 }
 
-static void tune_cris_ide(ide_drive_t *drive, u8 pio)
+static void cris_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
        int setup, strobe, hold;
 
-       pio = ide_get_best_pio_mode(drive, pio, 4);
-
        switch(pio)
        {
                case 0:
@@ -718,19 +715,12 @@ static void tune_cris_ide(ide_drive_t *drive, u8 pio)
        }
 
        cris_ide_set_speed(TYPE_PIO, setup, strobe, hold);
-
-       (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio);
 }
 
-static int speed_cris_ide(ide_drive_t *drive, u8 speed)
+static void cris_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
        int cyc = 0, dvs = 0, strobe = 0, hold = 0;
 
-       if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) {
-               tune_cris_ide(drive, speed - XFER_PIO_0);
-               return ide_config_drive_speed(drive, speed);
-       }
-
        switch(speed)
        {
                case XFER_UDMA_0:
@@ -766,8 +756,6 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
                cris_ide_set_speed(TYPE_UDMA, cyc, dvs, 0);
        else
                cris_ide_set_speed(TYPE_DMA, 0, strobe, hold);
-
-       return ide_config_drive_speed(drive, speed);
 }
 
 void __init
@@ -797,13 +785,12 @@ init_e100_ide (void)
                ide_register_hw(&hw, 1, &hwif);
                hwif->mmio = 1;
                hwif->chipset = ide_etrax100;
-               hwif->tuneproc = &tune_cris_ide;
-               hwif->speedproc = &speed_cris_ide;
+               hwif->set_pio_mode = &cris_set_pio_mode;
+               hwif->set_dma_mode = &cris_set_dma_mode;
                hwif->ata_input_data = &cris_ide_input_data;
                hwif->ata_output_data = &cris_ide_output_data;
                hwif->atapi_input_bytes = &cris_atapi_input_bytes;
                hwif->atapi_output_bytes = &cris_atapi_output_bytes;
-               hwif->ide_dma_check = &cris_dma_check;
                hwif->ide_dma_end = &cris_dma_end;
                hwif->dma_setup = &cris_dma_setup;
                hwif->dma_exec_cmd = &cris_dma_exec_cmd;
@@ -819,6 +806,8 @@ init_e100_ide (void)
                hwif->dma_off_quietly = &cris_dma_off;
                hwif->cbl = ATA_CBL_PATA40;
                hwif->pio_mask = ATA_PIO4,
+               hwif->drives[0].autotune = 1;
+               hwif->drives[1].autotune = 1;
                hwif->ultra_mask = cris_ultra_mask;
                hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
                hwif->autodma = 1;
@@ -950,7 +939,8 @@ static int cris_ide_build_dmatable (ide_drive_t *drive)
                /* group sequential buffers into one large buffer */
                addr = page_to_phys(sg->page) + sg->offset;
                size = sg_dma_len(sg);
-               while (sg++, --i) {
+               while (--i) {
+                       sg = sg_next(sg);
                        if ((addr + size) != page_to_phys(sg->page) + sg->offset)
                                break;
                        size += sg_dma_len(sg);
@@ -1028,14 +1018,6 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)
  * the caller should revert to PIO for the current request.
  */
 
-static int cris_dma_check(ide_drive_t *drive)
-{
-       if (ide_tune_dma(drive))
-               return 0;
-
-       return -1;
-}
-
 static int cris_dma_end(ide_drive_t *drive)
 {
        drive->waiting_for_dma = 0;