aboutsummaryrefslogtreecommitdiff
path: root/drivers/ide/pci/serverworks.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-06-12 22:34:34 -0400
committerJeff Garzik <jeff@garzik.org>2007-06-12 22:34:34 -0400
commitb232923966f1210e1183353bbd1d52ee53b79fbf (patch)
treee90c72b2cb400af53e1f92aff0af122782d7f65c /drivers/ide/pci/serverworks.c
parentbca1a5518cab2d58c766863c61ee4ef5f1cc4caa (diff)
parent99f9f3d49cbc7d944476f6fde53a77ec789ab2aa (diff)
Merge branch 'master' into upstream-fixes
Diffstat (limited to 'drivers/ide/pci/serverworks.c')
-rw-r--r--drivers/ide/pci/serverworks.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 47bcd91c9b5..d9c4fd1ae99 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -1,5 +1,5 @@
/*
- * linux/drivers/ide/pci/serverworks.c Version 0.9 Mar 4 2007
+ * linux/drivers/ide/pci/serverworks.c Version 0.11 Jun 2 2007
*
* Copyright (C) 1998-2000 Michel Aubry
* Copyright (C) 1998-2000 Andrzej Krzysztofowicz
@@ -170,42 +170,55 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
if (!drive->init_speed) {
u8 dma_stat = inb(hwif->dma_status);
-dma_pio:
if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) {
drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)];
return 0;
} else if ((dma_timing) &&
((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
- u8 dmaspeed = dma_timing;
+ u8 dmaspeed;
- dma_timing &= ~0xFFU;
- if ((dmaspeed & 0x20) == 0x20)
+ switch (dma_timing & 0x77) {
+ case 0x20:
dmaspeed = XFER_MW_DMA_2;
- else if ((dmaspeed & 0x21) == 0x21)
+ break;
+ case 0x21:
dmaspeed = XFER_MW_DMA_1;
- else if ((dmaspeed & 0x77) == 0x77)
+ break;
+ case 0x77:
dmaspeed = XFER_MW_DMA_0;
- else
+ break;
+ default:
goto dma_pio;
+ }
+
drive->current_speed = drive->init_speed = dmaspeed;
return 0;
- } else if (pio_timing) {
- u8 piospeed = pio_timing;
+ }
+dma_pio:
+ if (pio_timing) {
+ u8 piospeed;
- pio_timing &= ~0xFFU;
- if ((piospeed & 0x20) == 0x20)
+ switch (pio_timing & 0x7f) {
+ case 0x20:
piospeed = XFER_PIO_4;
- else if ((piospeed & 0x22) == 0x22)
+ break;
+ case 0x22:
piospeed = XFER_PIO_3;
- else if ((piospeed & 0x34) == 0x34)
+ break;
+ case 0x34:
piospeed = XFER_PIO_2;
- else if ((piospeed & 0x47) == 0x47)
+ break;
+ case 0x47:
piospeed = XFER_PIO_1;
- else if ((piospeed & 0x5d) == 0x5d)
+ break;
+ case 0x5d:
piospeed = XFER_PIO_0;
- else
+ break;
+ default:
goto oem_setup_failed;
+ }
+
drive->current_speed = drive->init_speed = piospeed;
return 0;
}
@@ -214,8 +227,8 @@ dma_pio:
oem_setup_failed:
- pio_timing &= ~0xFFU;
- dma_timing &= ~0xFFU;
+ pio_timing = 0;
+ dma_timing = 0;
ultra_timing &= ~(0x0F << (4*unit));
ultra_enable &= ~(0x01 << drive->dn);
csb5_pio &= ~(0x0F << (4*drive->dn));