aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-generic.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:57 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:57 -0400
commit48c3c1072651922ed153bcf0a33ea82cf20df390 (patch)
tree92ad23e3869e70731eca99394c08a3bf06b8753e /drivers/ide/ide-generic.c
parent374e042c3e767ac2e5a40b78529220e0b3de793c (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/ide-generic.c')
-rw-r--r--drivers/ide/ide-generic.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index a5c352abff59..e8818362eb46 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -28,27 +28,24 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
28 28
29static ssize_t store_add(struct class *cls, const char *buf, size_t n) 29static ssize_t store_add(struct class *cls, const char *buf, size_t n)
30{ 30{
31 ide_hwif_t *hwif; 31 struct ide_host *host;
32 unsigned int base, ctl; 32 unsigned int base, ctl;
33 int irq; 33 int irq;
34 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 34 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
35 u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
36 35
37 if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) 36 if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
38 return -EINVAL; 37 return -EINVAL;
39 38
40 hwif = ide_find_port();
41 if (hwif == NULL)
42 return -ENOENT;
43
44 memset(&hw, 0, sizeof(hw)); 39 memset(&hw, 0, sizeof(hw));
45 ide_std_init_ports(&hw, base, ctl); 40 ide_std_init_ports(&hw, base, ctl);
46 hw.irq = irq; 41 hw.irq = irq;
47 hw.chipset = ide_generic; 42 hw.chipset = ide_generic;
48 43
49 idx[0] = hwif->index; 44 host = ide_host_alloc(NULL, hws);
45 if (host == NULL)
46 return -ENOENT;
50 47
51 ide_device_add(idx, NULL, hws); 48 ide_host_register(host, NULL, hws);
52 49
53 return n; 50 return n;
54}; 51};
@@ -89,18 +86,16 @@ static int __init ide_generic_sysfs_init(void)
89static int __init ide_generic_init(void) 86static int __init ide_generic_init(void)
90{ 87{
91 hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; 88 hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
92 u8 idx[MAX_HWIFS]; 89 struct ide_host *host;
93 int i; 90 int i;
94 91
95 printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " 92 printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module "
96 "parameter for probing all legacy ISA IDE ports\n"); 93 "parameter for probing all legacy ISA IDE ports\n");
97 94
98 for (i = 0; i < MAX_HWIFS; i++) { 95 for (i = 0; i < MAX_HWIFS; i++) {
99 ide_hwif_t *hwif;
100 unsigned long io_addr = ide_default_io_base(i); 96 unsigned long io_addr = ide_default_io_base(i);
101 97
102 hws[i] = NULL; 98 hws[i] = NULL;
103 idx[i] = 0xff;
104 99
105 if ((probe_mask & (1 << i)) && io_addr) { 100 if ((probe_mask & (1 << i)) && io_addr) {
106 if (!request_region(io_addr, 8, DRV_NAME)) { 101 if (!request_region(io_addr, 8, DRV_NAME)) {
@@ -118,23 +113,18 @@ static int __init ide_generic_init(void)
118 continue; 113 continue;
119 } 114 }
120 115
121 hwif = ide_find_port();
122 if (hwif == NULL)
123 continue;
124
125 hwif->chipset = ide_generic;
126
127 memset(&hw[i], 0, sizeof(hw[i])); 116 memset(&hw[i], 0, sizeof(hw[i]));
128 ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); 117 ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
129 hw[i].irq = ide_default_irq(io_addr); 118 hw[i].irq = ide_default_irq(io_addr);
130 hw[i].chipset = ide_generic; 119 hw[i].chipset = ide_generic;
131 120
132 hws[i] = &hw[i]; 121 hws[i] = &hw[i];
133 idx[i] = i;
134 } 122 }
135 } 123 }
136 124
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);
138 128
139 if (ide_generic_sysfs_init()) 129 if (ide_generic_sysfs_init())
140 printk(KERN_ERR DRV_NAME ": failed to create ide_generic " 130 printk(KERN_ERR DRV_NAME ": failed to create ide_generic "