Skip to content

Commit f01d35d

Browse files
committed
ide-generic: remove ide_default_{io_base,irq}() inlines (take 3)
Replace ide_default_{io_base,irq}() inlines by legacy_{bases,irqs}[]. v2: Add missing zero-ing of hws[] (caught during testing by Borislav Petkov). v3: Fix zero-oing of hws[] for _real_ this time. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 35bbac9 commit f01d35d

6 files changed

Lines changed: 29 additions & 162 deletions

File tree

‎drivers/ide/ide-generic.c‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#include <linux/module.h>
2121
#include <linux/ide.h>
2222

23+
/* FIXME: convert m32r to use ide_platform host driver */
24+
#ifdef CONFIG_M32R
25+
#include <asm/m32r.h>
26+
#endif
27+
2328
#define DRV_NAME "ide_generic"
2429

2530
static int probe_mask = 0x03;
@@ -80,6 +85,21 @@ static int __init ide_generic_sysfs_init(void)
8085
return 0;
8186
}
8287

88+
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
89+
|| defined(CONFIG_PLAT_OPSPUT)
90+
static const u16 legacy_bases[] = { 0x1f0 };
91+
static const int legacy_irqs[] = { PLD_IRQ_CFIREQ };
92+
#elif defined(CONFIG_PLAT_MAPPI3)
93+
static const u16 legacy_bases[] = { 0x1f0, 0x170 };
94+
static const int legacy_irqs[] = { PLD_IRQ_CFIREQ, PLD_IRQ_IDEIREQ };
95+
#elif defined(CONFIG_ALPHA)
96+
static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168 };
97+
static const int legacy_irqs[] = { 14, 15, 11, 10 };
98+
#else
99+
static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
100+
static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 };
101+
#endif
102+
83103
static int __init ide_generic_init(void)
84104
{
85105
hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
@@ -94,8 +114,10 @@ static int __init ide_generic_init(void)
94114
printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module "
95115
"parameter for probing all legacy ISA IDE ports\n");
96116

97-
for (i = 0; i < MAX_HWIFS; i++) {
98-
io_addr = ide_default_io_base(i);
117+
memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS);
118+
119+
for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) {
120+
io_addr = legacy_bases[i];
99121

100122
hws[i] = NULL;
101123

@@ -117,7 +139,11 @@ static int __init ide_generic_init(void)
117139

118140
memset(&hw[i], 0, sizeof(hw[i]));
119141
ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
120-
hw[i].irq = ide_default_irq(io_addr);
142+
#ifdef CONFIG_IA64
143+
hw[i].irq = isa_irq_to_vector(legacy_irqs[i]);
144+
#else
145+
hw[i].irq = legacy_irqs[i];
146+
#endif
121147
hw[i].chipset = ide_generic;
122148

123149
hws[i] = &hw[i];

‎include/asm-alpha/ide.h‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,6 @@
1313

1414
#ifdef __KERNEL__
1515

16-
static inline int ide_default_irq(unsigned long base)
17-
{
18-
switch (base) {
19-
case 0x1f0: return 14;
20-
case 0x170: return 15;
21-
case 0x1e8: return 11;
22-
case 0x168: return 10;
23-
default:
24-
return 0;
25-
}
26-
}
27-
28-
static inline unsigned long ide_default_io_base(int index)
29-
{
30-
switch (index) {
31-
case 0: return 0x1f0;
32-
case 1: return 0x170;
33-
case 2: return 0x1e8;
34-
case 3: return 0x168;
35-
default:
36-
return 0;
37-
}
38-
}
39-
4016
#include <asm-generic/ide_iops.h>
4117

4218
#endif /* __KERNEL__ */

‎include/asm-ia64/ide.h‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,8 @@
1313

1414
#ifdef __KERNEL__
1515

16-
1716
#include <linux/irq.h>
1817

19-
static inline int ide_default_irq(unsigned long base)
20-
{
21-
switch (base) {
22-
case 0x1f0: return isa_irq_to_vector(14);
23-
case 0x170: return isa_irq_to_vector(15);
24-
case 0x1e8: return isa_irq_to_vector(11);
25-
case 0x168: return isa_irq_to_vector(10);
26-
case 0x1e0: return isa_irq_to_vector(8);
27-
case 0x160: return isa_irq_to_vector(12);
28-
default:
29-
return 0;
30-
}
31-
}
32-
33-
static inline unsigned long ide_default_io_base(int index)
34-
{
35-
switch (index) {
36-
case 0: return 0x1f0;
37-
case 1: return 0x170;
38-
case 2: return 0x1e8;
39-
case 3: return 0x168;
40-
case 4: return 0x1e0;
41-
case 5: return 0x160;
42-
default:
43-
return 0;
44-
}
45-
}
46-
4718
#include <asm-generic/ide_iops.h>
4819

4920
#endif /* __KERNEL__ */

‎include/asm-m32r/ide.h‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,6 @@
1313

1414
#ifdef __KERNEL__
1515

16-
#include <asm/m32r.h>
17-
18-
static __inline__ int ide_default_irq(unsigned long base)
19-
{
20-
switch (base) {
21-
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
22-
|| defined(CONFIG_PLAT_OPSPUT)
23-
case 0x1f0: return PLD_IRQ_CFIREQ;
24-
default:
25-
return 0;
26-
#elif defined(CONFIG_PLAT_MAPPI3)
27-
case 0x1f0: return PLD_IRQ_CFIREQ;
28-
case 0x170: return PLD_IRQ_IDEIREQ;
29-
default:
30-
return 0;
31-
#else
32-
case 0x1f0: return 14;
33-
case 0x170: return 15;
34-
case 0x1e8: return 11;
35-
case 0x168: return 10;
36-
case 0x1e0: return 8;
37-
case 0x160: return 12;
38-
default:
39-
return 0;
40-
#endif
41-
}
42-
}
43-
44-
static __inline__ unsigned long ide_default_io_base(int index)
45-
{
46-
switch (index) {
47-
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
48-
|| defined(CONFIG_PLAT_OPSPUT)
49-
case 0: return 0x1f0;
50-
#elif defined(CONFIG_PLAT_MAPPI3)
51-
case 0: return 0x1f0;
52-
case 1: return 0x170;
53-
#else
54-
case 0: return 0x1f0;
55-
case 1: return 0x170;
56-
case 2: return 0x1e8;
57-
case 3: return 0x168;
58-
case 4: return 0x1e0;
59-
case 5: return 0x160;
60-
#endif
61-
default:
62-
return 0;
63-
}
64-
}
65-
6616
#include <asm-generic/ide_iops.h>
6717

6818
#endif /* __KERNEL__ */

‎include/asm-mips/mach-generic/ide.h‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,6 @@ static __inline__ int ide_probe_legacy(void)
4848
#endif
4949
}
5050

51-
static __inline__ int ide_default_irq(unsigned long base)
52-
{
53-
switch (base) {
54-
case 0x1f0: return 14;
55-
case 0x170: return 15;
56-
case 0x1e8: return 11;
57-
case 0x168: return 10;
58-
case 0x1e0: return 8;
59-
case 0x160: return 12;
60-
default:
61-
return 0;
62-
}
63-
}
64-
65-
static __inline__ unsigned long ide_default_io_base(int index)
66-
{
67-
switch (index) {
68-
case 0: return 0x1f0;
69-
case 1: return 0x170;
70-
case 2: return 0x1e8;
71-
case 3: return 0x168;
72-
case 4: return 0x1e0;
73-
case 5: return 0x160;
74-
default:
75-
return 0;
76-
}
77-
}
78-
7951
/* MIPS port and memory-mapped I/O string operations. */
8052
static inline void __ide_flush_prologue(void)
8153
{

‎include/asm-x86/ide.h‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,6 @@
1111

1212
#ifdef __KERNEL__
1313

14-
static __inline__ int ide_default_irq(unsigned long base)
15-
{
16-
switch (base) {
17-
case 0x1f0: return 14;
18-
case 0x170: return 15;
19-
case 0x1e8: return 11;
20-
case 0x168: return 10;
21-
case 0x1e0: return 8;
22-
case 0x160: return 12;
23-
default:
24-
return 0;
25-
}
26-
}
27-
28-
static __inline__ unsigned long ide_default_io_base(int index)
29-
{
30-
switch (index) {
31-
case 0: return 0x1f0;
32-
case 1: return 0x170;
33-
case 2: return 0x1e8;
34-
case 3: return 0x168;
35-
case 4: return 0x1e0;
36-
case 5: return 0x160;
37-
default:
38-
return 0;
39-
}
40-
}
41-
4214
#include <asm-generic/ide_iops.h>
4315

4416
#endif /* __KERNEL__ */

0 commit comments

Comments
 (0)