[PATCH 19/21] ide: move ide_pio_cycle_time() to ide-timings.c

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-ide@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-kernel@...>
Date: Wednesday, May 28, 2008 - 5:43 pm

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.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-lib.c     |   23 -----------------------
 drivers/ide/ide-timings.c |   22 ++++++++++++++++++++++
 include/linux/ide.h       |    2 +-
 3 files changed, 23 insertions(+), 24 deletions(-)

Index: b/drivers/ide/ide-lib.c
===================================================================
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -188,29 +188,6 @@ static int ide_scan_pio_blacklist (char 
 	return -1;
 }
 
-unsigned int ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
-{
-	struct hd_driveid *id = drive->id;
-	int cycle_time = 0;
-
-	if (id->field_valid & 2) {
-		if (id->capability & 8)
-			cycle_time = id->eide_pio_iordy;
-		else
-			cycle_time = id->eide_pio;
-	}
-
-	/* conservative "downgrade" for all pre-ATA2 drives */
-	if (pio < 3) {
-		if (cycle_time && cycle_time < ide_pio_timings[pio].cycle_time)
-			cycle_time = 0; /* use standard timing */
-	}
-
-	return cycle_time ? cycle_time : ide_pio_timings[pio].cycle_time;
-}
-
-EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
-
 /**
  *	ide_get_best_pio_mode	-	get PIO mode from drive
  *	@drive: drive to consider
Index: b/drivers/ide/ide-timings.c
===================================================================
--- a/drivers/ide/ide-timings.c
+++ b/drivers/ide/ide-timings.c
@@ -1,5 +1,6 @@
 /*
  *  Copyright (c) 1999-2001 Vojtech Pavlik
+ *  Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -73,6 +74,27 @@ struct ide_timing *ide_timing_find_mode(
 	return t;
 }
 
+u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
+{
+	struct hd_driveid *id = drive->id;
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
+	u16 cycle = 0;
+
+	if (id->field_valid & 2) {
+		if (id->capability & 8)
+			cycle = id->eide_pio_iordy;
+		else
+			cycle = id->eide_pio;
+
+		/* conservative "downgrade" for all pre-ATA2 drives */
+		if (pio < 3 && cycle < t->cycle)
+			cycle = 0; /* use standard timing */
+	}
+
+	return cycle ? cycle : t->cycle;
+}
+EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
+
 #define ENOUGH(v, unit)		(((v) - 1) / (unit) + 1)
 #define EZ(v, unit)		((v) ? ENOUGH(v, unit) : 0)
 
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1285,6 +1285,7 @@ enum {
 };
 
 struct ide_timing *ide_timing_find_mode(u8);
+u16 ide_pio_cycle_time(ide_drive_t *, u8);
 void ide_timing_merge(struct ide_timing *, struct ide_timing *,
 		      struct ide_timing *, unsigned int);
 int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
@@ -1296,7 +1297,6 @@ typedef struct ide_pio_timings_s {
 				/* active + recovery (+ setup for some chips) */
 } ide_pio_timings_t;
 
-unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
 u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
 extern const ide_pio_timings_t ide_pio_timings[6];
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/21] ide: convert ide-timing.h to ide-timings.c lib..., Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:39 pm)
[PATCH 20/21] ide: remove no longer used ide_pio_timings[], Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:43 pm)
[PATCH 21/21] ide: move PIO blacklist to ide-pio-blacklist.c, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:43 pm)
[PATCH 19/21] ide: move ide_pio_cycle_time() to ide-timings.c, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:43 pm)
[PATCH 18/21] ide-pmac: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:43 pm)
[PATCH 17/21] ide-mpc8xx: convert to use ide_timing_find_mod..., Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:43 pm)
[PATCH 16/21] sl82c105: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 15/21] opti621: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 14/21] cy82c693: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 13/21] cmd64x: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 12/21] cmd640: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 11/21] alim15x3: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 10/21] qd65xx: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:42 pm)
[PATCH 09/21] ht6560b: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:41 pm)
[PATCH 08/21] ali14xx: convert to use ide_timing_find_mode(), Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
[PATCH 07/21] ide: convert ide-timing.h to ide-timings.c lib..., Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
[PATCH 06/21] ide: checkpatch.pl fixes for ide-timing.h, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
Re: [PATCH 06/21] ide: checkpatch.pl fixes for ide-timing.h, Sergei Shtylyov, (Fri May 30, 7:46 am)
[PATCH 05/21] ide: remove XFER_* masks from ide-timing.h, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
Re: [PATCH 05/21] ide: remove XFER_* masks from ide-timing.h, Sergei Shtylyov, (Fri May 30, 7:46 am)
[PATCH 04/21] ide: move some bits from ide-timing.h to &lt;l..., Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
[PATCH 03/21] ide: use u8 for xfer modes in ide-timing.h, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
[PATCH 02/21] ide: remove unused XFER_UDMA_SLOW, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:40 pm)
Re: [PATCH 02/21] ide: remove unused XFER_UDMA_SLOW, Sergei Shtylyov, (Mon Jun 2, 7:43 am)
[PATCH 01/21] ide: remove needless includes from ide-lib.c, Bartlomiej Zolnierkiewicz..., (Wed May 28, 5:39 pm)