ide: change ->set_pio_mode method parameters
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 19 Jan 2010 09:44:41 +0000 (01:44 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Jan 2010 09:44:41 +0000 (01:44 -0800)
Change ->set_pio_mode method parameters to match ->set_piomode method
used in struct ata_port_operations.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
44 files changed:
drivers/ide/aec62xx.c
drivers/ide/ali14xx.c
drivers/ide/alim15x3.c
drivers/ide/amd74xx.c
drivers/ide/at91_ide.c
drivers/ide/atiixp.c
drivers/ide/au1xxx-ide.c
drivers/ide/cmd640.c
drivers/ide/cmd64x.c
drivers/ide/cs5520.c
drivers/ide/cs5530.c
drivers/ide/cs5535.c
drivers/ide/cs5536.c
drivers/ide/cy82c693.c
drivers/ide/dtc2278.c
drivers/ide/hpt366.c
drivers/ide/ht6560b.c
drivers/ide/ide-devsets.c
drivers/ide/ide-xfer-mode.c
drivers/ide/it8172.c
drivers/ide/it8213.c
drivers/ide/it821x.c
drivers/ide/jmicron.c
drivers/ide/opti621.c
drivers/ide/palm_bk3710.c
drivers/ide/pdc202xx_new.c
drivers/ide/pdc202xx_old.c
drivers/ide/piix.c
drivers/ide/pmac.c
drivers/ide/qd65xx.c
drivers/ide/sc1200.c
drivers/ide/scc_pata.c
drivers/ide/serverworks.c
drivers/ide/siimage.c
drivers/ide/sis5513.c
drivers/ide/sl82c105.c
drivers/ide/slc90e66.c
drivers/ide/tc86c001.c
drivers/ide/triflex.c
drivers/ide/tx4938ide.c
drivers/ide/tx4939ide.c
drivers/ide/umc8672.c
drivers/ide/via82cxxx.c
include/linux/ide.h

index 4c869872eb9a32fff4d393815913cf56d93bdad5..3790847361c3537f0a90327a4121f62c9bc8f51b 100644 (file)
@@ -134,10 +134,10 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
        local_irq_restore(flags);
 }
 
-static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void aec_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       drive->dma_mode = pio + XFER_PIO_0;
-       drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0);
+       drive->dma_mode = drive->pio_mode;
+       hwif->port_ops->set_dma_mode(drive, drive->dma_mode);
 }
 
 static int init_chipset_aec62xx(struct pci_dev *dev)
index 90da1f953ed080d0b0fb3ce38ff527398c42d00c..25b9fe3a9f8ef02047f689645755b347223a94a5 100644 (file)
@@ -109,13 +109,14 @@ static DEFINE_SPINLOCK(ali14xx_lock);
  * This function computes timing parameters
  * and sets controller registers accordingly.
  */
-static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void ali14xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        int driveNum;
        int time1, time2;
        u8 param1, param2, param3, param4;
        unsigned long flags;
        int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 
        /* calculate timing, according to PIO mode */
index 8f03cce055fa9b0469daeffc1cb149ea72759beb..28cee1055f76b8324da03eb9b6d4ea3ae3929d16 100644 (file)
@@ -63,15 +63,14 @@ static void ali_fifo_control(ide_hwif_t *hwif, ide_drive_t *drive, int on)
 
 /**
  *     ali_set_pio_mode        -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Program the controller for the given PIO mode.
  */
 
-static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void ali_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
        unsigned long T =  1000000 / bus_speed; /* PCI clock based */
@@ -79,7 +78,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
        u8 unit = drive->dn & 1;
        struct ide_timing t;
 
-       ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1);
+       ide_timing_compute(drive, drive->pio_mode, &t, T, 1);
 
        t.setup = clamp_val(t.setup, 1, 8) & 7;
        t.active = clamp_val(t.active, 1, 8) & 7;
index 108e9b6768596766b53c1174a72085b0271a1e23..3eee7be7ca6ff801e14d22e3f3c0cc375537a017 100644 (file)
@@ -108,9 +108,9 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed)
  * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning.
  */
 
-static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void amd_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       amd_set_drive(drive, XFER_PIO_0 + pio);
+       amd_set_drive(drive, drive->pio_mode);
 }
 
 static void amd7409_cable_detect(struct pci_dev *dev)
index 248219a89a68cdbf25bce00b93ec51075a47c393..000a78e5246c5c1d9f510fcfbbfc9cf35700137a 100644 (file)
@@ -172,11 +172,12 @@ static void at91_ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
        leave_16bit(chipselect, mode);
 }
 
-static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void at91_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        struct ide_timing *timing;
-       u8 chipselect = drive->hwif->select_data;
+       u8 chipselect = hwif->select_data;
        int use_iordy = 0;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        pdbg("chipselect %u pio %u\n", chipselect, pio);
 
index 837322b10a4c45875462f603ab1e59ee279b124e..b6848dfb93b0dcd1d9f3de1100207dab184e47d4 100644 (file)
@@ -42,19 +42,20 @@ static DEFINE_SPINLOCK(atiixp_lock);
 
 /**
  *     atiixp_set_pio_mode     -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Set the interface PIO mode.
  */
 
-static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void atiixp_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
        unsigned long flags;
        int timing_shift = (drive->dn ^ 1) * 8;
        u32 pio_timing_data;
        u16 pio_mode_data;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        spin_lock_irqsave(&atiixp_lock, flags);
 
index 87cef0c440ad32f625fe7bd55e368b8a427afcf4..c90e9b0a9f6eb058ddff134ac6858ded4ff363d3 100644 (file)
@@ -99,12 +99,11 @@ static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
 }
 #endif
 
-static void au1xxx_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void au1xxx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
 
-       /* set pio mode! */
-       switch(pio) {
+       switch (drive->pio_mode - XFER_PIO_0) {
        case 0:
                mem_sttime = SBC_IDE_TIMING(PIO0);
 
index 1a32d62ed86b6bb611b8cd625a790587ef6b5735..c7d46a3d347a6410b054ffcd3a63354792b4eaf9 100644 (file)
@@ -572,9 +572,10 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
        program_drive_counts(drive, index);
 }
 
-static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cmd640_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        unsigned int index = 0, cycle_time;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        u8 b;
 
        switch (pio) {
index 9f89f3116df0e6e783b0840d9f5991486924d847..0b11745937e7c1270e0a9b2362fd0d7c0c3c8d6d 100644 (file)
@@ -127,8 +127,10 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode)
  * Special cases are 8: prefetch off, 9: prefetch on (both never worked)
  */
 
-static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cmd64x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
+
        /*
         * Filter out the prefetch control values
         * to prevent PIO5 from being programmed
index 09f98ed0731fa251bfb08f46eea0e369eefe3f05..b8094f049f3e17eee26332c31500c229faccf07c 100644 (file)
@@ -57,11 +57,11 @@ static struct pio_clocks cs5520_pio_clocks[]={
        {1, 2, 1}
 };
 
-static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cs5520_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct pci_dev *pdev = to_pci_dev(hwif->dev);
        int controller = drive->dn > 1 ? 1 : 0;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        /* 8bit CAT/CRT - 8bit command timing for channel */
        pci_write_config_byte(pdev, 0x62 + controller, 
@@ -85,7 +85,8 @@ static void cs5520_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
        printk(KERN_ERR "cs55x0: bad ide timing.\n");
 
-       cs5520_set_pio_mode(drive, 0);
+       drive->pio_mode = XFER_PIO_0 + 0;
+       cs5520_set_pio_mode(drive->hwif, drive);
 }
 
 static const struct ide_port_ops cs5520_port_ops = {
index 40bf05eddf6ea1ef55c01e1c87be2ca9f88657b7..4ced40255ad6b3c30ecb472da64e4f9c0e33d405 100644 (file)
@@ -41,8 +41,8 @@ static unsigned int cs5530_pio_timings[2][5] = {
 
 /**
  *     cs5530_set_pio_mode     -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Handles setting of PIO mode for the chipset.
  *
@@ -50,10 +50,11 @@ static unsigned int cs5530_pio_timings[2][5] = {
  *     will have valid default PIO timings set up before we get here.
  */
 
-static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cs5530_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       unsigned long basereg = CS5530_BASEREG(drive->hwif);
+       unsigned long basereg = CS5530_BASEREG(hwif);
        unsigned int format = (inl(basereg + 4) >> 31) & 1;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        outl(cs5530_pio_timings[format][pio], basereg + ((drive->dn & 1)<<3));
 }
index b883838adc241f068f5212972585cdb4cdb4d801..7974415ea89fafc97f0c35dde137b234bd09cbb3 100644 (file)
@@ -142,15 +142,15 @@ static void cs5535_set_dma_mode(ide_drive_t *drive, const u8 speed)
 
 /**
  *     cs5535_set_pio_mode     -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     A callback from the upper layers for PIO-only tuning.
  */
 
-static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cs5535_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       cs5535_set_speed(drive, XFER_PIO_0 + pio);
+       cs5535_set_speed(drive, drive->pio_mode);
 }
 
 static u8 cs5535_cable_detect(ide_hwif_t *hwif)
index 9623b852c616b4a3a27a6ef3277d03994960484a..b518ef0e9a35b01cc2351c5df698bfd713d3d30f 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,11 +143,12 @@ 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)
index fbf3dcc26577939c12449644b35ca6ce1ac89e3d..ead65c394f0024826c7888dd6c86e808160a56ad 100644 (file)
@@ -80,9 +80,8 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
        outb(data, CY82_DATA_PORT);
 }
 
-static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void cy82c693_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
        const unsigned long T = 1000000 / bus_speed;
@@ -101,7 +100,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
                }
        }
 
-       ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1);
+       ide_timing_compute(drive, drive->pio_mode, &t, T, 1);
 
        time_16 = clamp_val(t.recover - 1, 0, 15) |
                  (clamp_val(t.active - 1, 0, 15) << 4);
index c6b138122981b7474b5f3f1381f4e798da9fb132..6929f7fce93a735114333709e8cd020f319c01d3 100644 (file)
@@ -68,11 +68,11 @@ static void sub22 (char b, char c)
 
 static DEFINE_SPINLOCK(dtc2278_lock);
 
-static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void dtc2278_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        unsigned long flags;
 
-       if (pio >= 3) {
+       if (drive->pio_mode >= XFER_PIO_3) {
                spin_lock_irqsave(&dtc2278_lock, flags);
                /*
                 * This enables PIO mode4 (3?) on the first interface
index 4d90ac2dbb1be827aef1a633159ae835f701588d..f1dec519a9e6c98f8bb8a12e02e71ca061aa9e5e 100644 (file)
@@ -651,9 +651,9 @@ static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
        pci_write_config_dword(dev, itr_addr, new_itr);
 }
 
-static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void hpt3xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
+       hpt3xx_set_mode(drive, drive->pio_mode);
 }
 
 static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
index aafed8060e17a223e5b3dac63f6e0012195d1272..d81e49680c3fbc6a52fe89213ad01f9244c7cf34 100644 (file)
@@ -279,9 +279,10 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state)
 #endif
 }
 
-static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void ht6560b_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        unsigned long flags, config;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        u8 timing;
        
        switch (pio) {
index cb3341ce655ceb75f3c2cfca9453c4e068788d32..c6935c78757cfbfaacb06fb820223dc6fd19bec8 100644 (file)
@@ -112,10 +112,10 @@ static int set_pio_mode(ide_drive_t *drive, int arg)
 
                        /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
                        spin_lock_irqsave(&hwif->lock, flags);
-                       port_ops->set_pio_mode(drive, arg);
+                       port_ops->set_pio_mode(hwif, drive);
                        spin_unlock_irqrestore(&hwif->lock, flags);
                } else
-                       port_ops->set_pio_mode(drive, arg);
+                       port_ops->set_pio_mode(hwif, drive);
        } else {
                int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
 
index c2323869d92a2e5622d2b722fb782c243a4e78f4..a62fb03fc1cc9f24606769578587d2a71dd41f0b 100644 (file)
@@ -136,7 +136,7 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
         */
        if (port_ops->set_dma_mode == NULL) {
                drive->pio_mode = mode;
-               port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
+               port_ops->set_pio_mode(hwif, drive);
                return 0;
        }
 
@@ -144,11 +144,11 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
                if (ide_config_drive_speed(drive, mode))
                        return -1;
                drive->pio_mode = mode;
-               port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
+               port_ops->set_pio_mode(hwif, drive);
                return 0;
        } else {
                drive->pio_mode = mode;
-               port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
+               port_ops->set_pio_mode(hwif, drive);
                return ide_config_drive_speed(drive, mode);
        }
 }
index 0d266a5b524d6ad822d0cfaa7c858539dc59a502..9dfdc8741a7bef198e65a891693800b0556e061b 100644 (file)
 
 #define DRV_NAME "IT8172"
 
-static void it8172_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void it8172_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif        = drive->hwif;
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        u16 drive_enables;
        u32 drive_timing;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        /*
         * The highest value of DIOR/DIOW pulse width and recovery time
@@ -98,14 +98,14 @@ static void it8172_set_dma_mode(ide_drive_t *drive, const u8 speed)
                pci_write_config_byte(dev, 0x4a, reg4a | u_speed);
        } else {
                const u8 mwdma_to_pio[] = { 0, 3, 4 };
-               u8 pio;
 
                pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
                pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
 
-               pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
+               drive->pio_mode =
+                       mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
 
-               it8172_set_pio_mode(drive, pio);
+               it8172_set_pio_mode(hwif, drive);
        }
 }
 
index 47976167796a4a03fd35a44dbf1c2b372a920739..492c07d5f4f32962f4fd3bea7ea8900f046fa633 100644 (file)
 
 /**
  *     it8213_set_pio_mode     -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Set the interface PIO mode.
  */
 
-static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void it8213_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif        = drive->hwif;
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        int is_slave            = drive->dn & 1;
        int master_port         = 0x40;
@@ -35,6 +34,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio)
        u8 slave_data;
        static DEFINE_SPINLOCK(tune_lock);
        int control = 0;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        static const u8 timings[][2] = {
                                        { 0, 0 },
@@ -120,7 +120,6 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
        } else {
                const u8 mwdma_to_pio[] = { 0, 3, 4 };
-               u8 pio;
 
                if (reg48 & u_flag)
                        pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
@@ -132,11 +131,12 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
 
                if (speed >= XFER_MW_DMA_0)
-                       pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
+                       drive->pio_mode =
+                               mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
                else
-                       pio = 2; /* only SWDMA2 is allowed */
+                       drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
 
-               it8213_set_pio_mode(drive, pio);
+               it8213_set_pio_mode(hwif, drive);
        }
 }
 
index 51aa745246dcb9551af49161014f533bd4d4e43c..69becb7b9656f27e4969b64903bdbb2bb6ac3b24 100644 (file)
@@ -228,18 +228,18 @@ static void it821x_clock_strategy(ide_drive_t *drive)
 
 /**
  *     it821x_set_pio_mode     -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Tune the host to the desired PIO mode taking into the consideration
  *     the maximum PIO mode supported by the other device on the cable.
  */
 
-static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void it821x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct it821x_dev *itdev = ide_get_hwifdata(hwif);
        ide_drive_t *pair = ide_get_pair_dev(drive);
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        u8 unit = drive->dn & 1, set_pio = pio;
 
        /* Spec says 89 ref driver uses 88 */
index bf2be6431b204d0a593b898a58ce4286a0e3f48b..ebffb904ed24f026f124f7edbf91651ef84a7899 100644 (file)
@@ -80,7 +80,7 @@ static u8 jmicron_cable_detect(ide_hwif_t *hwif)
        return ATA_CBL_PATA80;
 }
 
-static void jmicron_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
 }
 
index 2052788fab7a83971ed7d921c61abbc6e672eba0..1a53a4c375ed4fdf998ac4be336dc1d79e2b82a3 100644 (file)
@@ -62,12 +62,12 @@ static u8 read_reg(int reg)
        return ret;
 }
 
-static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void opti621_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        ide_drive_t *pair = ide_get_pair_dev(drive);
        unsigned long flags;
-       unsigned long mode = XFER_PIO_0 + pio, pair_mode;
+       unsigned long mode = drive->pio_mode, pair_mode;
+       const u8 pio = mode - XFER_PIO_0;
        u8 tim, misc, addr_pio = pio, clk;
 
        /* DRDY is default 2 (by OPTi Databook) */
index f8eddf05ecb8533ebca9e9134c56c097a65170bd..0f262d07c378d342b542ec6555e88ce1929cfaad 100644 (file)
@@ -203,12 +203,13 @@ static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed)
        }
 }
 
-static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio)
+static void palm_bk3710_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        unsigned int cycle_time;
        int is_slave = drive->dn & 1;
        ide_drive_t *mate;
-       void __iomem *base = (void *)drive->hwif->dma_base;
+       void __iomem *base = (void *)hwif->dma_base;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        /*
         * Obtain the drive PIO data for tuning the Palm Chip registers
index 65ba8239e7b563496ca93c905841f5c731d9e2e3..874acd2bb6e62697d9b3430b953f6b9f67e7f7e0 100644 (file)
@@ -167,11 +167,11 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed)
        }
 }
 
-static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void pdcnew_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        u8 adj = (drive->dn & 1) ? 0x08 : 0x00;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        if (max_dma_rate(dev) == 4) {
                set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c);
index 1d20594ee420ce8eacc18fc7f28554370ea33d8f..402aab7f3baafc8c464534a6da025c951139f947 100644 (file)
@@ -76,9 +76,9 @@ static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed)
        }
 }
 
-static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void pdc202xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       pdc202xx_set_mode(drive, XFER_PIO_0 + pio);
+       pdc202xx_set_mode(drive, drive->pio_mode);
 }
 
 static int pdc202xx_test_irq(ide_hwif_t *hwif)
index bf14f39bd3a78c470a7333ee7ebe07bb191e4cc8..64b3041daa607ba64f9ac2dd34e03776a3112ec3 100644 (file)
@@ -59,15 +59,14 @@ static int no_piix_dma;
 
 /**
  *     piix_set_pio_mode       -       set host controller for PIO mode
+ *     @port: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Set the interface PIO mode based upon the settings done by AMI BIOS.
  */
 
-static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void piix_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif        = drive->hwif;
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        int is_slave            = drive->dn & 1;
        int master_port         = hwif->channel ? 0x42 : 0x40;
@@ -77,6 +76,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
        u8 slave_data;
        static DEFINE_SPINLOCK(tune_lock);
        int control = 0;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
                                     /* ISP  RTC */
        static const u8 timings[][2]= {
@@ -176,7 +176,6 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
        } else {
                const u8 mwdma_to_pio[] = { 0, 3, 4 };
-               u8 pio;
 
                if (reg48 & u_flag)
                        pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
@@ -188,11 +187,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
 
                if (speed >= XFER_MW_DMA_0)
-                       pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
+                       drive->pio_mode =
+                               mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
                else
-                       pio = 2; /* only SWDMA2 is allowed */
+                       drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
 
-               piix_set_pio_mode(drive, pio);
+               piix_set_pio_mode(hwif, drive);
        }
 }
 
index 7a4e788cab2f54d5c031cb814e2d42db7ca0e855..a167968a2d42c3e99d4317c52b049c5f86259d65 100644 (file)
@@ -496,12 +496,11 @@ static void pmac_write_devctl(ide_hwif_t *hwif, u8 ctl)
 /*
  * Old tuning functions (called on hdparm -p), sets up drive PIO timings
  */
-static void
-pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void pmac_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        pmac_ide_hwif_t *pmif =
                (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
        u32 *timings, t;
        unsigned accessTicks, recTicks;
index 74696edc8d1dec7e94cb04621a04a782d75aeee4..3f0244fd8e623010433c5086c1656bf812a62fbb 100644 (file)
@@ -189,15 +189,13 @@ static void qd_set_timing (ide_drive_t *drive, u8 timing)
        printk(KERN_DEBUG "%s: %#x\n", drive->name, timing);
 }
 
-static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void qd6500_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        u16 *id = drive->id;
        int active_time   = 175;
        int recovery_time = 415; /* worst case values from the dos driver */
 
-       /*
-        * FIXME: use "pio" value
-        */
+       /* FIXME: use drive->pio_mode value */
        if (!qd_find_disk_type(drive, &active_time, &recovery_time) &&
            (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) &&
            id[ATA_ID_EIDE_PIO] >= 240) {
@@ -211,9 +209,9 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio)
                                active_time, recovery_time));
 }
 
-static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void qd6580_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
        unsigned int cycle_time;
        int active_time   = 175;
index d467478d68da96839efd99b665b552e2f7512bbc..bb0166e460ab80107df7cc5c01220c70f646a88f 100644 (file)
@@ -193,10 +193,10 @@ static int sc1200_dma_end(ide_drive_t *drive)
  * will have valid default PIO timings set up before we get here.
  */
 
-static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void sc1200_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t      *hwif = drive->hwif;
        int             mode = -1;
+       const u8        pio = drive->pio_mode - XFER_PIO_0;
 
        /*
         * bad abuse of ->set_pio_mode interface
index 1104bb301eb98eb4f2d22b78a05ba33d1d99761c..23e16e4460ee8c008f1c0d9dc8831ff0d6e97c4e 100644 (file)
@@ -199,16 +199,15 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count)
 
 /**
  *     scc_set_pio_mode        -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Load the timing settings for this device mode into the
  *     controller.
  */
 
-static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void scc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct scc_ports *ports = ide_get_hwifdata(hwif);
        unsigned long ctl_base = ports->ctl;
        unsigned long cckctrl_port = ctl_base + 0xff0;
@@ -216,6 +215,7 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio)
        unsigned long pioct_port = ctl_base + 0x004;
        unsigned long reg;
        int offset;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        reg = in_be32((void __iomem *)cckctrl_port);
        if (reg & CCKCTRL_ATACLKOEN) {
index 657f0433ec50459e5217d93dcd6655822ed5621b..a56bc51ae032f0914bec8c24ef60f313121be2ce 100644 (file)
@@ -106,12 +106,13 @@ static u8 svwks_csb_check (struct pci_dev *dev)
        return 0;
 }
 
-static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
        static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
 
-       struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
 
index d95df528562f0db7d1dd0b782954d4a30e7125ef..97266958f744aea2bbb8221628371e1cd0f24b4f 100644 (file)
@@ -229,19 +229,18 @@ static u8 sil_sata_udma_filter(ide_drive_t *drive)
 
 /**
  *     sil_set_pio_mode        -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     Load the timing settings for this device mode into the
  *     controller.
  */
 
-static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
+static void sil_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        static const u16 tf_speed[]   = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 };
        static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 };
 
-       ide_hwif_t *hwif        = drive->hwif;
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        ide_drive_t *pair       = ide_get_pair_dev(drive);
        u32 speedt              = 0;
@@ -249,6 +248,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
        unsigned long addr      = siimage_seldev(drive, 0x04);
        unsigned long tfaddr    = siimage_selreg(hwif,  0x02);
        unsigned long base      = (unsigned long)hwif->hwif_data;
+       const u8 pio            = drive->pio_mode - XFER_PIO_0;
        u8 tf_pio               = pio;
        u8 mmio                 = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
        u8 addr_mask            = hwif->channel ? (mmio ? 0xF4 : 0x84)
index 468706082fb59ffbf89f11a3eaa139f6d52bfc66..5a01920605319faa581ab27ccbe92346f0ad2d95 100644 (file)
@@ -290,10 +290,10 @@ static void config_drive_art_rwp(ide_drive_t *drive)
                pci_write_config_byte(dev, 0x4b, rw_prefetch);
 }
 
-static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void sis_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
        config_drive_art_rwp(drive);
-       sis_program_timings(drive, XFER_PIO_0 + pio);
+       sis_program_timings(drive, drive->pio_mode);
 }
 
 static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode)
index 3c2bbf0057ea594e68d99cd81542d6443443f397..419cd3bc6c84088a3022083dd4701fefef2a8f9c 100644 (file)
@@ -63,12 +63,13 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
 /*
  * Configure the chipset for PIO mode.
  */
-static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void sl82c105_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       struct pci_dev *dev     = to_pci_dev(drive->hwif->dev);
+       struct pci_dev *dev     = to_pci_dev(hwif->dev);
        unsigned long timings   = (unsigned long)ide_get_drivedata(drive);
        int reg                 = 0x44 + drive->dn * 4;
        u16 drv_ctrl;
+       const u8 pio            = drive->pio_mode - XFER_PIO_0;
 
        drv_ctrl = get_pio_timings(drive, pio);
 
index 1ccfb40e721511210527fb5b603c81b2eaa9e0f6..019777522cd20cd2082764e2fcf0e0cf9eed3c3a 100644 (file)
@@ -18,9 +18,8 @@
 
 static DEFINE_SPINLOCK(slc90e66_lock);
 
-static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void slc90e66_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif        = drive->hwif;
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        int is_slave            = drive->dn & 1;
        int master_port         = hwif->channel ? 0x42 : 0x40;
@@ -29,6 +28,8 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
        u16 master_data;
        u8 slave_data;
        int control = 0;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
+
                                     /* ISP  RTC */
        static const u8 timings[][2] = {
                                        { 0, 0 },
@@ -98,7 +99,6 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
                }
        } else {
                const u8 mwdma_to_pio[] = { 0, 3, 4 };
-               u8 pio;
 
                if (reg48 & u_flag)
                        pci_write_config_word(dev, 0x48, reg48 & ~u_flag);
@@ -106,11 +106,12 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
 
                if (speed >= XFER_MW_DMA_0)
-                       pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
+                       drive->pio_mode =
+                               mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
                else
-                       pio = 2; /* only SWDMA2 is allowed */
+                       drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
 
-               slc90e66_set_pio_mode(drive, pio);
+               slc90e66_set_pio_mode(hwif, drive);
        }
 }
 
index 05a93d6baecc60edf3ba587ab26c0947907915aa..f2cb62bf3f22627efc31dced480ec504e9f0a11f 100644 (file)
@@ -41,9 +41,9 @@ static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed)
        outw(scr, scr_port);
 }
 
-static void tc86c001_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void tc86c001_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       tc86c001_set_mode(drive, XFER_PIO_0 + pio);
+       tc86c001_set_mode(drive, drive->pio_mode);
 }
 
 /*
index 8773c3ba7462d9f07dfb5bb7a1b2707e3a437972..d34a7eecdea586702e91574fd0672991a73794cf 100644 (file)
@@ -82,9 +82,9 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed)
        pci_write_config_dword(dev, channel_offset, triflex_timings);
 }
 
-static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void triflex_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       triflex_set_mode(drive, XFER_PIO_0 + pio);
+       triflex_set_mode(drive, drive->pio_mode);
 }
 
 static const struct ide_port_ops triflex_port_ops = {
index fd59c0d235b56cc0ce04a06a2298a0d03b4d4bb0..326d4683488b42942fe38e496539eadf35b3b6e8 100644 (file)
@@ -56,11 +56,10 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
                     &tx4938_ebuscptr->cr[ebus_ch]);
 }
 
-static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void tx4938ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct tx4938ide_platform_info *pdata = hwif->dev->platform_data;
-       u8 safe = pio;
+       u8 safe = drive->pio_mode - XFER_PIO_0;
        ide_drive_t *pair;
 
        pair = ide_get_pair_dev(drive);
index 64b58ecc3f0ea7131d697634e4c848554f5b7e17..5228a4786de5bb0f756bf226f8883d314d62b251 100644 (file)
@@ -104,11 +104,11 @@ static void tx4939ide_writeb(u8 val, void __iomem *base, u32 reg)
 
 #define TX4939IDE_BASE(hwif)   ((void __iomem *)(hwif)->extra_base)
 
-static void tx4939ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void tx4939ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        int is_slave = drive->dn;
        u32 mask, val;
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
        u8 safe = pio;
        ide_drive_t *pair;
 
index 60f936e2319cb3fef78dab4f05096f535ebe5b72..47adcd09cb26a3c6f867374ec31b9aa6dfb039e1 100644 (file)
@@ -104,10 +104,11 @@ static void umc_set_speeds(u8 speeds[])
                speeds[0], speeds[1], speeds[2], speeds[3]);
 }
 
-static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void umc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif, *mate = hwif->mate;
+       ide_hwif_t *mate = hwif->mate;
        unsigned long uninitialized_var(flags);
+       const u8 pio = drive->pio_mode - XFER_PIO_0;
 
        printk("%s: setting umc8672 to PIO mode%d (speed %d)\n",
                drive->name, pio, pio_to_umc[pio]);
index fbecf8ea820772ab5b87fefabed13742e8c01d66..6d995fc9d4f5a7de27c10c7a5885922bc9a4cfff 100644 (file)
@@ -208,15 +208,15 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed)
 
 /**
  *     via_set_pio_mode        -       set host controller for PIO mode
+ *     @hwif: port
  *     @drive: drive
- *     @pio: PIO mode number
  *
  *     A callback from the upper layers for PIO-only tuning.
  */
 
-static void via_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void via_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       via_set_drive(drive, XFER_PIO_0 + pio);
+       via_set_drive(drive, drive->pio_mode);
 }
 
 static struct via_isa_bridge *via_config_find(struct pci_dev **isa)
index 746ef9fdabcb86409f2f46f187433caa8f1d8ea3..803ec306883c31e1ea39bbec9778382087c85e9a 100644 (file)
@@ -624,7 +624,7 @@ extern const struct ide_tp_ops default_tp_ops;
  */
 struct ide_port_ops {
        void    (*init_dev)(ide_drive_t *);
-       void    (*set_pio_mode)(ide_drive_t *, const u8);
+       void    (*set_pio_mode)(struct hwif_s *, ide_drive_t *);
        void    (*set_dma_mode)(ide_drive_t *, const u8);
        int     (*reset_poll)(ide_drive_t *);
        void    (*pre_reset)(ide_drive_t *);