diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-01-06 11:20:51 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-01-06 11:20:51 -0500 |
commit | b40d1b88f1001f0224c63fa2c008914514bcef33 (patch) | |
tree | 84b86e05c8b9218366871fef77b1ea0f2ae09da8 /drivers/ide/ide.c | |
parent | ff670e632e818535950d9e31d9d0dcfc7d5b4090 (diff) |
ide: move ide_init_port_data() and friends to ide-probe.c
* Move IDE_DEFAULT_MAX_FAILURES to <linux/ide.h>.
* Move ide_cfg_mtx, ide_hwif_to_major[], ide_port_init_devices_data(),
ide_init_port_data(), ide_init_port_hw() and ide_unregister() to
ide-probe.c from ide.c.
* Make ide_unregister(), ide_init_port_data(), ide_init_port_hw()
and ide_cfg_mtx static.
While at it:
* Remove stale ide_init_port_data() documentation and ide_lock extern.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r-- | drivers/ide/ide.c | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 6538b63158bf..c1bb0f6784a9 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -60,154 +60,8 @@ | |||
60 | #include <linux/completion.h> | 60 | #include <linux/completion.h> |
61 | #include <linux/device.h> | 61 | #include <linux/device.h> |
62 | 62 | ||
63 | |||
64 | /* default maximum number of failures */ | ||
65 | #define IDE_DEFAULT_MAX_FAILURES 1 | ||
66 | |||
67 | struct class *ide_port_class; | 63 | struct class *ide_port_class; |
68 | 64 | ||
69 | static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, | ||
70 | IDE2_MAJOR, IDE3_MAJOR, | ||
71 | IDE4_MAJOR, IDE5_MAJOR, | ||
72 | IDE6_MAJOR, IDE7_MAJOR, | ||
73 | IDE8_MAJOR, IDE9_MAJOR }; | ||
74 | |||
75 | DEFINE_MUTEX(ide_cfg_mtx); | ||
76 | |||
77 | static void ide_port_init_devices_data(ide_hwif_t *); | ||
78 | |||
79 | /* | ||
80 | * Do not even *think* about calling this! | ||
81 | */ | ||
82 | void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | ||
83 | { | ||
84 | /* bulk initialize hwif & drive info with zeros */ | ||
85 | memset(hwif, 0, sizeof(ide_hwif_t)); | ||
86 | |||
87 | /* fill in any non-zero initial values */ | ||
88 | hwif->index = index; | ||
89 | hwif->major = ide_hwif_to_major[index]; | ||
90 | |||
91 | hwif->name[0] = 'i'; | ||
92 | hwif->name[1] = 'd'; | ||
93 | hwif->name[2] = 'e'; | ||
94 | hwif->name[3] = '0' + index; | ||
95 | |||
96 | init_completion(&hwif->gendev_rel_comp); | ||
97 | |||
98 | hwif->tp_ops = &default_tp_ops; | ||
99 | |||
100 | ide_port_init_devices_data(hwif); | ||
101 | } | ||
102 | |||
103 | static void ide_port_init_devices_data(ide_hwif_t *hwif) | ||
104 | { | ||
105 | int unit; | ||
106 | |||
107 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
108 | ide_drive_t *drive = &hwif->drives[unit]; | ||
109 | u8 j = (hwif->index * MAX_DRIVES) + unit; | ||
110 | |||
111 | memset(drive, 0, sizeof(*drive)); | ||
112 | |||
113 | drive->media = ide_disk; | ||
114 | drive->select = (unit << 4) | ATA_DEVICE_OBS; | ||
115 | drive->hwif = hwif; | ||
116 | drive->ready_stat = ATA_DRDY; | ||
117 | drive->bad_wstat = BAD_W_STAT; | ||
118 | drive->special.b.recalibrate = 1; | ||
119 | drive->special.b.set_geometry = 1; | ||
120 | drive->name[0] = 'h'; | ||
121 | drive->name[1] = 'd'; | ||
122 | drive->name[2] = 'a' + j; | ||
123 | drive->max_failures = IDE_DEFAULT_MAX_FAILURES; | ||
124 | |||
125 | INIT_LIST_HEAD(&drive->list); | ||
126 | init_completion(&drive->gendev_rel_comp); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | static void __ide_port_unregister_devices(ide_hwif_t *hwif) | ||
131 | { | ||
132 | int i; | ||
133 | |||
134 | for (i = 0; i < MAX_DRIVES; i++) { | ||
135 | ide_drive_t *drive = &hwif->drives[i]; | ||
136 | |||
137 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | ||
138 | device_unregister(&drive->gendev); | ||
139 | wait_for_completion(&drive->gendev_rel_comp); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | void ide_port_unregister_devices(ide_hwif_t *hwif) | ||
145 | { | ||
146 | mutex_lock(&ide_cfg_mtx); | ||
147 | __ide_port_unregister_devices(hwif); | ||
148 | hwif->present = 0; | ||
149 | ide_port_init_devices_data(hwif); | ||
150 | mutex_unlock(&ide_cfg_mtx); | ||
151 | } | ||
152 | EXPORT_SYMBOL_GPL(ide_port_unregister_devices); | ||
153 | |||
154 | /** | ||
155 | * ide_unregister - free an IDE interface | ||
156 | * @hwif: IDE interface | ||
157 | * | ||
158 | * Perform the final unregister of an IDE interface. | ||
159 | * | ||
160 | * Locking: | ||
161 | * The caller must not hold the IDE locks. | ||
162 | * | ||
163 | * It is up to the caller to be sure there is no pending I/O here, | ||
164 | * and that the interface will not be reopened (present/vanishing | ||
165 | * locking isn't yet done BTW). | ||
166 | */ | ||
167 | |||
168 | void ide_unregister(ide_hwif_t *hwif) | ||
169 | { | ||
170 | BUG_ON(in_interrupt()); | ||
171 | BUG_ON(irqs_disabled()); | ||
172 | |||
173 | mutex_lock(&ide_cfg_mtx); | ||
174 | |||
175 | if (hwif->present) { | ||
176 | __ide_port_unregister_devices(hwif); | ||
177 | hwif->present = 0; | ||
178 | } | ||
179 | |||
180 | ide_proc_unregister_port(hwif); | ||
181 | |||
182 | free_irq(hwif->irq, hwif); | ||
183 | |||
184 | device_unregister(hwif->portdev); | ||
185 | device_unregister(&hwif->gendev); | ||
186 | wait_for_completion(&hwif->gendev_rel_comp); | ||
187 | |||
188 | /* | ||
189 | * Remove us from the kernel's knowledge | ||
190 | */ | ||
191 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); | ||
192 | kfree(hwif->sg_table); | ||
193 | unregister_blkdev(hwif->major, hwif->name); | ||
194 | |||
195 | ide_release_dma_engine(hwif); | ||
196 | |||
197 | mutex_unlock(&ide_cfg_mtx); | ||
198 | } | ||
199 | |||
200 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | ||
201 | { | ||
202 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | ||
203 | hwif->irq = hw->irq; | ||
204 | hwif->chipset = hw->chipset; | ||
205 | hwif->dev = hw->dev; | ||
206 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | ||
207 | hwif->ack_intr = hw->ack_intr; | ||
208 | hwif->config_data = hw->config; | ||
209 | } | ||
210 | |||
211 | /* | 65 | /* |
212 | * Locks for IDE setting functionality | 66 | * Locks for IDE setting functionality |
213 | */ | 67 | */ |