Skip to content

Commit

Permalink
alim15x3: fix PIO mode setup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sergei Shtylyov authored and Bartlomiej Zolnierkiewicz committed Mar 3, 2007
1 parent bb648a0 commit 21b8247
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions drivers/ide/pci/alim15x3.c
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 21b8247

Please sign in to comment.