Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
[safe/jmp/linux-2.6] / drivers / ide / cs5536.c
index 353a35b..24214ab 100644 (file)
@@ -125,11 +125,11 @@ static u8 cs5536_cable_detect(ide_hwif_t *hwif)
 
 /**
  *     cs5536_set_pio_mode             -       PIO timing setup
+ *     @hwif: ATA port
  *     @drive: ATA device
- *     @pio: PIO mode number
  */
 
-static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cs5536_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        static const u8 drv_timings[5] = {
                0x98, 0x55, 0x32, 0x21, 0x20,
@@ -143,17 +143,20 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
                0x99, 0x92, 0x90, 0x22, 0x20,
        };
 
-       struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
+       struct pci_dev *pdev = to_pci_dev(hwif->dev);
        ide_drive_t *pair = ide_get_pair_dev(drive);
        int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT;
+       unsigned long timings = (unsigned long)ide_get_drivedata(drive);
        u32 cast;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        u8 cmd_pio = pio;
 
        if (pair)
-               cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4));
+               cmd_pio = min_t(u8, pio, pair->pio_mode - XFER_PIO_0);
 
-       drive->drive_data &= (IDE_DRV_MASK << 8);
-       drive->drive_data |= drv_timings[pio];
+       timings &= (IDE_DRV_MASK << 8);
+       timings |= drv_timings[pio];
+       ide_set_drivedata(drive, (void *)timings);
 
        cs5536_program_dtc(drive, drv_timings[pio]);
 
@@ -170,11 +173,11 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
 
 /**
  *     cs5536_set_dma_mode             -       DMA timing setup
+ *     @hwif: ATA port
  *     @drive: ATA device
- *     @mode: DMA mode
  */
 
-static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
+static void cs5536_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        static const u8 udma_timings[6] = {
                0xc2, 0xc1, 0xc0, 0xc4, 0xc5, 0xc6,
@@ -184,9 +187,11 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
                0x67, 0x21, 0x20,
        };
 
-       struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
+       struct pci_dev *pdev = to_pci_dev(hwif->dev);
        int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT;
+       unsigned long timings = (unsigned long)ide_get_drivedata(drive);
        u32 etc;
+       const u8 mode = drive->dma_mode;
 
        cs5536_read(pdev, ETC, &etc);
 
@@ -195,8 +200,9 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
                etc |= udma_timings[mode - XFER_UDMA_0] << dshift;
        } else { /* MWDMA */
                etc &= ~(IDE_ETC_UDMA_MASK << dshift);
-               drive->drive_data &= IDE_DRV_MASK;
-               drive->drive_data |= mwdma_timings[mode - XFER_MW_DMA_0] << 8;
+               timings &= IDE_DRV_MASK;
+               timings |= mwdma_timings[mode - XFER_MW_DMA_0] << 8;
+               ide_set_drivedata(drive, (void *)timings);
        }
 
        cs5536_write(pdev, ETC, etc);
@@ -204,9 +210,11 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
 
 static void cs5536_dma_start(ide_drive_t *drive)
 {
+       unsigned long timings = (unsigned long)ide_get_drivedata(drive);
+
        if (drive->current_speed < XFER_UDMA_0 &&
-           (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK))
-               cs5536_program_dtc(drive, drive->drive_data >> 8);
+           (timings >> 8) != (timings & IDE_DRV_MASK))
+               cs5536_program_dtc(drive, timings >> 8);
 
        ide_dma_start(drive);
 }
@@ -214,10 +222,11 @@ static void cs5536_dma_start(ide_drive_t *drive)
 static int cs5536_dma_end(ide_drive_t *drive)
 {
        int ret = ide_dma_end(drive);
+       unsigned long timings = (unsigned long)ide_get_drivedata(drive);
 
        if (drive->current_speed < XFER_UDMA_0 &&
-           (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK))
-               cs5536_program_dtc(drive, drive->drive_data & IDE_DRV_MASK);
+           (timings >> 8) != (timings & IDE_DRV_MASK))
+               cs5536_program_dtc(drive, timings & IDE_DRV_MASK);
 
        return ret;
 }
@@ -236,6 +245,7 @@ static const struct ide_dma_ops cs5536_dma_ops = {
        .dma_test_irq           = ide_dma_test_irq,
        .dma_lost_irq           = ide_dma_lost_irq,
        .dma_timer_expiry       = ide_dma_sff_timer_expiry,
+       .dma_sff_read_status    = ide_dma_sff_read_status,
 };
 
 static const struct ide_port_info cs5536_info = {