From 7dd00083b1160b560fa2a0a486799b57baa5d035 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 20 Jul 2007 01:11:56 +0200 Subject: ide: add ide_pio_cycle_time() helper (take 2) * Add ide_pio_cycle_time() helper. * Use it in ali14xx/ht6560b/qd65xx/cmd64{0,x}/sl82c105 and pmac host drivers (previously cycle time given by the device was only used for "pio" == 255). * Remove no longer needed ide_pio_data_t.cycle_time field. v2: * Fix "ata_" prefix (Noticed by Jeff). Acked-by: Sergei Shtylyov Cc: Jeff Garzik Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/cmd640.c | 12 +++++------- drivers/ide/pci/cmd64x.c | 10 ++++++---- drivers/ide/pci/sl82c105.c | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers/ide/pci') diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index dff21597e64..9f67ffc4342 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c @@ -633,9 +633,8 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle */ static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted) { + unsigned int index = 0, cycle_time; u8 b; - ide_pio_data_t d; - unsigned int index = 0; while (drive != cmd_drives[index]) { if (++index > 3) { @@ -662,13 +661,12 @@ static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted) return; } - (void) ide_get_best_pio_mode (drive, mode_wanted, 5, &d); - cmd640_set_mode (index, d.pio_mode, d.cycle_time); + mode_wanted = ide_get_best_pio_mode(drive, mode_wanted, 5, NULL); + cycle_time = ide_pio_cycle_time(drive, mode_wanted); + cmd640_set_mode(index, mode_wanted, cycle_time); printk("%s: selected cmd640 PIO mode%d (%dns)", - drive->name, - d.pio_mode, - d.cycle_time); + drive->name, mode_wanted, cycle_time); display_clocks(index); } diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 8150a023dd7..c383f6dc67d 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -221,16 +221,18 @@ static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted) { ide_hwif_t *hwif = HWIF(drive); struct pci_dev *dev = hwif->pci_dev; - ide_pio_data_t pio; + unsigned int cycle_time; u8 pio_mode, setup_count, arttim = 0; static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; - pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &pio); + + pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, NULL); + cycle_time = ide_pio_cycle_time(drive, pio_mode); cmdprintk("%s: PIO mode wanted %d, selected %d (%d ns)\n", - drive->name, mode_wanted, pio_mode, pio.cycle_time); + drive->name, mode_wanted, pio_mode, cycle_time); - program_cycle_times(drive, pio.cycle_time, + program_cycle_times(drive, cycle_time, ide_pio_timings[pio_mode].active_time); setup_count = quantize_timing(ide_pio_timings[pio_mode].setup_time, diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index f4637d29aaf..cc5f69b7514 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c @@ -52,13 +52,13 @@ * Convert a PIO mode and cycle time to the required on/off times * for the interface. This has protection against runaway timings. */ -static unsigned int get_pio_timings(ide_drive_t *drive, ide_pio_data_t *p) +static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) { unsigned int cmd_on, cmd_off; u8 iordy = 0; - cmd_on = (ide_pio_timings[p->pio_mode].active_time + 29) / 30; - cmd_off = (p->cycle_time - 30 * cmd_on + 29) / 30; + cmd_on = (ide_pio_timings[pio].active_time + 29) / 30; + cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30; if (cmd_on == 0) cmd_on = 1; @@ -66,7 +66,7 @@ static unsigned int get_pio_timings(ide_drive_t *drive, ide_pio_data_t *p) if (cmd_off == 0) cmd_off = 1; - if (p->pio_mode > 2 || ide_dev_has_iordy(drive->id)) + if (pio > 2 || ide_dev_has_iordy(drive->id)) iordy = 0x40; return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy; @@ -79,14 +79,13 @@ static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio) { struct pci_dev *dev = HWIF(drive)->pci_dev; int reg = 0x44 + drive->dn * 4; - ide_pio_data_t p; u16 drv_ctrl; DBG(("sl82c105_tune_pio(drive:%s, pio:%u)\n", drive->name, pio)); - pio = ide_get_best_pio_mode(drive, pio, 5, &p); + pio = ide_get_best_pio_mode(drive, pio, 5, NULL); - drv_ctrl = get_pio_timings(drive, &p); + drv_ctrl = get_pio_timings(drive, pio); /* * Store the PIO timings so that we can restore them @@ -105,7 +104,8 @@ static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio) } printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name, - ide_xfer_verbose(pio + XFER_PIO_0), p.cycle_time, drv_ctrl); + ide_xfer_verbose(pio + XFER_PIO_0), + ide_pio_cycle_time(drive, pio), drv_ctrl); return pio; } -- cgit v1.2.3