Skip to contentSkip to conversation

ide: convert ide-timing.h to ide-timings.c library

PATCH In review Bartlomiej Zolnierkiewicz 2 participants 40 messages May 28, 2008 – Jun 2, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ide: convert ide-timing.h to ide-timings.c library

This (fairly obvious/trivial) patchset converts drivers/ide/ide-timing.h into ide-timings.c library (enabled by host drivers that want to use it by selecting CONFIG_IDE_TIMINGS config option) and updates host drivers still using ide_pio_timings[] to use ide_timing_find_mode() instead.

Also as a bonus it moves PIO blacklist from ide-lib.c to ide-pio-blacklist.c.

diffstat:

 drivers/ide/Kconfig             |   16 +
 drivers/ide/Makefile            |    4 
 drivers/ide/arm/palm_bk3710.c   |    2 
 drivers/ide/ide-lib.c           |  151 -----------------
 drivers/ide/ide-pio-blacklist.c |   94 +++++++++++
 drivers/ide/ide-timing.h        |  341 +++++++---------------------------------
 drivers/ide/ide-timings.c       |  201 +++++++++++++++++++++++
 drivers/ide/legacy/ali14xx.c    |    3 
 drivers/ide/legacy/ht6560b.c    |    7 
 drivers/ide/legacy/qd65xx.c     |    3 
 drivers/ide/pci/alim15x3.c      |    6 
 drivers/ide/pci/amd74xx.c       |    2 
 drivers/ide/pci/cmd640.c        |    8 
 drivers/ide/pci/cmd64x.c        |    6 
 drivers/ide/pci/cs5535.c        |    6 
 drivers/ide/pci/cy82c693.c      |    9 -
 drivers/ide/pci/opti621.c       |   10 -
 drivers/ide/pci/sis5513.c       |    3 
 drivers/ide/pci/sl82c105.c      |    3 
 drivers/ide/pci/via82cxxx.c     |    2 
 drivers/ide/ppc/mpc8xx.c        |   33 +--
 drivers/ide/ppc/pmac.c          |   15 -
 include/linux/ide.h             |   45 ++++-
 23 files changed, 461 insertions(+), 509 deletions(-)
#1 lore raw

PATCH 1/21 ide: remove needless includes from ide-lib.c

---
 drivers/ide/ide-lib.c |   15 ---------------
 1 file changed, 15 deletions(-)
drivers/ide/ide-lib.c +0 -15
Index: b/drivers/ide/ide-lib.c
===================================================================
@@ -1,26 +1,11 @@
-#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
 #include <linux/interrupt.h>
-#include <linux/major.h>
-#include <linux/errno.h>
-#include <linux/genhd.h>
-#include <linux/blkpg.h>
-#include <linux/slab.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/bitops.h>
 
-#include <asm/byteorder.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
 static const char *udma_str[] =
 	 { "UDMA/16", "UDMA/25",  "UDMA/33",  "UDMA/44",
 	   "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };
#2 lore raw

PATCH 2/21 ide: remove unused XFER_UDMA_SLOW

In reply to Bartlomiej Zolnierkiewicz

Remove unused XFER_UDMA_SLOW from ide_timing[].

While at it:

- fix re-defining XFER_PIO_5 (no need to define it in ide-timing.h as it is defined in <linux/ata.h> which is included by <linux/hdreg.h>)

- fix whitespace damage

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-timing.h |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/ide/ide-timing.h +1 -6
Index: b/drivers/ide/ide-timing.h
===================================================================
@@ -28,9 +28,6 @@
 #include <linux/kernel.h>
 #include <linux/hdreg.h>
 
-#define XFER_PIO_5		0x0d
-#define XFER_UDMA_SLOW		0x4f
-
 struct ide_timing {
 	short mode;
 	short setup;	/* t1 */
@@ -61,12 +58,10 @@ static struct ide_timing ide_timing[] = 
 	{ XFER_UDMA_1,     0,   0,   0,   0,   0,   0,   0,  80 },
 	{ XFER_UDMA_0,     0,   0,   0,   0,   0,   0,   0, 120 },
 
-	{ XFER_UDMA_SLOW,  0,   0,   0,   0,   0,   0,   0, 150 },
-                                          
 	{ XFER_MW_DMA_2,  25,   0,   0,   0,  70,  25, 120,   0 },
 	{ XFER_MW_DMA_1,  45,   0,   0,   0,  80,  50, 150,   0 },
 	{ XFER_MW_DMA_0,  60,   0,   0,   0, 215, 215, 480,   0 },
-                                          
+
 	{ XFER_SW_DMA_2,  60,   0,   0,   0, 120, 120, 240,   0 },
 	{ XFER_SW_DMA_1,  90,   0,   0,   0, 240, 240, 480,   0 },
 	{ XFER_SW_DMA_0, 120,   0,   0,   0, 480, 480, 960,   0 },
Acked-by on v1 2/21
#3 lore raw

Re: [PATCH 02/21] ide: remove unused XFER_UDMA_SLOW

Quoted 4 lines · Bartlomiej Zolnierkiewicz

Remove unused XFER_UDMA_SLOW from ide_timing[].

While at it:

Quoted 8 lines

- fix re-defining XFER_PIO_5 (no need to define it in ide-timing.h as it is defined in <linux/ata.h> which is included by <linux/hdreg.h>)

- fix whitespace damage

There should be no functional changes caused by this patch.

MBR, Sergei

#4 lore raw

PATCH 3/21 ide: use u8 for xfer modes in ide-timing.h

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-timing.h |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/ide/ide-timing.h +6 -5
Index: b/drivers/ide/ide-timing.h
===================================================================
@@ -29,7 +29,7 @@
 #include <linux/hdreg.h>
 
 struct ide_timing {
-	short mode;
+	u8    mode;
 	short setup;	/* t1 */
 	short act8b;	/* t2 for 8-bit io */
 	short rec8b;	/* t2i for 8-bit io */
@@ -76,7 +76,7 @@ static struct ide_timing ide_timing[] = 
 
 	{ XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960,   0 },
 
-	{ -1 }
+	{ 0xff }
 };
 
 #define IDE_TIMING_SETUP	0x01
@@ -122,17 +122,18 @@ static void ide_timing_merge(struct ide_
 	if (what & IDE_TIMING_UDMA   ) m->udma    = max(a->udma,    b->udma);
 }
 
-static struct ide_timing* ide_timing_find_mode(short speed)
+static struct ide_timing *ide_timing_find_mode(u8 speed)
 {
 	struct ide_timing *t;
 
 	for (t = ide_timing; t->mode != speed; t++)
-		if (t->mode < 0)
+		if (t->mode == 0xff)
 			return NULL;
 	return t; 
 }
 
-static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing *t, int T, int UT)
+static int ide_timing_compute(ide_drive_t *drive, u8 speed,
+			      struct ide_timing *t, int T, int UT)
 {
 	struct hd_driveid *id = drive->id;
 	struct ide_timing *s, p;
#6 lore raw

PATCH 4/21 ide: move some bits from ide-timing.h to <linux/ide.h>

In reply to Bartlomiej Zolnierkiewicz

Move struct ide_timing and IDE_TIMING_* defines to <linux/ide.h> from drivers/ide/ide-timing.h.

While at it:

- use u8/u16 instead of short for struct ide_timing fields

- use enum for IDE_TIMING_*

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-timing.h |   23 -----------------------
 include/linux/ide.h      |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 23 deletions(-)
drivers/ide/ide-timing.h +0 -23
Index: b/drivers/ide/ide-timing.h
===================================================================
@@ -28,18 +28,6 @@
 #include <linux/kernel.h>
 #include <linux/hdreg.h>
 
-struct ide_timing {
-	u8    mode;
-	short setup;	/* t1 */
-	short act8b;	/* t2 for 8-bit io */
-	short rec8b;	/* t2i for 8-bit io */
-	short cyc8b;	/* t0 for 8-bit io */
-	short active;	/* t2 or tD */
-	short recover;	/* t2i or tK */
-	short cycle;	/* t0 */
-	short udma;	/* t2CYCTYP/2 */
-};
-
 /*
  * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
  * These were taken from ATA/ATAPI-6 standard, rev 0a, except
@@ -79,17 +67,6 @@ static struct ide_timing ide_timing[] = 
 	{ 0xff }
 };
 
-#define IDE_TIMING_SETUP	0x01
-#define IDE_TIMING_ACT8B	0x02
-#define IDE_TIMING_REC8B	0x04
-#define IDE_TIMING_CYC8B	0x08
-#define IDE_TIMING_8BIT		0x0e
-#define IDE_TIMING_ACTIVE	0x10
-#define IDE_TIMING_RECOVER	0x20
-#define IDE_TIMING_CYCLE	0x40
-#define IDE_TIMING_UDMA		0x80
-#define IDE_TIMING_ALL		0xff
-
 #define ENOUGH(v,unit)		(((v)-1)/(unit)+1)
 #define EZ(v,unit)		((v)?ENOUGH(v,unit):0)
 
include/linux/ide.h +28 -0
Index: b/include/linux/ide.h
===================================================================
@@ -1256,6 +1256,34 @@ static inline int ide_dev_is_sata(struct
 u64 ide_get_lba_addr(struct ide_taskfile *, int);
 u8 ide_dump_status(ide_drive_t *, const char *, u8);
 
+struct ide_timing {
+	u8  mode;
+	u8  setup;	/* t1 */
+	u16 act8b;	/* t2 for 8-bit io */
+	u16 rec8b;	/* t2i for 8-bit io */
+	u16 cyc8b;	/* t0 for 8-bit io */
+	u16 active;	/* t2 or tD */
+	u16 recover;	/* t2i or tK */
+	u16 cycle;	/* t0 */
+	u16 udma;	/* t2CYCTYP/2 */
+};
+
+enum {
+	IDE_TIMING_SETUP	= (1 << 0),
+	IDE_TIMING_ACT8B	= (1 << 1),
+	IDE_TIMING_REC8B	= (1 << 2),
+	IDE_TIMING_CYC8B	= (1 << 3),
+	IDE_TIMING_8BIT		= IDE_TIMING_ACT8B | IDE_TIMING_REC8B |
+				  IDE_TIMING_CYC8B,
+	IDE_TIMING_ACTIVE	= (1 << 4),
+	IDE_TIMING_RECOVER	= (1 << 5),
+	IDE_TIMING_CYCLE	= (1 << 6),
+	IDE_TIMING_UDMA		= (1 << 7),
+	IDE_TIMING_ALL		= IDE_TIMING_SETUP | IDE_TIMING_8BIT |
+				  IDE_TIMING_ACTIVE | IDE_TIMING_RECOVER |
+				  IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
+};
+
 typedef struct ide_pio_timings_s {
 	int	setup_time;	/* Address setup (ns) minimum */
 	int	active_time;	/* Active pulse (ns) minimum */
Acked-by on v1 4/21
#7 lore raw

Re: [PATCH 04/21] ide: move some bits from ide-timing.h to <linux/ide.h>

Hello.

Quoted 5 lines · Bartlomiej Zolnierkiewicz

Move struct ide_timing and IDE_TIMING_* defines to <linux/ide.h> from drivers/ide/ide-timing.h.

While at it:

Quoted 7 lines

- use u8/u16 instead of short for struct ide_timing fields

- use enum for IDE_TIMING_*

There should be no functional changes caused by this patch.

MBR, Sergei

#8 lore raw

PATCH 5/21 ide: remove XFER_* masks from ide-timing.h

In reply to Bartlomiej Zolnierkiewicz

* Check requested xfer mode against xfer modes instead of XFER_* masks in ide_timing_compute() and cs5535.c::cs5535_set_speed().

* Remove XFER_[MODE,MWDMA,EPIO,PIO] masks.

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-timing.h |   24 +++++++-----------------
 drivers/ide/pci/cs5535.c |    4 +---
 2 files changed, 8 insertions(+), 20 deletions(-)
drivers/ide/ide-timing.h +7 -17
Index: b/drivers/ide/ide-timing.h
===================================================================
@@ -70,11 +70,6 @@ static struct ide_timing ide_timing[] = 
 #define ENOUGH(v,unit)		(((v)-1)/(unit)+1)
 #define EZ(v,unit)		((v)?ENOUGH(v,unit):0)
 
-#define XFER_MODE	0xf0
-#define XFER_MWDMA	0x20
-#define XFER_EPIO	0x01
-#define XFER_PIO	0x00
-
 static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
 {
 	q->setup   = EZ(t->setup   * 1000,  T);
@@ -137,17 +132,12 @@ static int ide_timing_compute(ide_drive_
 
 		memset(&p, 0, sizeof(p));
 
-		switch (speed & XFER_MODE) {
-
-			case XFER_PIO:
-				if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = id->eide_pio;
-						    else p.cycle = p.cyc8b = id->eide_pio_iordy;
-				break;
-
-			case XFER_MWDMA:
-				p.cycle = id->eide_dma_min;
-				break;
-		}
+		if (speed <= XFER_PIO_2)
+			p.cycle = p.cyc8b = id->eide_pio;
+		else if (speed <= XFER_PIO_5)
+			p.cycle = p.cyc8b = id->eide_pio_iordy;
+		else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
+			p.cycle = id->eide_dma_min;
 
 		ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B);
 	}
@@ -164,7 +154,7 @@ static int ide_timing_compute(ide_drive_
  * slower/equal than the fastest PIO timing.
  */
 
-	if ((speed & XFER_MODE) != XFER_PIO) {
+	if (speed >= XFER_SW_DMA_0) {
 		u8 pio = ide_get_best_pio_mode(drive, 255, 5);
 		ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
 		ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
drivers/ide/pci/cs5535.c +1 -3
Index: b/drivers/ide/pci/cs5535.c
===================================================================
@@ -75,13 +75,11 @@ static unsigned int cs5535_udma_timings[
  */
 static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)
 {
-
 	u32 reg = 0, dummy;
 	int unit = drive->select.b.unit;
 
-
 	/* Set the PIO timings */
-	if ((speed & XFER_MODE) == XFER_PIO) {
+	if (speed < XFER_SW_DMA_0) {
 		ide_drive_t *pair = ide_get_paired_drive(drive);
 		u8 cmd, pioa;
 
Acked-by on v1 5/21
#9 lore raw

Re: [PATCH 05/21] ide: remove XFER_* masks from ide-timing.h

Quoted 8 lines · Bartlomiej Zolnierkiewicz

* Check requested xfer mode against xfer modes instead of XFER_* masks in ide_timing_compute() and cs5535.c::cs5535_set_speed().

* Remove XFER_[MODE,MWDMA,EPIO,PIO] masks.

There should be no functional changes caused by this patch.

MBR, Sergei

#10 lore raw

PATCH 6/21 ide: checkpatch.pl fixes for ide-timing.h

In reply to Bartlomiej Zolnierkiewicz

Also fix placement of comments in ide_timing_compute() while at it.

There should be no functional changes caused by this patch (md5sum was verified to be the same before/after the patch).

---
 drivers/ide/ide-timing.h |   93 ++++++++++++++++++++++++-----------------------
 1 file changed, 48 insertions(+), 45 deletions(-)
drivers/ide/ide-timing.h +48 -45
Index: b/drivers/ide/ide-timing.h
===================================================================
@@ -3,9 +3,7 @@
 
 /*
  *  Copyright (c) 1999-2001 Vojtech Pavlik
- */
-
-/*
+ *
  * 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
  * the Free Software Foundation; either version 2 of the License, or
@@ -32,7 +30,7 @@
  * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
  * These were taken from ATA/ATAPI-6 standard, rev 0a, except
  * for PIO 5, which is a nonstandard extension and UDMA6, which
- * is currently supported only by Maxtor drives. 
+ * is currently supported only by Maxtor drives.
  */
 
 static struct ide_timing ide_timing[] = {
@@ -67,10 +65,11 @@ static struct ide_timing ide_timing[] = 
 	{ 0xff }
 };
 
-#define ENOUGH(v,unit)		(((v)-1)/(unit)+1)
-#define EZ(v,unit)		((v)?ENOUGH(v,unit):0)
+#define ENOUGH(v, unit)		(((v) - 1) / (unit) + 1)
+#define EZ(v, unit)		((v) ? ENOUGH(v, unit) : 0)
 
-static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
+static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
+				int T, int UT)
 {
 	q->setup   = EZ(t->setup   * 1000,  T);
 	q->act8b   = EZ(t->act8b   * 1000,  T);
@@ -82,16 +81,25 @@ static void ide_timing_quantize(struct i
 	q->udma    = EZ(t->udma    * 1000, UT);
 }
 
-static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what)
+static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
+			     struct ide_timing *m, unsigned int what)
 {
-	if (what & IDE_TIMING_SETUP  ) m->setup   = max(a->setup,   b->setup);
-	if (what & IDE_TIMING_ACT8B  ) m->act8b   = max(a->act8b,   b->act8b);
-	if (what & IDE_TIMING_REC8B  ) m->rec8b   = max(a->rec8b,   b->rec8b);
-	if (what & IDE_TIMING_CYC8B  ) m->cyc8b   = max(a->cyc8b,   b->cyc8b);
-	if (what & IDE_TIMING_ACTIVE ) m->active  = max(a->active,  b->active);
-	if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
-	if (what & IDE_TIMING_CYCLE  ) m->cycle   = max(a->cycle,   b->cycle);
-	if (what & IDE_TIMING_UDMA   ) m->udma    = max(a->udma,    b->udma);
+	if (what & IDE_TIMING_SETUP)
+		m->setup   = max(a->setup,   b->setup);
+	if (what & IDE_TIMING_ACT8B)
+		m->act8b   = max(a->act8b,   b->act8b);
+	if (what & IDE_TIMING_REC8B)
+		m->rec8b   = max(a->rec8b,   b->rec8b);
+	if (what & IDE_TIMING_CYC8B)
+		m->cyc8b   = max(a->cyc8b,   b->cyc8b);
+	if (what & IDE_TIMING_ACTIVE)
+		m->active  = max(a->active,  b->active);
+	if (what & IDE_TIMING_RECOVER)
+		m->recover = max(a->recover, b->recover);
+	if (what & IDE_TIMING_CYCLE)
+		m->cycle   = max(a->cycle,   b->cycle);
+	if (what & IDE_TIMING_UDMA)
+		m->udma    = max(a->udma,    b->udma);
 }
 
 static struct ide_timing *ide_timing_find_mode(u8 speed)
@@ -101,7 +109,7 @@ static struct ide_timing *ide_timing_fin
 	for (t = ide_timing; t->mode != speed; t++)
 		if (t->mode == 0xff)
 			return NULL;
-	return t; 
+	return t;
 }
 
 static int ide_timing_compute(ide_drive_t *drive, u8 speed,
@@ -110,24 +118,22 @@ static int ide_timing_compute(ide_drive_
 	struct hd_driveid *id = drive->id;
 	struct ide_timing *s, p;
 
-/*
- * Find the mode.
- */
-
-	if (!(s = ide_timing_find_mode(speed)))
+	/*
+	 * Find the mode.
+	 */
+	s = ide_timing_find_mode(speed);
+	if (s == NULL)
 		return -EINVAL;
 
-/*
- * Copy the timing from the table.
- */
-
+	/*
+	 * Copy the timing from the table.
+	 */
 	*t = *s;
 
-/*
- * If the drive is an EIDE drive, it can tell us it needs extended
- * PIO/MWDMA cycle timing.
- */
-
+	/*
+	 * If the drive is an EIDE drive, it can tell us it needs extended
+	 * PIO/MWDMA cycle timing.
+	 */
 	if (id && id->field_valid & 2) {	/* EIDE drive */
 
 		memset(&p, 0, sizeof(p));
@@ -142,28 +148,25 @@ static int ide_timing_compute(ide_drive_
 		ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B);
 	}
 
-/*
- * Convert the timing to bus clock counts.
- */
-
+	/*
+	 * Convert the timing to bus clock counts.
+	 */
 	ide_timing_quantize(t, t, T, UT);
 
-/*
- * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
- * and some other commands. We have to ensure that the DMA cycle timing is
- * slower/equal than the fastest PIO timing.
- */
-
+	/*
+	 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY,
+	 * S.M.A.R.T and some other commands. We have to ensure that the
+	 * DMA cycle timing is slower/equal than the fastest PIO timing.
+	 */
 	if (speed >= XFER_SW_DMA_0) {
 		u8 pio = ide_get_best_pio_mode(drive, 255, 5);
 		ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
 		ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
 	}
 
-/*
- * Lengthen active & recovery time so that cycle time is correct.
- */
-
+	/*
+	 * Lengthen active & recovery time so that cycle time is correct.
+	 */
 	if (t->act8b + t->rec8b < t->cyc8b) {
 		t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
 		t->rec8b = t->cyc8b - t->act8b;
#12 lore raw

PATCH 7/21 ide: convert ide-timing.h to ide-timings.c library

In reply to Bartlomiej Zolnierkiewicz

* Don't include ide-timing.h in cs5535 and sis5513 host drivers (they don't need it currently).

* Convert ide-timing.h to ide-timings.c library and add CONFIG_IDE_TIMINGS config option to be selected by host drivers using the library.

While at it:

- fix ide_timing_find_mode() placement

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig           |    7 +
 drivers/ide/Makefile          |    1 
 drivers/ide/arm/palm_bk3710.c |    2 
 drivers/ide/ide-timing.h      |  183 ------------------------------------------
 drivers/ide/ide-timings.c     |  179 +++++++++++++++++++++++++++++++++++++++++
 drivers/ide/pci/amd74xx.c     |    2 
 drivers/ide/pci/cs5535.c      |    2 
 drivers/ide/pci/sis5513.c     |    3 
 drivers/ide/pci/via82cxxx.c   |    2 
 drivers/ide/ppc/pmac.c        |    2 
 include/linux/ide.h           |    5 +
 11 files changed, 192 insertions(+), 196 deletions(-)
drivers/ide/Kconfig +7 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -98,6 +98,9 @@ if BLK_DEV_IDE
 
 comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
 
+config IDE_TIMINGS
+	bool
+
 config IDE_ATAPI
 	bool
 
@@ -469,6 +472,7 @@ config BLK_DEV_ALI15X3
 config BLK_DEV_AMD74XX
 	tristate "AMD and nVidia IDE support"
 	depends on !ARM
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  This driver adds explicit support for AMD-7xx and AMD-8111 chips
@@ -725,6 +729,7 @@ config BLK_DEV_TRM290
 
 config BLK_DEV_VIA82CXXX
 	tristate "VIA82CXXX chipset support"
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  This driver adds explicit support for VIA BusMastering IDE chips.
@@ -751,6 +756,7 @@ endif
 config BLK_DEV_IDE_PMAC
 	tristate "PowerMac on-board IDE support"
 	depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y
+	select IDE_TIMINGS
 	help
 	  This driver provides support for the on-board IDE controller on
 	  most of the recent Apple Power Macintoshes and PowerBooks.
@@ -919,6 +925,7 @@ config BLK_DEV_Q40IDE
 config BLK_DEV_PALMCHIP_BK3710
 	tristate "Palmchip bk3710 IDE controller support"
 	depends on ARCH_DAVINCI
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_SFF
 	help
 	  Say Y here if you want to support the onchip IDE controller on the
drivers/ide/Makefile +1 -0
Index: b/drivers/ide/Makefile
===================================================================
@@ -14,6 +14,7 @@ EXTRA_CFLAGS				+= -Idrivers/ide
 ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
 
 # core IDE code
+ide-core-$(CONFIG_IDE_TIMINGS)		+= ide-timings.o
 ide-core-$(CONFIG_IDE_ATAPI)		+= ide-atapi.o
 ide-core-$(CONFIG_BLK_DEV_IDEPCI)	+= setup-pci.o
 ide-core-$(CONFIG_BLK_DEV_IDEDMA)	+= ide-dma.o
drivers/ide/arm/palm_bk3710.c +0 -2
Index: b/drivers/ide/arm/palm_bk3710.c
===================================================================
@@ -74,8 +74,6 @@ struct palm_bk3710_udmatiming {
 #define BK3710_IORDYTMP		0x78
 #define BK3710_IORDYTMS		0x7C
 
-#include "../ide-timing.h"
-
 static long ide_palm_clk;
 
 static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
drivers/ide/ide-timing.h deleted +0 -183

183 lines not on this page · raw message

drivers/ide/ide-timings.c new file +179 -0

179 lines not on this page · raw message

drivers/ide/pci/amd74xx.c +0 -2
Index: b/drivers/ide/pci/amd74xx.c
===================================================================
@@ -21,8 +21,6 @@
 #include <linux/init.h>
 #include <linux/ide.h>
 
-#include "ide-timing.h"
-
 enum {
 	AMD_IDE_CONFIG		= 0x41,
 	AMD_CABLE_DETECT	= 0x42,
drivers/ide/pci/cs5535.c +0 -2
Index: b/drivers/ide/pci/cs5535.c
===================================================================
@@ -26,8 +26,6 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#include "ide-timing.h"
-
 #define MSR_ATAC_BASE		0x51300000
 #define ATAC_GLD_MSR_CAP	(MSR_ATAC_BASE+0)
 #define ATAC_GLD_MSR_CONFIG	(MSR_ATAC_BASE+0x01)
drivers/ide/pci/sis5513.c +0 -3
Index: b/drivers/ide/pci/sis5513.c
===================================================================
@@ -52,8 +52,6 @@
 #include <linux/init.h>
 #include <linux/ide.h>
 
-#include "ide-timing.h"
-
 /* registers layout and init values are chipset family dependant */
 
 #define ATA_16		0x01
@@ -616,7 +614,6 @@ MODULE_LICENSE("GPL");
 /*
  * TODO:
  *	- CLEANUP
- *	- Use drivers/ide/ide-timing.h !
  *	- More checks in the config registers (force values instead of
  *	  relying on the BIOS setting them correctly).
  *	- Further optimisations ?
drivers/ide/pci/via82cxxx.c +0 -2
Index: b/drivers/ide/pci/via82cxxx.c
===================================================================
@@ -35,8 +35,6 @@
 #include <asm/processor.h>
 #endif
 
-#include "ide-timing.h"
-
 #define VIA_IDE_ENABLE		0x40
 #define VIA_IDE_CONFIG		0x41
 #define VIA_FIFO_CONFIG		0x43
drivers/ide/ppc/pmac.c +0 -2
Index: b/drivers/ide/ppc/pmac.c
===================================================================
@@ -48,8 +48,6 @@
 #include <asm/mediabay.h>
 #endif
 
-#include "../ide-timing.h"
-
 #undef IDE_PMAC_DEBUG
 
 #define DMA_WAIT_TIMEOUT	50
include/linux/ide.h +5 -0
Index: b/include/linux/ide.h
===================================================================
@@ -1284,6 +1284,11 @@ enum {
 				  IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
 };
 
+struct ide_timing *ide_timing_find_mode(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);
+
 typedef struct ide_pio_timings_s {
 	int	setup_time;	/* Address setup (ns) minimum */
 	int	active_time;	/* Active pulse (ns) minimum */
#13 lore raw

PATCH 8/21 ali14xx: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig          |    1 +
 drivers/ide/legacy/ali14xx.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -988,6 +988,7 @@ config BLK_DEV_4DRIVES
 
 config BLK_DEV_ALI14XX
 	tristate "ALI M14xx support"
+	select IDE_TIMINGS
 	help
 	  This driver is enabled at runtime using the "ali14xx.probe" kernel
 	  boot parameter.  It enables support for the secondary IDE interface
drivers/ide/legacy/ali14xx.c +2 -1
Index: b/drivers/ide/legacy/ali14xx.c
===================================================================
@@ -117,10 +117,11 @@ static void ali14xx_set_pio_mode(ide_dri
 	u8 param1, param2, param3, param4;
 	unsigned long flags;
 	int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 
 	/* calculate timing, according to PIO mode */
 	time1 = ide_pio_cycle_time(drive, pio);
-	time2 = ide_pio_timings[pio].active_time;
+	time2 = t->active;
 	param3 = param1 = (time2 * bus_speed + 999) / 1000;
 	param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1;
 	if (pio < 3) {
#15 lore raw

PATCH 9/21 ht6560b: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig          |    1 +
 drivers/ide/legacy/ht6560b.c |    7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -1008,6 +1008,7 @@ config BLK_DEV_DTC2278
 
 config BLK_DEV_HT6560B
 	tristate "Holtek HT6560B support"
+	select IDE_TIMINGS
 	help
 	  This driver is enabled at runtime using the "ht6560b.probe" kernel
 	  boot parameter. It enables support for the secondary IDE interface
drivers/ide/legacy/ht6560b.c +3 -4
Index: b/drivers/ide/legacy/ht6560b.c
===================================================================
@@ -216,6 +216,7 @@ static u8 ht_pio2timings(ide_drive_t *dr
 
         if (pio) {
 		unsigned int cycle_time;
+		struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 
 		cycle_time = ide_pio_cycle_time(drive, pio);
 
@@ -224,10 +225,8 @@ static u8 ht_pio2timings(ide_drive_t *dr
 		 *  actual cycle time for recovery and activity
 		 *  according system bus speed.
 		 */
-		active_time = ide_pio_timings[pio].active_time;
-		recovery_time = cycle_time
-			- active_time
-			- ide_pio_timings[pio].setup_time;
+		active_time = t->active;
+		recovery_time = cycle_time - active_time - t->setup;
 		/*
 		 *  Cycle times should be Vesa bus cycles
 		 */
#17 lore raw

PATCH 10/21 qd65xx: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig         |    1 +
 drivers/ide/legacy/qd65xx.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -1018,6 +1018,7 @@ config BLK_DEV_HT6560B
 
 config BLK_DEV_QD65XX
 	tristate "QDI QD65xx support"
+	select IDE_TIMINGS
 	help
 	  This driver is enabled at runtime using the "qd65xx.probe" kernel
 	  boot parameter.  It permits faster I/O speeds to be set.  See the
drivers/ide/legacy/qd65xx.c +2 -1
Index: b/drivers/ide/legacy/qd65xx.c
===================================================================
@@ -207,6 +207,7 @@ static void qd6500_set_pio_mode(ide_driv
 static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
 	ide_hwif_t *hwif = drive->hwif;
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 	unsigned int cycle_time;
 	int active_time   = 175;
 	int recovery_time = 415; /* worst case values from the dos driver */
@@ -236,7 +237,7 @@ static void qd6580_set_pio_mode(ide_driv
 					active_time = 110;
 					recovery_time = cycle_time - 120;
 				} else {
-					active_time = ide_pio_timings[pio].active_time;
+					active_time = t->active;
 					recovery_time = cycle_time - active_time;
 				}
 		}
#19 lore raw

PATCH 11/21 alim15x3: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig        |    1 +
 drivers/ide/pci/alim15x3.c |    6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -458,6 +458,7 @@ config BLK_DEV_AEC62XX
 
 config BLK_DEV_ALI15X3
 	tristate "ALI M15x3 chipset support"
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  This driver ensures (U)DMA support for ALI 1533, 1543 and 1543C
drivers/ide/pci/alim15x3.c +2 -4
Index: b/drivers/ide/pci/alim15x3.c
===================================================================
@@ -69,7 +69,8 @@ static void ali_set_pio_mode(ide_drive_t
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	struct pci_dev *dev = to_pci_dev(hwif->dev);
-	int s_time, a_time, c_time;
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
+	int s_time = t->setup, a_time = t->active, c_time = t->cycle;
 	u8 s_clc, a_clc, r_clc;
 	unsigned long flags;
 	int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
@@ -78,13 +79,10 @@ static void ali_set_pio_mode(ide_drive_t
 	u8 cd_dma_fifo = 0;
 	int unit = drive->select.b.unit & 1;
 
-	s_time = ide_pio_timings[pio].setup_time;
-	a_time = ide_pio_timings[pio].active_time;
 	if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
 		s_clc = 0;
 	if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8)
 		a_clc = 0;
-	c_time = ide_pio_timings[pio].cycle_time;
 
 	if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
 		r_clc = 1;
#21 lore raw

PATCH 12/21 cmd640: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig      |    1 +
 drivers/ide/pci/cmd640.c |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -329,6 +329,7 @@ config BLK_DEV_PLATFORM
 config BLK_DEV_CMD640
 	tristate "CMD640 chipset bugfix/support"
 	depends on X86
+	select IDE_TIMINGS
 	---help---
 	  The CMD-Technologies CMD640 IDE chip is used on many common 486 and
 	  Pentium motherboards, usually in combination with a "Neptune" or
drivers/ide/pci/cmd640.c +6 -2
Index: b/drivers/ide/pci/cmd640.c
===================================================================
@@ -521,6 +521,7 @@ static void program_drive_counts(ide_dri
 static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
 			    u8 pio_mode, unsigned int cycle_time)
 {
+	struct ide_timing *t;
 	int setup_time, active_time, recovery_time, clock_time;
 	u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count;
 	int bus_speed;
@@ -532,8 +533,11 @@ static void cmd640_set_mode(ide_drive_t 
 
 	if (pio_mode > 5)
 		pio_mode = 5;
-	setup_time  = ide_pio_timings[pio_mode].setup_time;
-	active_time = ide_pio_timings[pio_mode].active_time;
+
+	t = ide_timing_find_mode(XFER_PIO_0 + pio_mode);
+	setup_time  = t->setup;
+	active_time = t->active;
+
 	recovery_time = cycle_time - (setup_time + active_time);
 	clock_time = 1000 / bus_speed;
 	cycle_count = DIV_ROUND_UP(cycle_time, clock_time);
#24 lore raw

PATCH 13/21 cmd64x: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig      |    1 +
 drivers/ide/pci/cmd64x.c |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -495,6 +495,7 @@ config BLK_DEV_ATIIXP
 
 config BLK_DEV_CMD64X
 	tristate "CMD64{3|6|8|9} chipset support"
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  Say Y here if you have an IDE controller which uses any of these
drivers/ide/pci/cmd64x.c +3 -3
Index: b/drivers/ide/pci/cmd64x.c
===================================================================
@@ -116,6 +116,7 @@ static void cmd64x_tune_pio(ide_drive_t 
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= to_pci_dev(hwif->dev);
+	struct ide_timing *t	= ide_timing_find_mode(XFER_PIO_0 + pio);
 	unsigned int cycle_time;
 	u8 setup_count, arttim = 0;
 
@@ -124,10 +125,9 @@ static void cmd64x_tune_pio(ide_drive_t 
 
 	cycle_time = ide_pio_cycle_time(drive, pio);
 
-	program_cycle_times(drive, cycle_time,
-			    ide_pio_timings[pio].active_time);
+	program_cycle_times(drive, cycle_time, t->active);
 
-	setup_count = quantize_timing(ide_pio_timings[pio].setup_time,
+	setup_count = quantize_timing(t->setup,
 			1000 / (ide_pci_clk ? ide_pci_clk : 33));
 
 	/*
#26 lore raw

PATCH 14/21 cy82c693: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig        |    1 +
 drivers/ide/pci/cy82c693.c |    9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -510,6 +510,7 @@ config BLK_DEV_TRIFLEX
 
 config BLK_DEV_CY82C693
 	tristate "CY82C693 chipset support"
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  This driver adds detection and support for the CY82C693 chipset
drivers/ide/pci/cy82c693.c +4 -5
Index: b/drivers/ide/pci/cy82c693.c
===================================================================
@@ -133,6 +133,7 @@ static int calc_clk(int time, int bus_sp
  */
 static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
 {
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 	int clk1, clk2;
 	int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
 
@@ -141,15 +142,13 @@ static void compute_clocks(u8 pio, pio_c
 	 */
 
 	/* let's calc the address setup time clocks */
-	p_pclk->address_time = (u8)calc_clk(ide_pio_timings[pio].setup_time, bus_speed);
+	p_pclk->address_time = (u8)calc_clk(t->setup, bus_speed);
 
 	/* let's calc the active and recovery time clocks */
-	clk1 = calc_clk(ide_pio_timings[pio].active_time, bus_speed);
+	clk1 = calc_clk(t->active, bus_speed);
 
 	/* calc recovery timing */
-	clk2 =	ide_pio_timings[pio].cycle_time -
-		ide_pio_timings[pio].active_time -
-		ide_pio_timings[pio].setup_time;
+	clk2 = t->cycle - t->active - t->setup;
 
 	clk2 = calc_clk(clk2, bus_speed);
 
#28 lore raw

PATCH 15/21 opti621: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig       |    1 +
 drivers/ide/pci/opti621.c |   10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -426,6 +426,7 @@ config BLK_DEV_GENERIC
 config BLK_DEV_OPTI621
 	tristate "OPTi 82C621 chipset enhanced support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	select IDE_TIMINGS
 	select BLK_DEV_IDEPCI
 	help
 	  This is a driver for the OPTi 82C621 EIDE controller.
drivers/ide/pci/opti621.c +5 -5
Index: b/drivers/ide/pci/opti621.c
===================================================================
@@ -208,15 +208,15 @@ typedef struct pio_clocks_s {
 static void compute_clocks(int pio, pio_clocks_t *clks)
 {
 	if (pio != PIO_NOT_EXIST) {
-		int adr_setup, data_pls;
+		struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
+		int adr_setup = t->setup, data_pls = t->active;
 		int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
 
-		adr_setup = ide_pio_timings[pio].setup_time;
-		data_pls = ide_pio_timings[pio].active_time;
 		clks->address_time = cmpt_clk(adr_setup, bus_speed);
 		clks->data_time = cmpt_clk(data_pls, bus_speed);
-		clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time
-			- adr_setup-data_pls, bus_speed);
+		clks->recovery_time = cmpt_clk(t->cycle	- adr_setup - data_pls,
+					       bus_speed);
+
 		if (clks->address_time < 1)
 			clks->address_time = 1;
 		if (clks->address_time > 4)
#30 lore raw

PATCH 16/21 sl82c105: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

There should be no functional changes caused by this patch.

---
 drivers/ide/Kconfig        |    1 +
 drivers/ide/pci/sl82c105.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ide/Kconfig +1 -0
Index: b/drivers/ide/Kconfig
===================================================================
@@ -704,6 +704,7 @@ config BLK_DEV_SIS5513
 config BLK_DEV_SL82C105
 	tristate "Winbond SL82c105 support"
 	depends on (PPC || ARM)
+	select IDE_TIMINGS
 	select BLK_DEV_IDEDMA_PCI
 	help
 	  If you have a Winbond SL82c105 IDE controller, say Y here to enable
drivers/ide/pci/sl82c105.c +2 -1
Index: b/drivers/ide/pci/sl82c105.c
===================================================================
@@ -47,10 +47,11 @@
  */
 static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
 {
+	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 	unsigned int cmd_on, cmd_off;
 	u8 iordy = 0;
 
-	cmd_on  = (ide_pio_timings[pio].active_time + 29) / 30;
+	cmd_on  = (t->active + 29) / 30;
 	cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30;
 
 	if (cmd_on == 0)
#32 lore raw

PATCH 17/21 ide-mpc8xx: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

Also fix (disabled) debugging code while at it.

There should be no functional changes caused by this patch.

---
 drivers/ide/ppc/mpc8xx.c |   33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/ide/ppc/mpc8xx.c +13 -20
Index: b/drivers/ide/ppc/mpc8xx.c
===================================================================
@@ -89,7 +89,7 @@ ide_ioport_desc_t ioport_dsc[MAX_HWIFS] 
 #endif	/* IDE0_BASE_OFFSET */
 };
 
-ide_pio_timings_t ide_pio_clocks[6];
+struct ide_timing ide_pio_clocks[6];
 int hold_time[6] =  {30, 20, 15, 10, 10, 10 };   /* PIO Mode 5 with IORDY (nonstandard) */
 
 /*
@@ -200,30 +200,23 @@ static int __init m8xx_ide_init_ports(hw
 		/* Compute clock cycles for PIO timings */
 		for (i=0; i<6; ++i) {
 			bd_t	*binfo = (bd_t *)__res;
+			struct ide_timing *t, *n;
 
 			hold_time[i]   =
 				PCMCIA_MK_CLKS (hold_time[i],
 						binfo->bi_busfreq);
-			ide_pio_clocks[i].setup_time  =
-				PCMCIA_MK_CLKS (ide_pio_timings[i].setup_time,
-						binfo->bi_busfreq);
-			ide_pio_clocks[i].active_time =
-				PCMCIA_MK_CLKS (ide_pio_timings[i].active_time,
-						binfo->bi_busfreq);
-			ide_pio_clocks[i].cycle_time  =
-				PCMCIA_MK_CLKS (ide_pio_timings[i].cycle_time,
-						binfo->bi_busfreq);
+
+			t = ide_timing_find_mode(XFER_PIO_0 + i);
+			n = &ide_pio_clocks[i];
+
+			n->setup  = PCMCIA_MK_CLKS(t->setup,  binfo->bi_busfreq);
+			n->active = PCMCIA_MK_CLKS(t->active, binfo->bi_busfreq);
+			n->cycle  = PCMCIA_MK_CLKS(t->cycle,  binfo->bi_busfreq);
 #if 0
 			printk ("PIO mode %d timings: %d/%d/%d => %d/%d/%d\n",
 				i,
-				ide_pio_clocks[i].setup_time,
-				ide_pio_clocks[i].active_time,
-				ide_pio_clocks[i].hold_time,
-				ide_pio_clocks[i].cycle_time,
-				ide_pio_timings[i].setup_time,
-				ide_pio_timings[i].active_time,
-				ide_pio_timings[i].hold_time,
-				ide_pio_timings[i].cycle_time);
+				t->setup, t->active, t->cycle,
+				n->setup, n->active, n->cycle);
 #endif
 		}
 	}
@@ -404,8 +397,8 @@ static void m8xx_ide_set_pio_mode(ide_dr
 	mask = ~(PCMCIA_SHT(0xFF) | PCMCIA_SST(0xFF) | PCMCIA_SL(0xFF));
 
 	timing  = PCMCIA_SHT(hold_time[pio]  )
-		| PCMCIA_SST(ide_pio_clocks[pio].setup_time )
-		| PCMCIA_SL (ide_pio_clocks[pio].active_time)
+		| PCMCIA_SST(ide_pio_clocks[pio].setup)
+		| PCMCIA_SL (ide_pio_clocks[pio].active)
 		;
 
 #if 1
#33 lore raw

PATCH 18/21 ide-pmac: convert to use ide_timing_find_mode()

In reply to Bartlomiej Zolnierkiewicz

Also update my Copyrights while at it.

There should be no functional changes caused by this patch.

---
 drivers/ide/ppc/pmac.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/ide/ppc/pmac.c +6 -7
Index: b/drivers/ide/ppc/pmac.c
===================================================================
@@ -5,7 +5,7 @@
  * for doing DMA.
  *
  *  Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
- *  Copyright (C)      2007 Bartlomiej Zolnierkiewicz
+ *  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
@@ -494,6 +494,7 @@ static void pmac_outbsync(ide_hwif_t *hw
 static void
 pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
+	struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
 	u32 *timings, t;
 	unsigned accessTicks, recTicks;
 	unsigned accessTime, recTime;
@@ -525,10 +526,9 @@ pmac_ide_set_pio_mode(ide_drive_t *drive
 		}
 	case controller_kl_ata4:
 		/* 66Mhz cell */
-		recTime = cycle_time - ide_pio_timings[pio].active_time
-				- ide_pio_timings[pio].setup_time;
+		recTime = cycle_time - tim->active - tim->setup;
 		recTime = max(recTime, 150U);
-		accessTime = ide_pio_timings[pio].active_time;
+		accessTime = tim->active;
 		accessTime = max(accessTime, 150U);
 		accessTicks = SYSCLK_TICKS_66(accessTime);
 		accessTicks = min(accessTicks, 0x1fU);
@@ -541,10 +541,9 @@ pmac_ide_set_pio_mode(ide_drive_t *drive
 	default: {
 		/* 33Mhz cell */
 		int ebit = 0;
-		recTime = cycle_time - ide_pio_timings[pio].active_time
-				- ide_pio_timings[pio].setup_time;
+		recTime = cycle_time - tim->active - tim->setup;
 		recTime = max(recTime, 150U);
-		accessTime = ide_pio_timings[pio].active_time;
+		accessTime = tim->active;
 		accessTime = max(accessTime, 150U);
 		accessTicks = SYSCLK_TICKS(accessTime);
 		accessTicks = min(accessTicks, 0x1fU);
#35 lore raw

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

In reply to Bartlomiej Zolnierkiewicz

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.

---
 drivers/ide/ide-lib.c     |   23 -----------------------
 drivers/ide/ide-timings.c |   22 ++++++++++++++++++++++
 include/linux/ide.h       |    2 +-
 3 files changed, 23 insertions(+), 24 deletions(-)
drivers/ide/ide-lib.c +0 -23
Index: 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
drivers/ide/ide-timings.c +22 -0
Index: 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)
 
include/linux/ide.h +1 -1
Index: 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];
 
Acked-by on v1 19/21
#36 lore raw

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

Quoted 5 lines · Bartlomiej Zolnierkiewicz

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:

Quoted 7 lines

- 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.

MBR, Sergei

#37 lore raw

PATCH 20/21 ide: remove no longer used ide_pio_timings[]

In reply to Bartlomiej Zolnierkiewicz
---
 drivers/ide/ide-lib.c |   17 -----------------
 include/linux/ide.h   |    8 --------
 2 files changed, 25 deletions(-)
drivers/ide/ide-lib.c +0 -17
Index: b/drivers/ide/ide-lib.c
===================================================================
@@ -76,23 +76,6 @@ static u8 ide_rate_filter(ide_drive_t *d
 }
 
 /*
- * Standard (generic) timings for PIO modes, from ATA2 specification.
- * These timings are for access to the IDE data port register *only*.
- * Some drives may specify a mode, while also specifying a different
- * value for cycle_time (from drive identification data).
- */
-const ide_pio_timings_t ide_pio_timings[6] = {
-	{ 70,	165,	600 },	/* PIO Mode 0 */
-	{ 50,	125,	383 },	/* PIO Mode 1 */
-	{ 30,	100,	240 },	/* PIO Mode 2 */
-	{ 30,	80,	180 },	/* PIO Mode 3 with IORDY */
-	{ 25,	70,	120 },	/* PIO Mode 4 with IORDY */
-	{ 20,	50,	100 }	/* PIO Mode 5 with IORDY (nonstandard) */
-};
-
-EXPORT_SYMBOL_GPL(ide_pio_timings);
-
-/*
  * Shared data/functions for determining best PIO mode for an IDE drive.
  * Most of this stuff originally lived in cmd640.c, and changes to the
  * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
include/linux/ide.h +0 -8
Index: b/include/linux/ide.h
===================================================================
@@ -1290,15 +1290,7 @@ void ide_timing_merge(struct ide_timing 
 		      struct ide_timing *, unsigned int);
 int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
 
-typedef struct ide_pio_timings_s {
-	int	setup_time;	/* Address setup (ns) minimum */
-	int	active_time;	/* Active pulse (ns) minimum */
-	int	cycle_time;	/* Cycle time (ns) minimum = */
-				/* active + recovery (+ setup for some chips) */
-} ide_pio_timings_t;
-
 u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
-extern const ide_pio_timings_t ide_pio_timings[6];
 
 int ide_set_pio_mode(ide_drive_t *, u8);
 int ide_set_dma_mode(ide_drive_t *, u8);
#39 lore raw

PATCH 21/21 ide: move PIO blacklist to ide-pio-blacklist.c

In reply to Bartlomiej Zolnierkiewicz

Move PIO blacklist to ide-pio-blacklist.c.

While at it:

- fix comment

- fix whitespace damage

There should be no functional changes caused by this patch.

---
 drivers/ide/Makefile            |    3 -
 drivers/ide/ide-lib.c           |   96 ----------------------------------------
 drivers/ide/ide-pio-blacklist.c |   94 +++++++++++++++++++++++++++++++++++++++
 include/linux/ide.h             |    2 
 4 files changed, 98 insertions(+), 97 deletions(-)
drivers/ide/Makefile +2 -1
Index: b/drivers/ide/Makefile
===================================================================
@@ -11,7 +11,8 @@
 
 EXTRA_CFLAGS				+= -Idrivers/ide
 
-ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
+ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o \
+	      ide-pio-blacklist.o
 
 # core IDE code
 ide-core-$(CONFIG_IDE_TIMINGS)		+= ide-timings.o
drivers/ide/ide-lib.c +0 -96

102 lines not on this page · raw message

drivers/ide/ide-pio-blacklist.c new file +94 -0

94 lines not on this page · raw message

include/linux/ide.h +2 -0
Index: b/include/linux/ide.h
===================================================================
@@ -1290,6 +1290,8 @@ void ide_timing_merge(struct ide_timing 
 		      struct ide_timing *, unsigned int);
 int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
 
+int ide_scan_pio_blacklist(char *);
+
 u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
 
 int ide_set_pio_mode(ide_drive_t *, u8);