diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:57 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:57 -0400 |
commit | 48c3c1072651922ed153bcf0a33ea82cf20df390 (patch) | |
tree | 92ad23e3869e70731eca99394c08a3bf06b8753e /drivers/ide/arm | |
parent | 374e042c3e767ac2e5a40b78529220e0b3de793c (diff) |
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 <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/arm')
-rw-r--r-- | drivers/ide/arm/icside.c | 40 | ||||
-rw-r--r-- | drivers/ide/arm/ide_arm.c | 12 | ||||
-rw-r--r-- | drivers/ide/arm/palm_bk3710.c | 13 | ||||
-rw-r--r-- | drivers/ide/arm/rapide.c | 17 |
4 files changed, 26 insertions, 56 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 0283d162f7f7..6fa58425466a 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -72,7 +72,7 @@ struct icside_state { | |||
72 | void __iomem *ioc_base; | 72 | void __iomem *ioc_base; |
73 | unsigned int sel; | 73 | unsigned int sel; |
74 | unsigned int type; | 74 | unsigned int type; |
75 | ide_hwif_t *hwif[2]; | 75 | struct ide_host *host; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | #define ICS_TYPE_A3IN 0 | 78 | #define ICS_TYPE_A3IN 0 |
@@ -442,10 +442,9 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
442 | static int __init | 442 | static int __init |
443 | icside_register_v5(struct icside_state *state, struct expansion_card *ec) | 443 | icside_register_v5(struct icside_state *state, struct expansion_card *ec) |
444 | { | 444 | { |
445 | ide_hwif_t *hwif; | ||
446 | void __iomem *base; | 445 | void __iomem *base; |
446 | struct ide_host *host; | ||
447 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 447 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
448 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
449 | 448 | ||
450 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); | 449 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
451 | if (!base) | 450 | if (!base) |
@@ -465,17 +464,15 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
465 | 464 | ||
466 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); | 465 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); |
467 | 466 | ||
468 | hwif = ide_find_port(); | 467 | host = ide_host_alloc(NULL, hws); |
469 | if (!hwif) | 468 | if (host == NULL) |
470 | return -ENODEV; | 469 | return -ENODEV; |
471 | 470 | ||
472 | state->hwif[0] = hwif; | 471 | state->host = host; |
473 | 472 | ||
474 | ecard_set_drvdata(ec, state); | 473 | ecard_set_drvdata(ec, state); |
475 | 474 | ||
476 | idx[0] = hwif->index; | 475 | ide_host_register(host, NULL, hws); |
477 | |||
478 | ide_device_add(idx, NULL, hws); | ||
479 | 476 | ||
480 | return 0; | 477 | return 0; |
481 | } | 478 | } |
@@ -492,12 +489,11 @@ static const struct ide_port_info icside_v6_port_info __initdata = { | |||
492 | static int __init | 489 | static int __init |
493 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) | 490 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) |
494 | { | 491 | { |
495 | ide_hwif_t *hwif, *mate; | ||
496 | void __iomem *ioc_base, *easi_base; | 492 | void __iomem *ioc_base, *easi_base; |
493 | struct ide_host *host; | ||
497 | unsigned int sel = 0; | 494 | unsigned int sel = 0; |
498 | int ret; | 495 | int ret; |
499 | hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL }; | 496 | hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL }; |
500 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
501 | struct ide_port_info d = icside_v6_port_info; | 497 | struct ide_port_info d = icside_v6_port_info; |
502 | 498 | ||
503 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 499 | 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) | |||
537 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); | 533 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); |
538 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); | 534 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); |
539 | 535 | ||
540 | /* | 536 | host = ide_host_alloc(&d, hws); |
541 | * Find and register the interfaces. | 537 | if (host == NULL) |
542 | */ | ||
543 | hwif = ide_find_port(); | ||
544 | if (hwif == NULL) | ||
545 | return -ENODEV; | 538 | return -ENODEV; |
546 | 539 | ||
547 | hwif->chipset = ide_acorn; | 540 | state->host = host; |
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; | ||
559 | 541 | ||
560 | ecard_set_drvdata(ec, state); | 542 | ecard_set_drvdata(ec, state); |
561 | 543 | ||
@@ -565,7 +547,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
565 | d.dma_ops = NULL; | 547 | d.dma_ops = NULL; |
566 | } | 548 | } |
567 | 549 | ||
568 | ide_device_add(idx, &d, hws); | 550 | ide_host_register(host, &d, hws); |
569 | 551 | ||
570 | return 0; | 552 | return 0; |
571 | 553 | ||
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index e9831bbd988a..9efd7a86db45 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
@@ -28,10 +28,9 @@ | |||
28 | 28 | ||
29 | static int __init ide_arm_init(void) | 29 | static int __init ide_arm_init(void) |
30 | { | 30 | { |
31 | ide_hwif_t *hwif; | 31 | struct ide_host *host; |
32 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; | 32 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; |
33 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 33 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
35 | 34 | ||
36 | if (!request_region(base, 8, DRV_NAME)) { | 35 | if (!request_region(base, 8, DRV_NAME)) { |
37 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | 36 | 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) | |||
51 | hw.irq = IDE_ARM_IRQ; | 50 | hw.irq = IDE_ARM_IRQ; |
52 | hw.chipset = ide_generic; | 51 | hw.chipset = ide_generic; |
53 | 52 | ||
54 | hwif = ide_find_port(); | 53 | host = ide_host_alloc(NULL, hws); |
55 | if (hwif) { | 54 | if (host) |
56 | idx[0] = hwif->index; | 55 | ide_host_register(host, NULL, hws); |
57 | |||
58 | ide_device_add(idx, NULL, hws); | ||
59 | } | ||
60 | 56 | ||
61 | return 0; | 57 | return 0; |
62 | } | 58 | } |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 545563bc7e23..24389a571c37 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -347,11 +347,10 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
347 | { | 347 | { |
348 | struct clk *clk; | 348 | struct clk *clk; |
349 | struct resource *mem, *irq; | 349 | struct resource *mem, *irq; |
350 | ide_hwif_t *hwif; | 350 | struct ide_host *host; |
351 | unsigned long base, rate; | 351 | unsigned long base, rate; |
352 | int i; | 352 | int i; |
353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
354 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
355 | 354 | ||
356 | clk = clk_get(NULL, "IDECLK"); | 355 | clk = clk_get(NULL, "IDECLK"); |
357 | if (IS_ERR(clk)) | 356 | if (IS_ERR(clk)) |
@@ -393,15 +392,11 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
393 | hw.irq = irq->start; | 392 | hw.irq = irq->start; |
394 | hw.chipset = ide_palm3710; | 393 | hw.chipset = ide_palm3710; |
395 | 394 | ||
396 | hwif = ide_find_port(); | 395 | host = ide_host_alloc(&palm_bk3710_port_info, hws); |
397 | if (hwif == NULL) | 396 | if (host == NULL) |
398 | goto out; | 397 | goto out; |
399 | 398 | ||
400 | i = hwif->index; | 399 | ide_host_register(host, &palm_bk3710_port_info, hws); |
401 | |||
402 | idx[0] = i; | ||
403 | |||
404 | ide_device_add(idx, &palm_bk3710_port_info, hws); | ||
405 | 400 | ||
406 | return 0; | 401 | return 0; |
407 | out: | 402 | out: |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index a45c2f694949..11f3307385de 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -32,11 +32,10 @@ static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
32 | static int __devinit | 32 | static int __devinit |
33 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | 33 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) |
34 | { | 34 | { |
35 | ide_hwif_t *hwif; | ||
36 | void __iomem *base; | 35 | void __iomem *base; |
36 | struct ide_host *host; | ||
37 | int ret; | 37 | int ret; |
38 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 38 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
39 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
40 | 39 | ||
41 | ret = ecard_request_resources(ec); | 40 | ret = ecard_request_resources(ec); |
42 | if (ret) | 41 | if (ret) |
@@ -53,17 +52,15 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
53 | hw.chipset = ide_generic; | 52 | hw.chipset = ide_generic; |
54 | hw.dev = &ec->dev; | 53 | hw.dev = &ec->dev; |
55 | 54 | ||
56 | hwif = ide_find_port(); | 55 | host = ide_host_alloc(&rapide_port_info, hws); |
57 | if (hwif == NULL) { | 56 | if (host == NULL) { |
58 | ret = -ENOENT; | 57 | ret = -ENOENT; |
59 | goto release; | 58 | goto release; |
60 | } | 59 | } |
61 | 60 | ||
62 | idx[0] = hwif->index; | 61 | ide_host_register(host, &rapide_port_info, hws); |
63 | 62 | ||
64 | ide_device_add(idx, &rapide_port_info, hws); | 63 | ecard_set_drvdata(ec, host); |
65 | |||
66 | ecard_set_drvdata(ec, hwif); | ||
67 | goto out; | 64 | goto out; |
68 | 65 | ||
69 | release: | 66 | release: |
@@ -74,11 +71,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
74 | 71 | ||
75 | static void __devexit rapide_remove(struct expansion_card *ec) | 72 | static void __devexit rapide_remove(struct expansion_card *ec) |
76 | { | 73 | { |
77 | ide_hwif_t *hwif = ecard_get_drvdata(ec); | 74 | struct ide_host *host = ecard_get_drvdata(ec); |
78 | 75 | ||
79 | ecard_set_drvdata(ec, NULL); | 76 | ecard_set_drvdata(ec, NULL); |
80 | 77 | ||
81 | ide_unregister(hwif); | 78 | ide_host_remove(host); |
82 | 79 | ||
83 | ecard_release_resources(ec); | 80 | ecard_release_resources(ec); |
84 | } | 81 | } |