Skip to content

Commit f06ab34

Browse files
committed
ide: convert ide-timing.h to ide-timings.c library (take 2)
* 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 v2: * Add missing EXPORT_SYMBOLs. (Stephen Rothwell <sfr@canb.auug.org.au>) There should be no functional changes caused by this patch. Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 2c139e7 commit f06ab34

10 files changed

Lines changed: 32 additions & 32 deletions

File tree

‎drivers/ide/Kconfig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ if BLK_DEV_IDE
9898

9999
comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
100100

101+
config IDE_TIMINGS
102+
bool
103+
101104
config IDE_ATAPI
102105
bool
103106

@@ -469,6 +472,7 @@ config BLK_DEV_ALI15X3
469472
config BLK_DEV_AMD74XX
470473
tristate "AMD and nVidia IDE support"
471474
depends on !ARM
475+
select IDE_TIMINGS
472476
select BLK_DEV_IDEDMA_PCI
473477
help
474478
This driver adds explicit support for AMD-7xx and AMD-8111 chips
@@ -725,6 +729,7 @@ config BLK_DEV_TRM290
725729

726730
config BLK_DEV_VIA82CXXX
727731
tristate "VIA82CXXX chipset support"
732+
select IDE_TIMINGS
728733
select BLK_DEV_IDEDMA_PCI
729734
help
730735
This driver adds explicit support for VIA BusMastering IDE chips.
@@ -751,6 +756,7 @@ endif
751756
config BLK_DEV_IDE_PMAC
752757
tristate "PowerMac on-board IDE support"
753758
depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y
759+
select IDE_TIMINGS
754760
help
755761
This driver provides support for the on-board IDE controller on
756762
most of the recent Apple Power Macintoshes and PowerBooks.
@@ -912,6 +918,7 @@ config BLK_DEV_Q40IDE
912918
config BLK_DEV_PALMCHIP_BK3710
913919
tristate "Palmchip bk3710 IDE controller support"
914920
depends on ARCH_DAVINCI
921+
select IDE_TIMINGS
915922
select BLK_DEV_IDEDMA_SFF
916923
help
917924
Say Y here if you want to support the onchip IDE controller on the

‎drivers/ide/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ EXTRA_CFLAGS += -Idrivers/ide
1414
ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
1515

1616
# core IDE code
17+
ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
1718
ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
1819
ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
1920
ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o

‎drivers/ide/arm/palm_bk3710.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ struct palm_bk3710_udmatiming {
7474
#define BK3710_IORDYTMP 0x78
7575
#define BK3710_IORDYTMS 0x7C
7676

77-
#include "../ide-timing.h"
78-
7977
static unsigned ideclk_period; /* in nanoseconds */
8078

8179
static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#ifndef _IDE_TIMING_H
2-
#define _IDE_TIMING_H
3-
41
/*
52
* Copyright (c) 1999-2001 Vojtech Pavlik
63
*
@@ -25,6 +22,8 @@
2522

2623
#include <linux/kernel.h>
2724
#include <linux/hdreg.h>
25+
#include <linux/ide.h>
26+
#include <linux/module.h>
2827

2928
/*
3029
* PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
@@ -65,6 +64,17 @@ static struct ide_timing ide_timing[] = {
6564
{ 0xff }
6665
};
6766

67+
struct ide_timing *ide_timing_find_mode(u8 speed)
68+
{
69+
struct ide_timing *t;
70+
71+
for (t = ide_timing; t->mode != speed; t++)
72+
if (t->mode == 0xff)
73+
return NULL;
74+
return t;
75+
}
76+
EXPORT_SYMBOL_GPL(ide_timing_find_mode);
77+
6878
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
6979
#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
7080

@@ -81,8 +91,8 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
8191
q->udma = EZ(t->udma * 1000, UT);
8292
}
8393

84-
static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
85-
struct ide_timing *m, unsigned int what)
94+
void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
95+
struct ide_timing *m, unsigned int what)
8696
{
8797
if (what & IDE_TIMING_SETUP)
8898
m->setup = max(a->setup, b->setup);
@@ -101,19 +111,10 @@ static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
101111
if (what & IDE_TIMING_UDMA)
102112
m->udma = max(a->udma, b->udma);
103113
}
114+
EXPORT_SYMBOL_GPL(ide_timing_merge);
104115

105-
static struct ide_timing *ide_timing_find_mode(u8 speed)
106-
{
107-
struct ide_timing *t;
108-
109-
for (t = ide_timing; t->mode != speed; t++)
110-
if (t->mode == 0xff)
111-
return NULL;
112-
return t;
113-
}
114-
115-
static int ide_timing_compute(ide_drive_t *drive, u8 speed,
116-
struct ide_timing *t, int T, int UT)
116+
int ide_timing_compute(ide_drive_t *drive, u8 speed,
117+
struct ide_timing *t, int T, int UT)
117118
{
118119
struct hd_driveid *id = drive->id;
119120
struct ide_timing *s, p;
@@ -179,5 +180,4 @@ static int ide_timing_compute(ide_drive_t *drive, u8 speed,
179180

180181
return 0;
181182
}
182-
183-
#endif
183+
EXPORT_SYMBOL_GPL(ide_timing_compute);

‎drivers/ide/pci/amd74xx.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#include <linux/init.h>
2222
#include <linux/ide.h>
2323

24-
#include "ide-timing.h"
25-
2624
enum {
2725
AMD_IDE_CONFIG = 0x41,
2826
AMD_CABLE_DETECT = 0x42,

‎drivers/ide/pci/cs5535.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include <linux/pci.h>
2727
#include <linux/ide.h>
2828

29-
#include "ide-timing.h"
30-
3129
#define MSR_ATAC_BASE 0x51300000
3230
#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0)
3331
#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01)

‎drivers/ide/pci/sis5513.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#include <linux/init.h>
5353
#include <linux/ide.h>
5454

55-
#include "ide-timing.h"
56-
5755
/* registers layout and init values are chipset family dependant */
5856

5957
#define ATA_16 0x01
@@ -616,7 +614,6 @@ MODULE_LICENSE("GPL");
616614
/*
617615
* TODO:
618616
* - CLEANUP
619-
* - Use drivers/ide/ide-timing.h !
620617
* - More checks in the config registers (force values instead of
621618
* relying on the BIOS setting them correctly).
622619
* - Further optimisations ?

‎drivers/ide/pci/via82cxxx.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include <asm/processor.h>
3636
#endif
3737

38-
#include "ide-timing.h"
39-
4038
#define VIA_IDE_ENABLE 0x40
4139
#define VIA_IDE_CONFIG 0x41
4240
#define VIA_FIFO_CONFIG 0x43

‎drivers/ide/ppc/pmac.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
#include <asm/mediabay.h>
4949
#endif
5050

51-
#include "../ide-timing.h"
52-
5351
#undef IDE_PMAC_DEBUG
5452

5553
#define DMA_WAIT_TIMEOUT 50

‎include/linux/ide.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,11 @@ enum {
12991299
IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
13001300
};
13011301

1302+
struct ide_timing *ide_timing_find_mode(u8);
1303+
void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1304+
struct ide_timing *, unsigned int);
1305+
int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1306+
13021307
typedef struct ide_pio_timings_s {
13031308
int setup_time; /* Address setup (ns) minimum */
13041309
int active_time; /* Active pulse (ns) minimum */

0 commit comments

Comments
 (0)