]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
alim15x3: fix PIO mode setup
authorSergei Shtylyov <sshtylyov@ru.mvista.com>
Sat, 3 Mar 2007 16:48:52 +0000 (17:48 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 3 Mar 2007 16:48:52 +0000 (17:48 +0100)
The driver's tuneproc() method fails to set the drive's own speed -- fix this
by renaming the function to ali15x3_tune_pio() and "wrapping" the new tuneproc()
method around it and making it return the mode set, update the heading comment.

Also, setting PIO mode via the speedproc() method does not work due to passing
to the tuneproc() method's a mode number not biased by XFER_PIO_0 -- fix this
along with a typo in the heading comment...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/pci/alim15x3.c

index 4debd18d52f83da057dc1e73922d196a442ce2d5..83e0aa65a4316e8c6b74f4d35373dc8b0f0c3a7c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/alim15x3.c            Version 0.17    2003/01/02
+ * linux/drivers/ide/pci/alim15x3.c            Version 0.21    2007/02/03
  *
  *  Copyright (C) 1998-2000 Michel Aubry, Maintainer
  *  Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer
@@ -9,6 +9,7 @@
  *  May be copied or modified under the terms of the GNU General Public License
  *  Copyright (C) 2002 Alan Cox <alan@redhat.com>
  *  ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw>
+ *  Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
  *
  *  (U)DMA capable version of ali 1533/1543(C), 1535(D)
  *
@@ -280,15 +281,17 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count)
 #endif  /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) */
 
 /**
- *     ali15x3_tune_drive      -       set up a drive
+ *     ali15x3_tune_pio        -       set up chipset for PIO mode
  *     @drive: drive to tune
- *     @pio: unused
+ *     @pio: desired mode
  *
- *     Select the best PIO timing for the drive in question. Then
- *     program the controller for this drive set up
+ *     Select the best PIO mode for the drive in question.
+ *     Then program the controller for this mode.
+ *
+ *     Returns the PIO mode programmed.
  */
  
-static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
+static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
 {
        ide_pio_data_t d;
        ide_hwif_t *hwif = HWIF(drive);
@@ -356,6 +359,22 @@ static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
         * { 20,   50,     30  }    PIO Mode 5 with IORDY (nonstandard)
         */
 
+       return pio;
+}
+
+/**
+ *     ali15x3_tune_drive      -       set up drive for PIO mode
+ *     @drive: drive to tune
+ *     @pio: desired mode
+ *
+ *     Program the controller with the best PIO timing for the given drive.
+ *     Then set up the drive itself.
+ */
+
+static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
+{
+       pio = ali15x3_tune_pio(drive, pio);
+       (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
 }
 
 /**
@@ -430,7 +449,7 @@ static u8 ali15x3_ratemask (ide_drive_t *drive)
 }
 
 /**
- *     ali15x3_tune_chipset    -       set up chiset for new speed
+ *     ali15x3_tune_chipset    -       set up chipset/drive for new speed
  *     @drive: drive to configure for
  *     @xferspeed: desired speed
  *
@@ -461,7 +480,7 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                pci_write_config_byte(dev, m5229_udma, tmpbyte);
 
                if (speed < XFER_SW_DMA_0)
-                       ali15x3_tune_drive(drive, speed);
+                       (void) ali15x3_tune_pio(drive, speed - XFER_PIO_0);
        } else {
                pci_read_config_byte(dev, m5229_udma, &tmpbyte);
                tmpbyte &= (0x0f << ((1-unit) << 2));