This source file includes following definitions.
- ide_device_get
- ide_device_put
- ide_bus_match
- ide_uevent
- generic_ide_probe
- generic_ide_remove
- generic_ide_shutdown
- ide_set_dev_param_mask
- ide_set_disk_chs
- ide_dev_apply_params
- ide_set_ignore_cable
- ide_port_apply_params
- ide_init
- ide_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 #include <linux/module.h>
49 #include <linux/types.h>
50 #include <linux/string.h>
51 #include <linux/kernel.h>
52 #include <linux/interrupt.h>
53 #include <linux/major.h>
54 #include <linux/errno.h>
55 #include <linux/genhd.h>
56 #include <linux/init.h>
57 #include <linux/pci.h>
58 #include <linux/ide.h>
59 #include <linux/hdreg.h>
60 #include <linux/completion.h>
61 #include <linux/device.h>
62
63 struct class *ide_port_class;
64
65
66
67
68
69
70
71
72 int ide_device_get(ide_drive_t *drive)
73 {
74 struct device *host_dev;
75 struct module *module;
76
77 if (!get_device(&drive->gendev))
78 return -ENXIO;
79
80 host_dev = drive->hwif->host->dev[0];
81 module = host_dev ? host_dev->driver->owner : NULL;
82
83 if (module && !try_module_get(module)) {
84 put_device(&drive->gendev);
85 return -ENXIO;
86 }
87
88 return 0;
89 }
90 EXPORT_SYMBOL_GPL(ide_device_get);
91
92
93
94
95
96
97
98
99 void ide_device_put(ide_drive_t *drive)
100 {
101 #ifdef CONFIG_MODULE_UNLOAD
102 struct device *host_dev = drive->hwif->host->dev[0];
103 struct module *module = host_dev ? host_dev->driver->owner : NULL;
104
105 module_put(module);
106 #endif
107 put_device(&drive->gendev);
108 }
109 EXPORT_SYMBOL_GPL(ide_device_put);
110
111 static int ide_bus_match(struct device *dev, struct device_driver *drv)
112 {
113 return 1;
114 }
115
116 static int ide_uevent(struct device *dev, struct kobj_uevent_env *env)
117 {
118 ide_drive_t *drive = to_ide_device(dev);
119
120 add_uevent_var(env, "MEDIA=%s", ide_media_string(drive));
121 add_uevent_var(env, "DRIVENAME=%s", drive->name);
122 add_uevent_var(env, "MODALIAS=ide:m-%s", ide_media_string(drive));
123 return 0;
124 }
125
126 static int generic_ide_probe(struct device *dev)
127 {
128 ide_drive_t *drive = to_ide_device(dev);
129 struct ide_driver *drv = to_ide_driver(dev->driver);
130
131 return drv->probe ? drv->probe(drive) : -ENODEV;
132 }
133
134 static int generic_ide_remove(struct device *dev)
135 {
136 ide_drive_t *drive = to_ide_device(dev);
137 struct ide_driver *drv = to_ide_driver(dev->driver);
138
139 if (drv->remove)
140 drv->remove(drive);
141
142 return 0;
143 }
144
145 static void generic_ide_shutdown(struct device *dev)
146 {
147 ide_drive_t *drive = to_ide_device(dev);
148 struct ide_driver *drv = to_ide_driver(dev->driver);
149
150 if (dev->driver && drv->shutdown)
151 drv->shutdown(drive);
152 }
153
154 struct bus_type ide_bus_type = {
155 .name = "ide",
156 .match = ide_bus_match,
157 .uevent = ide_uevent,
158 .probe = generic_ide_probe,
159 .remove = generic_ide_remove,
160 .shutdown = generic_ide_shutdown,
161 .dev_groups = ide_dev_groups,
162 .suspend = generic_ide_suspend,
163 .resume = generic_ide_resume,
164 };
165
166 EXPORT_SYMBOL_GPL(ide_bus_type);
167
168 int ide_vlb_clk;
169 EXPORT_SYMBOL_GPL(ide_vlb_clk);
170
171 module_param_named(vlb_clock, ide_vlb_clk, int, 0);
172 MODULE_PARM_DESC(vlb_clock, "VLB clock frequency (in MHz)");
173
174 int ide_pci_clk;
175 EXPORT_SYMBOL_GPL(ide_pci_clk);
176
177 module_param_named(pci_clock, ide_pci_clk, int, 0);
178 MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)");
179
180 static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp)
181 {
182 unsigned int a, b, i, j = 1;
183 unsigned int *dev_param_mask = (unsigned int *)kp->arg;
184
185
186 if (sscanf(s, "%u.%u:%u", &a, &b, &j) != 3 &&
187 sscanf(s, "%u.%u", &a, &b) != 2)
188 return -EINVAL;
189
190 i = a * MAX_DRIVES + b;
191
192 if (i >= MAX_HWIFS * MAX_DRIVES || j > 1)
193 return -EINVAL;
194
195 if (j)
196 *dev_param_mask |= (1 << i);
197 else
198 *dev_param_mask &= ~(1 << i);
199
200 return 0;
201 }
202
203 static const struct kernel_param_ops param_ops_ide_dev_mask = {
204 .set = ide_set_dev_param_mask
205 };
206
207 #define param_check_ide_dev_mask(name, p) param_check_uint(name, p)
208
209 static unsigned int ide_nodma;
210
211 module_param_named(nodma, ide_nodma, ide_dev_mask, 0);
212 MODULE_PARM_DESC(nodma, "disallow DMA for a device");
213
214 static unsigned int ide_noflush;
215
216 module_param_named(noflush, ide_noflush, ide_dev_mask, 0);
217 MODULE_PARM_DESC(noflush, "disable flush requests for a device");
218
219 static unsigned int ide_nohpa;
220
221 module_param_named(nohpa, ide_nohpa, ide_dev_mask, 0);
222 MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device");
223
224 static unsigned int ide_noprobe;
225
226 module_param_named(noprobe, ide_noprobe, ide_dev_mask, 0);
227 MODULE_PARM_DESC(noprobe, "skip probing for a device");
228
229 static unsigned int ide_nowerr;
230
231 module_param_named(nowerr, ide_nowerr, ide_dev_mask, 0);
232 MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device");
233
234 static unsigned int ide_cdroms;
235
236 module_param_named(cdrom, ide_cdroms, ide_dev_mask, 0);
237 MODULE_PARM_DESC(cdrom, "force device as a CD-ROM");
238
239 struct chs_geom {
240 unsigned int cyl;
241 u8 head;
242 u8 sect;
243 };
244
245 static unsigned int ide_disks;
246 static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES];
247
248 static int ide_set_disk_chs(const char *str, const struct kernel_param *kp)
249 {
250 unsigned int a, b, c = 0, h = 0, s = 0, i, j = 1;
251
252
253
254 if (sscanf(str, "%u.%u:%u,%u,%u", &a, &b, &c, &h, &s) != 5 &&
255 sscanf(str, "%u.%u:%u", &a, &b, &j) != 3)
256 return -EINVAL;
257
258 i = a * MAX_DRIVES + b;
259
260 if (i >= MAX_HWIFS * MAX_DRIVES || j > 1)
261 return -EINVAL;
262
263 if (c > INT_MAX || h > 255 || s > 255)
264 return -EINVAL;
265
266 if (j)
267 ide_disks |= (1 << i);
268 else
269 ide_disks &= ~(1 << i);
270
271 ide_disks_chs[i].cyl = c;
272 ide_disks_chs[i].head = h;
273 ide_disks_chs[i].sect = s;
274
275 return 0;
276 }
277
278 module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0);
279 MODULE_PARM_DESC(chs, "force device as a disk (using CHS)");
280
281 static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
282 {
283 int i = drive->hwif->index * MAX_DRIVES + unit;
284
285 if (ide_nodma & (1 << i)) {
286 printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name);
287 drive->dev_flags |= IDE_DFLAG_NODMA;
288 }
289 if (ide_noflush & (1 << i)) {
290 printk(KERN_INFO "ide: disabling flush requests for %s\n",
291 drive->name);
292 drive->dev_flags |= IDE_DFLAG_NOFLUSH;
293 }
294 if (ide_nohpa & (1 << i)) {
295 printk(KERN_INFO "ide: disabling Host Protected Area for %s\n",
296 drive->name);
297 drive->dev_flags |= IDE_DFLAG_NOHPA;
298 }
299 if (ide_noprobe & (1 << i)) {
300 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
301 drive->dev_flags |= IDE_DFLAG_NOPROBE;
302 }
303 if (ide_nowerr & (1 << i)) {
304 printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n",
305 drive->name);
306 drive->bad_wstat = BAD_R_STAT;
307 }
308 if (ide_cdroms & (1 << i)) {
309 printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name);
310 drive->dev_flags |= IDE_DFLAG_PRESENT;
311 drive->media = ide_cdrom;
312
313 drive->ready_stat = 0;
314 }
315 if (ide_disks & (1 << i)) {
316 drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl;
317 drive->head = drive->bios_head = ide_disks_chs[i].head;
318 drive->sect = drive->bios_sect = ide_disks_chs[i].sect;
319
320 printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n",
321 drive->name,
322 drive->cyl, drive->head, drive->sect);
323
324 drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT;
325 drive->media = ide_disk;
326 drive->ready_stat = ATA_DRDY;
327 }
328 }
329
330 static unsigned int ide_ignore_cable;
331
332 static int ide_set_ignore_cable(const char *s, const struct kernel_param *kp)
333 {
334 int i, j = 1;
335
336
337
338 if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1)
339 return -EINVAL;
340
341 if (i >= MAX_HWIFS || j < 0 || j > 1)
342 return -EINVAL;
343
344 if (j)
345 ide_ignore_cable |= (1 << i);
346 else
347 ide_ignore_cable &= ~(1 << i);
348
349 return 0;
350 }
351
352 module_param_call(ignore_cable, ide_set_ignore_cable, NULL, NULL, 0);
353 MODULE_PARM_DESC(ignore_cable, "ignore cable detection");
354
355 void ide_port_apply_params(ide_hwif_t *hwif)
356 {
357 ide_drive_t *drive;
358 int i;
359
360 if (ide_ignore_cable & (1 << hwif->index)) {
361 printk(KERN_INFO "ide: ignoring cable detection for %s\n",
362 hwif->name);
363 hwif->cbl = ATA_CBL_PATA40_SHORT;
364 }
365
366 ide_port_for_each_dev(i, drive, hwif)
367 ide_dev_apply_params(drive, i);
368 }
369
370
371
372
373 static int __init ide_init(void)
374 {
375 int ret;
376
377 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n");
378
379 ret = bus_register(&ide_bus_type);
380 if (ret < 0) {
381 printk(KERN_WARNING "IDE: bus_register error: %d\n", ret);
382 return ret;
383 }
384
385 ide_port_class = class_create(THIS_MODULE, "ide_port");
386 if (IS_ERR(ide_port_class)) {
387 ret = PTR_ERR(ide_port_class);
388 goto out_port_class;
389 }
390
391 ide_acpi_init();
392
393 proc_ide_create();
394
395 return 0;
396
397 out_port_class:
398 bus_unregister(&ide_bus_type);
399
400 return ret;
401 }
402
403 static void __exit ide_exit(void)
404 {
405 proc_ide_destroy();
406
407 class_destroy(ide_port_class);
408
409 bus_unregister(&ide_bus_type);
410 }
411
412 module_init(ide_init);
413 module_exit(ide_exit);
414
415 MODULE_LICENSE("GPL");