aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-16 14:33:39 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-16 14:33:39 -0400
commitc9d6c1a2379373219bb3271bdcbdc0ab2edf349d (patch)
tree9807c4ff5c92df9fd914c39db6bdd0179ecb1b27 /drivers/ide
parent8a97206e31dc2e2f8f9b4d97e234b5c701fe9894 (diff)
ide: move ide_pio_cycle_time() to ide-timings.c
All ide_pio_cycle_time() users already select CONFIG_IDE_TIMINGS so move the function from ide-lib.c to ide-timings.c. While at it: - convert ide_pio_cycle_time() to use ide_timing_find_mode() - cleanup ide_pio_cycle_time() a bit There should be no functional changes caused by this patch. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-lib.c23
-rw-r--r--drivers/ide/ide-timings.c22
2 files changed, 22 insertions, 23 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 7e053d217732..efa5bfa64d01 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -188,29 +188,6 @@ static int ide_scan_pio_blacklist (char *model)
188 return -1; 188 return -1;
189} 189}
190 190
191unsigned int ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
192{
193 struct hd_driveid *id = drive->id;
194 int cycle_time = 0;
195
196 if (id->field_valid & 2) {
197 if (id->capability & 8)
198 cycle_time = id->eide_pio_iordy;
199 else
200 cycle_time = id->eide_pio;
201 }
202
203 /* conservative "downgrade" for all pre-ATA2 drives */
204 if (pio < 3) {
205 if (cycle_time && cycle_time < ide_pio_timings[pio].cycle_time)
206 cycle_time = 0; /* use standard timing */
207 }
208
209 return cycle_time ? cycle_time : ide_pio_timings[pio].cycle_time;
210}
211
212EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
213
214/** 191/**
215 * ide_get_best_pio_mode - get PIO mode from drive 192 * ide_get_best_pio_mode - get PIO mode from drive
216 * @drive: drive to consider 193 * @drive: drive to consider
diff --git a/drivers/ide/ide-timings.c b/drivers/ide/ide-timings.c
index ebef6d4e3f63..8c2f8327f487 100644
--- a/drivers/ide/ide-timings.c
+++ b/drivers/ide/ide-timings.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 1999-2001 Vojtech Pavlik 2 * Copyright (c) 1999-2001 Vojtech Pavlik
3 * Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -75,6 +76,27 @@ struct ide_timing *ide_timing_find_mode(u8 speed)
75} 76}
76EXPORT_SYMBOL_GPL(ide_timing_find_mode); 77EXPORT_SYMBOL_GPL(ide_timing_find_mode);
77 78
79u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
80{
81 struct hd_driveid *id = drive->id;
82 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
83 u16 cycle = 0;
84
85 if (id->field_valid & 2) {
86 if (id->capability & 8)
87 cycle = id->eide_pio_iordy;
88 else
89 cycle = id->eide_pio;
90
91 /* conservative "downgrade" for all pre-ATA2 drives */
92 if (pio < 3 && cycle < t->cycle)
93 cycle = 0; /* use standard timing */
94 }
95
96 return cycle ? cycle : t->cycle;
97}
98EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
99
78#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1) 100#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
79#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0) 101#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
80 102