Skip to content

Commit c9d6c1a

Browse files
committed
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>
1 parent 8a97206 commit c9d6c1a

3 files changed

Lines changed: 23 additions & 24 deletions

File tree

‎drivers/ide/ide-lib.c‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -188,29 +188,6 @@ static int ide_scan_pio_blacklist (char *model)
188188
return -1;
189189
}
190190

191-
unsigned 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-
212-
EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
213-
214191
/**
215192
* ide_get_best_pio_mode - get PIO mode from drive
216193
* @drive: drive to consider

‎drivers/ide/ide-timings.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 1999-2001 Vojtech Pavlik
3+
* Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
34
*
45
* This program is free software; you can redistribute it and/or modify
56
* 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)
7576
}
7677
EXPORT_SYMBOL_GPL(ide_timing_find_mode);
7778

79+
u16 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+
}
98+
EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
99+
78100
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
79101
#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
80102

‎include/linux/ide.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ enum {
13001300
};
13011301

13021302
struct ide_timing *ide_timing_find_mode(u8);
1303+
u16 ide_pio_cycle_time(ide_drive_t *, u8);
13031304
void ide_timing_merge(struct ide_timing *, struct ide_timing *,
13041305
struct ide_timing *, unsigned int);
13051306
int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
@@ -1311,7 +1312,6 @@ typedef struct ide_pio_timings_s {
13111312
/* active + recovery (+ setup for some chips) */
13121313
} ide_pio_timings_t;
13131314

1314-
unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
13151315
u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
13161316
extern const ide_pio_timings_t ide_pio_timings[6];
13171317

0 commit comments

Comments
 (0)