Skip to content

Commit 48c3c10

Browse files
committed
ide: add struct ide_host (take 3)
* Add struct ide_host which keeps pointers to host's ports. * Add ide_host_alloc[_all]() and ide_host_remove() helpers. * Pass 'struct ide_host *host' instead of 'u8 *idx' to ide_device_add[_all]() and rename it to ide_host_register[_all](). * Convert host drivers and core code to use struct ide_host. * Remove no longer needed ide_find_port(). * Make ide_find_port_slot() static. * Unexport ide_unregister(). v2: * Add missing 'struct ide_host *host' to macide.c. v3: * Fix build problem in pmac.c (s/ide_alloc_host/ide_host_alloc/) (Noticed by Stephen Rothwell). Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
1 parent 374e042 commit 48c3c10

27 files changed

+264
-349
lines changed

drivers/ide/arm/icside.c

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct icside_state {
7272
void __iomem *ioc_base;
7373
unsigned int sel;
7474
unsigned int type;
75-
ide_hwif_t *hwif[2];
75+
struct ide_host *host;
7676
};
7777

7878
#define ICS_TYPE_A3IN 0
@@ -442,10 +442,9 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
442442
static int __init
443443
icside_register_v5(struct icside_state *state, struct expansion_card *ec)
444444
{
445-
ide_hwif_t *hwif;
446445
void __iomem *base;
446+
struct ide_host *host;
447447
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
448-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
449448

450449
base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
451450
if (!base)
@@ -465,17 +464,15 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
465464

466465
icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec);
467466

468-
hwif = ide_find_port();
469-
if (!hwif)
467+
host = ide_host_alloc(NULL, hws);
468+
if (host == NULL)
470469
return -ENODEV;
471470

472-
state->hwif[0] = hwif;
471+
state->host = host;
473472

474473
ecard_set_drvdata(ec, state);
475474

476-
idx[0] = hwif->index;
477-
478-
ide_device_add(idx, NULL, hws);
475+
ide_host_register(host, NULL, hws);
479476

480477
return 0;
481478
}
@@ -492,12 +489,11 @@ static const struct ide_port_info icside_v6_port_info __initdata = {
492489
static int __init
493490
icside_register_v6(struct icside_state *state, struct expansion_card *ec)
494491
{
495-
ide_hwif_t *hwif, *mate;
496492
void __iomem *ioc_base, *easi_base;
493+
struct ide_host *host;
497494
unsigned int sel = 0;
498495
int ret;
499496
hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL };
500-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
501497
struct ide_port_info d = icside_v6_port_info;
502498

503499
ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
@@ -537,25 +533,11 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
537533
icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec);
538534
icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec);
539535

540-
/*
541-
* Find and register the interfaces.
542-
*/
543-
hwif = ide_find_port();
544-
if (hwif == NULL)
536+
host = ide_host_alloc(&d, hws);
537+
if (host == NULL)
545538
return -ENODEV;
546539

547-
hwif->chipset = ide_acorn;
548-
549-
idx[0] = hwif->index;
550-
551-
mate = ide_find_port();
552-
if (mate) {
553-
hws[1] = &hw[1];
554-
idx[1] = mate->index;
555-
}
556-
557-
state->hwif[0] = hwif;
558-
state->hwif[1] = mate;
540+
state->host = host;
559541

560542
ecard_set_drvdata(ec, state);
561543

@@ -565,7 +547,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
565547
d.dma_ops = NULL;
566548
}
567549

568-
ide_device_add(idx, &d, hws);
550+
ide_host_register(host, &d, hws);
569551

570552
return 0;
571553

drivers/ide/arm/ide_arm.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828

2929
static int __init ide_arm_init(void)
3030
{
31-
ide_hwif_t *hwif;
31+
struct ide_host *host;
3232
unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206;
3333
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
34-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
3534

3635
if (!request_region(base, 8, DRV_NAME)) {
3736
printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
@@ -51,12 +50,9 @@ static int __init ide_arm_init(void)
5150
hw.irq = IDE_ARM_IRQ;
5251
hw.chipset = ide_generic;
5352

54-
hwif = ide_find_port();
55-
if (hwif) {
56-
idx[0] = hwif->index;
57-
58-
ide_device_add(idx, NULL, hws);
59-
}
53+
host = ide_host_alloc(NULL, hws);
54+
if (host)
55+
ide_host_register(host, NULL, hws);
6056

6157
return 0;
6258
}

drivers/ide/arm/palm_bk3710.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,10 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
347347
{
348348
struct clk *clk;
349349
struct resource *mem, *irq;
350-
ide_hwif_t *hwif;
350+
struct ide_host *host;
351351
unsigned long base, rate;
352352
int i;
353353
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
354-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
355354

356355
clk = clk_get(NULL, "IDECLK");
357356
if (IS_ERR(clk))
@@ -393,15 +392,11 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
393392
hw.irq = irq->start;
394393
hw.chipset = ide_palm3710;
395394

396-
hwif = ide_find_port();
397-
if (hwif == NULL)
395+
host = ide_host_alloc(&palm_bk3710_port_info, hws);
396+
if (host == NULL)
398397
goto out;
399398

400-
i = hwif->index;
401-
402-
idx[0] = i;
403-
404-
ide_device_add(idx, &palm_bk3710_port_info, hws);
399+
ide_host_register(host, &palm_bk3710_port_info, hws);
405400

406401
return 0;
407402
out:

drivers/ide/arm/rapide.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
3232
static int __devinit
3333
rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
3434
{
35-
ide_hwif_t *hwif;
3635
void __iomem *base;
36+
struct ide_host *host;
3737
int ret;
3838
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
39-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
4039

4140
ret = ecard_request_resources(ec);
4241
if (ret)
@@ -53,17 +52,15 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
5352
hw.chipset = ide_generic;
5453
hw.dev = &ec->dev;
5554

56-
hwif = ide_find_port();
57-
if (hwif == NULL) {
55+
host = ide_host_alloc(&rapide_port_info, hws);
56+
if (host == NULL) {
5857
ret = -ENOENT;
5958
goto release;
6059
}
6160

62-
idx[0] = hwif->index;
61+
ide_host_register(host, &rapide_port_info, hws);
6362

64-
ide_device_add(idx, &rapide_port_info, hws);
65-
66-
ecard_set_drvdata(ec, hwif);
63+
ecard_set_drvdata(ec, host);
6764
goto out;
6865

6966
release:
@@ -74,11 +71,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
7471

7572
static void __devexit rapide_remove(struct expansion_card *ec)
7673
{
77-
ide_hwif_t *hwif = ecard_get_drvdata(ec);
74+
struct ide_host *host = ecard_get_drvdata(ec);
7875

7976
ecard_set_drvdata(ec, NULL);
8077

81-
ide_unregister(hwif);
78+
ide_host_remove(host);
8279

8380
ecard_release_resources(ec);
8481
}

drivers/ide/h8300/ide-h8300.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,8 @@ static const struct ide_port_info h8300_port_info = {
191191

192192
static int __init h8300_ide_init(void)
193193
{
194-
ide_hwif_t *hwif;
195-
int index;
194+
struct ide_host *host;
196195
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
197-
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
198196

199197
printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
200198

@@ -207,15 +205,11 @@ static int __init h8300_ide_init(void)
207205

208206
hw_setup(&hw);
209207

210-
hwif = ide_find_port_slot(&h8300_port_info);
211-
if (hwif == NULL)
208+
host = ide_host_alloc(&h8300_port_info, hws);
209+
if (host == NULL)
212210
return -ENOENT;
213211

214-
index = hwif->index;
215-
216-
idx[0] = index;
217-
218-
ide_device_add(idx, &h8300_port_info, hws);
212+
ide_host_register(host, &h8300_port_info, hws);
219213

220214
return 0;
221215

drivers/ide/ide-generic.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,24 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
2828

2929
static ssize_t store_add(struct class *cls, const char *buf, size_t n)
3030
{
31-
ide_hwif_t *hwif;
31+
struct ide_host *host;
3232
unsigned int base, ctl;
3333
int irq;
3434
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
35-
u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
3635

3736
if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
3837
return -EINVAL;
3938

40-
hwif = ide_find_port();
41-
if (hwif == NULL)
42-
return -ENOENT;
43-
4439
memset(&hw, 0, sizeof(hw));
4540
ide_std_init_ports(&hw, base, ctl);
4641
hw.irq = irq;
4742
hw.chipset = ide_generic;
4843

49-
idx[0] = hwif->index;
44+
host = ide_host_alloc(NULL, hws);
45+
if (host == NULL)
46+
return -ENOENT;
5047

51-
ide_device_add(idx, NULL, hws);
48+
ide_host_register(host, NULL, hws);
5249

5350
return n;
5451
};
@@ -89,18 +86,16 @@ static int __init ide_generic_sysfs_init(void)
8986
static int __init ide_generic_init(void)
9087
{
9188
hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
92-
u8 idx[MAX_HWIFS];
89+
struct ide_host *host;
9390
int i;
9491

9592
printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module "
9693
"parameter for probing all legacy ISA IDE ports\n");
9794

9895
for (i = 0; i < MAX_HWIFS; i++) {
99-
ide_hwif_t *hwif;
10096
unsigned long io_addr = ide_default_io_base(i);
10197

10298
hws[i] = NULL;
103-
idx[i] = 0xff;
10499

105100
if ((probe_mask & (1 << i)) && io_addr) {
106101
if (!request_region(io_addr, 8, DRV_NAME)) {
@@ -118,23 +113,18 @@ static int __init ide_generic_init(void)
118113
continue;
119114
}
120115

121-
hwif = ide_find_port();
122-
if (hwif == NULL)
123-
continue;
124-
125-
hwif->chipset = ide_generic;
126-
127116
memset(&hw[i], 0, sizeof(hw[i]));
128117
ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
129118
hw[i].irq = ide_default_irq(io_addr);
130119
hw[i].chipset = ide_generic;
131120

132121
hws[i] = &hw[i];
133-
idx[i] = i;
134122
}
135123
}
136124

137-
ide_device_add_all(idx, NULL, hws);
125+
host = ide_host_alloc_all(NULL, hws);
126+
if (host)
127+
ide_host_register(host, NULL, hws);
138128

139129
if (ide_generic_sysfs_init())
140130
printk(KERN_ERR DRV_NAME ": failed to create ide_generic "

drivers/ide/ide-pnp.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ 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-
ide_hwif_t *hwif;
32+
struct ide_host *host;
3333
unsigned long base, ctl;
3434
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
3535

@@ -59,14 +59,11 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
5959
hw.irq = pnp_irq(dev, 0);
6060
hw.chipset = ide_generic;
6161

62-
hwif = ide_find_port();
63-
if (hwif) {
64-
u8 index = hwif->index;
65-
u8 idx[4] = { index, 0xff, 0xff, 0xff };
62+
host = ide_host_alloc(NULL, hws);
63+
if (host) {
64+
pnp_set_drvdata(dev, host);
6665

67-
pnp_set_drvdata(dev, hwif);
68-
69-
ide_device_add(idx, NULL, hws);
66+
ide_host_register(host, NULL, hws);
7067

7168
return 0;
7269
}
@@ -79,9 +76,9 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
7976

8077
static void idepnp_remove(struct pnp_dev *dev)
8178
{
82-
ide_hwif_t *hwif = pnp_get_drvdata(dev);
79+
struct ide_host *host = pnp_get_drvdata(dev);
8380

84-
ide_unregister(hwif);
81+
ide_host_remove(host);
8582

8683
release_region(pnp_port_start(dev, 1), 1);
8784
release_region(pnp_port_start(dev, 0), 8);

0 commit comments

Comments
 (0)