Skip to content

Commit c97c6ac

Browse files
committed
ide: pass hw_regs_t-s to ide_device_add[_all]() (take 3)
* Add 'hw_regs_t **hws' argument to ide_device_add[_all]() and convert host drivers + ide_legacy_init_one() + ide_setup_pci_device[s]() to use it instead of calling ide_init_port_hw() directly. [ However if host has > 1 port we must still set hwif->chipset to hint consecutive ide_find_port() call that the previous slot is occupied. ] * Unexport ide_init_port_hw(). v2: * Use defines instead of hard-coded values in buddha.c, gayle.c and q40ide.c. (Suggested by Geert Uytterhoeven) * Better patch description. v3: * Fix build problem in ide-cs.c. (Noticed by Stephen Rothwell) There should be no functional changes caused by this patch. Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 51d87ed commit c97c6ac

27 files changed

Lines changed: 131 additions & 140 deletions

‎drivers/ide/arm/icside.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
442442
{
443443
ide_hwif_t *hwif;
444444
void __iomem *base;
445+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
445446
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
446-
hw_regs_t hw;
447447

448448
base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
449449
if (!base)
@@ -467,7 +467,6 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
467467
if (!hwif)
468468
return -ENODEV;
469469

470-
ide_init_port_hw(hwif, &hw);
471470
default_hwif_mmiops(hwif);
472471

473472
state->hwif[0] = hwif;
@@ -476,7 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
476475

477476
idx[0] = hwif->index;
478477

479-
ide_device_add(idx, NULL);
478+
ide_device_add(idx, NULL, hws);
480479

481480
return 0;
482481
}
@@ -497,9 +496,9 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
497496
void __iomem *ioc_base, *easi_base;
498497
unsigned int sel = 0;
499498
int ret;
499+
hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL };
500500
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
501501
struct ide_port_info d = icside_v6_port_info;
502-
hw_regs_t hw[2];
503502

504503
ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
505504
if (!ioc_base) {
@@ -545,16 +544,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
545544
if (hwif == NULL)
546545
return -ENODEV;
547546

548-
ide_init_port_hw(hwif, &hw[0]);
547+
hwif->chipset = ide_acorn;
549548
default_hwif_mmiops(hwif);
550549

551550
idx[0] = hwif->index;
552551

553552
mate = ide_find_port();
554553
if (mate) {
555-
ide_init_port_hw(mate, &hw[1]);
556554
default_hwif_mmiops(mate);
557555

556+
hws[1] = &hw[1];
558557
idx[1] = mate->index;
559558
}
560559

@@ -569,7 +568,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
569568
d.dma_ops = NULL;
570569
}
571570

572-
ide_device_add(idx, &d);
571+
ide_device_add(idx, &d, hws);
573572

574573
return 0;
575574

‎drivers/ide/arm/ide_arm.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
static int __init ide_arm_init(void)
3030
{
3131
ide_hwif_t *hwif;
32-
hw_regs_t hw;
3332
unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206;
33+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
3434
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
3535

3636
if (!request_region(base, 8, DRV_NAME)) {
@@ -53,10 +53,9 @@ static int __init ide_arm_init(void)
5353

5454
hwif = ide_find_port();
5555
if (hwif) {
56-
ide_init_port_hw(hwif, &hw);
5756
idx[0] = hwif->index;
5857

59-
ide_device_add(idx, NULL);
58+
ide_device_add(idx, NULL, hws);
6059
}
6160

6261
return 0;

‎drivers/ide/arm/palm_bk3710.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
351351
ide_hwif_t *hwif;
352352
unsigned long base, rate;
353353
int i;
354-
hw_regs_t hw;
354+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
355355
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
356356

357357
clk = clk_get(NULL, "IDECLK");
@@ -400,13 +400,11 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
400400

401401
i = hwif->index;
402402

403-
ide_init_port_hw(hwif, &hw);
404-
405403
default_hwif_mmiops(hwif);
406404

407405
idx[0] = i;
408406

409-
ide_device_add(idx, &palm_bk3710_port_info);
407+
ide_device_add(idx, &palm_bk3710_port_info, hws);
410408

411409
return 0;
412410
out:

‎drivers/ide/arm/rapide.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
3535
ide_hwif_t *hwif;
3636
void __iomem *base;
3737
int ret;
38+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
3839
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
39-
hw_regs_t hw;
4040

4141
ret = ecard_request_resources(ec);
4242
if (ret)
@@ -59,12 +59,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
5959
goto release;
6060
}
6161

62-
ide_init_port_hw(hwif, &hw);
6362
default_hwif_mmiops(hwif);
6463

6564
idx[0] = hwif->index;
6665

67-
ide_device_add(idx, &rapide_port_info);
66+
ide_device_add(idx, &rapide_port_info, hws);
6867

6968
ecard_set_drvdata(ec, hwif);
7069
goto out;

‎drivers/ide/h8300/ide-h8300.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ static const struct ide_port_info h8300_port_info = {
184184

185185
static int __init h8300_ide_init(void)
186186
{
187-
hw_regs_t hw;
188187
ide_hwif_t *hwif;
189188
int index;
189+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
190190
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
191191

192192
printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
@@ -205,12 +205,11 @@ static int __init h8300_ide_init(void)
205205
return -ENOENT;
206206

207207
index = hwif->index;
208-
ide_init_port_hw(hwif, &hw);
209208
hwif_setup(hwif);
210209

211210
idx[0] = index;
212211

213-
ide_device_add(idx, &h8300_port_info);
212+
ide_device_add(idx, &h8300_port_info, hws);
214213

215214
return 0;
216215

‎drivers/ide/ide-generic.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n)
3131
ide_hwif_t *hwif;
3232
unsigned int base, ctl;
3333
int irq;
34-
hw_regs_t hw;
34+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
3535
u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
3636

3737
if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
@@ -46,11 +46,9 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n)
4646
hw.irq = irq;
4747
hw.chipset = ide_generic;
4848

49-
ide_init_port_hw(hwif, &hw);
50-
5149
idx[0] = hwif->index;
5250

53-
ide_device_add(idx, NULL);
51+
ide_device_add(idx, NULL, hws);
5452

5553
return n;
5654
};
@@ -90,6 +88,7 @@ static int __init ide_generic_sysfs_init(void)
9088

9189
static int __init ide_generic_init(void)
9290
{
91+
hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
9392
u8 idx[MAX_HWIFS];
9493
int i;
9594

@@ -99,8 +98,8 @@ static int __init ide_generic_init(void)
9998
for (i = 0; i < MAX_HWIFS; i++) {
10099
ide_hwif_t *hwif;
101100
unsigned long io_addr = ide_default_io_base(i);
102-
hw_regs_t hw;
103101

102+
hws[i] = NULL;
104103
idx[i] = 0xff;
105104

106105
if ((probe_mask & (1 << i)) && io_addr) {
@@ -129,17 +128,19 @@ static int __init ide_generic_init(void)
129128
continue;
130129
}
131130

132-
memset(&hw, 0, sizeof(hw));
133-
ide_std_init_ports(&hw, io_addr, io_addr + 0x206);
134-
hw.irq = ide_default_irq(io_addr);
135-
hw.chipset = ide_generic;
136-
ide_init_port_hw(hwif, &hw);
131+
hwif->chipset = ide_generic;
132+
133+
memset(&hw[i], 0, sizeof(hw[i]));
134+
ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
135+
hw[i].irq = ide_default_irq(io_addr);
136+
hw[i].chipset = ide_generic;
137137

138+
hws[i] = &hw[i];
138139
idx[i] = i;
139140
}
140141
}
141142

142-
ide_device_add_all(idx, NULL);
143+
ide_device_add_all(idx, NULL, hws);
143144

144145
if (ide_generic_sysfs_init())
145146
printk(KERN_ERR DRV_NAME ": failed to create ide_generic "

‎drivers/ide/ide-pnp.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ static struct pnp_device_id idepnp_devices[] = {
2929

3030
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
3131
{
32-
hw_regs_t hw;
3332
ide_hwif_t *hwif;
3433
unsigned long base, ctl;
34+
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
3535

3636
printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
3737

@@ -64,11 +64,9 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
6464
u8 index = hwif->index;
6565
u8 idx[4] = { index, 0xff, 0xff, 0xff };
6666

67-
ide_init_port_hw(hwif, &hw);
68-
6967
pnp_set_drvdata(dev, hwif);
7068

71-
ide_device_add(idx, NULL);
69+
ide_device_add(idx, NULL, hws);
7270

7371
return 0;
7472
}

‎drivers/ide/ide-probe.c‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
15011501
}
15021502
EXPORT_SYMBOL_GPL(ide_find_port_slot);
15031503

1504-
int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
1504+
int ide_device_add_all(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
15051505
{
15061506
ide_hwif_t *hwif, *mate = NULL;
15071507
int i, rc = 0;
@@ -1514,6 +1514,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
15141514

15151515
hwif = &ide_hwifs[idx[i]];
15161516

1517+
ide_init_port_hw(hwif, hws[i]);
15171518
ide_port_apply_params(hwif);
15181519

15191520
if (d == NULL) {
@@ -1603,15 +1604,18 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
16031604
}
16041605
EXPORT_SYMBOL_GPL(ide_device_add_all);
16051606

1606-
int ide_device_add(u8 idx[4], const struct ide_port_info *d)
1607+
int ide_device_add(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
16071608
{
1609+
hw_regs_t *hws_all[MAX_HWIFS];
16081610
u8 idx_all[MAX_HWIFS];
16091611
int i;
16101612

1611-
for (i = 0; i < MAX_HWIFS; i++)
1613+
for (i = 0; i < MAX_HWIFS; i++) {
1614+
hws_all[i] = (i < 4) ? hws[i] : NULL;
16121615
idx_all[i] = (i < 4) ? idx[i] : 0xff;
1616+
}
16131617

1614-
return ide_device_add_all(idx_all, d);
1618+
return ide_device_add_all(idx_all, d, hws_all);
16151619
}
16161620
EXPORT_SYMBOL_GPL(ide_device_add);
16171621

@@ -1634,8 +1638,8 @@ void ide_port_scan(ide_hwif_t *hwif)
16341638
}
16351639
EXPORT_SYMBOL_GPL(ide_port_scan);
16361640

1637-
static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
1638-
const struct ide_port_info *d,
1641+
static void ide_legacy_init_one(u8 *idx, hw_regs_t **hws, hw_regs_t *hw,
1642+
u8 port_no, const struct ide_port_info *d,
16391643
unsigned long config)
16401644
{
16411645
ide_hwif_t *hwif;
@@ -1671,29 +1675,32 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
16711675

16721676
hwif = ide_find_port_slot(d);
16731677
if (hwif) {
1674-
ide_init_port_hw(hwif, hw);
1678+
hwif->chipset = hw->chipset;
1679+
16751680
if (config)
16761681
hwif->config_data = config;
1682+
1683+
hws[port_no] = hw;
16771684
idx[port_no] = hwif->index;
16781685
}
16791686
}
16801687

16811688
int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
16821689
{
16831690
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1684-
hw_regs_t hw[2];
1691+
hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
16851692

16861693
memset(&hw, 0, sizeof(hw));
16871694

16881695
if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
1689-
ide_legacy_init_one(idx, &hw[0], 0, d, config);
1690-
ide_legacy_init_one(idx, &hw[1], 1, d, config);
1696+
ide_legacy_init_one(idx, hws, &hw[0], 0, d, config);
1697+
ide_legacy_init_one(idx, hws, &hw[1], 1, d, config);
16911698

16921699
if (idx[0] == 0xff && idx[1] == 0xff &&
16931700
(d->host_flags & IDE_HFLAG_SINGLE))
16941701
return -ENOENT;
16951702

1696-
ide_device_add(idx, d);
1703+
ide_device_add(idx, d, hws);
16971704

16981705
return 0;
16991706
}

‎drivers/ide/ide.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
288288
hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
289289
hwif->ack_intr = hw->ack_intr;
290290
}
291-
EXPORT_SYMBOL_GPL(ide_init_port_hw);
292291

293292
/*
294293
* Locks for IDE setting functionality

‎drivers/ide/legacy/buddha.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define CATWEASEL_NUM_HWIFS 3
3838
#define XSURF_NUM_HWIFS 2
3939

40+
#define MAX_NUM_HWIFS 3
41+
4042
/*
4143
* Bases of the IDE interfaces (relative to the board address)
4244
*/
@@ -148,7 +150,6 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
148150

149151
static int __init buddha_init(void)
150152
{
151-
hw_regs_t hw;
152153
ide_hwif_t *hwif;
153154
int i;
154155

@@ -159,6 +160,7 @@ static int __init buddha_init(void)
159160

160161
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
161162
unsigned long board;
163+
hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
162164
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
163165

164166
if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
@@ -221,19 +223,19 @@ static int __init buddha_init(void)
221223
ack_intr = xsurf_ack_intr;
222224
}
223225

224-
buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr);
226+
buddha_setup_ports(&hw[i], base, ctl, irq_port,
227+
ack_intr);
225228

226229
hwif = ide_find_port();
227230
if (hwif) {
228-
u8 index = hwif->index;
229-
230-
ide_init_port_hw(hwif, &hw);
231+
hwif->chipset = ide_generic;
231232

232-
idx[i] = index;
233+
hws[i] = &hw[i];
234+
idx[i] = hwif->index;
233235
}
234236
}
235237

236-
ide_device_add(idx, NULL);
238+
ide_device_add(idx, NULL, hws);
237239
}
238240

239241
return 0;

0 commit comments

Comments
 (0)