2 * linux/drivers/ide/ide-proc.c Version 1.03 January 2, 1998
4 * Copyright (C) 1997-1998 Mark Lord
8 * This is the /proc/ide/ filesystem implementation.
10 * The major reason this exists is to provide sufficient access
11 * to driver and config data, such that user-mode programs can
12 * be developed to handle chipset tuning for most PCI interfaces.
13 * This should provide better utilities, and less kernel bloat.
15 * The entire pci config space for a PCI interface chipset can be
16 * retrieved by just reading it. e.g. "cat /proc/ide3/config"
18 * To modify registers *safely*, do something like:
19 * echo "P40:88" >/proc/ide/ide3/config
20 * That expression writes 0x88 to pci config register 0x40
21 * on the chip which controls ide3. Multiple tuples can be issued,
22 * and the writes will be completed as an atomic set:
23 * echo "P40:88 P41:35 P42:00 P43:00" >/proc/ide/ide3/config
25 * All numbers must be specified using pairs of ascii hex digits.
26 * It is important to note that these writes will be performed
27 * after waiting for the IDE controller (both interfaces)
28 * to be completely idle, to ensure no corruption of I/O in progress.
30 * Non-PCI registers can also be written, using "R" in place of "P"
31 * in the above examples. The size of the port transfer is determined
32 * by the number of pairs of hex digits given for the data. If a two
33 * digit value is given, the write will be a byte operation; if four
34 * digits are used, the write will be performed as a 16-bit operation;
35 * and if eight digits are specified, a 32-bit "dword" write will be
36 * performed. Odd numbers of digits are not permitted.
38 * If there is an error *anywhere* in the string of registers/data
39 * then *none* of the writes will be performed.
41 * Drive/Driver settings can be retrieved by reading the drive's
42 * "settings" files. e.g. "cat /proc/ide0/hda/settings"
43 * To write a new value "val" into a specific setting "name", use:
44 * echo "name:val" >/proc/ide/ide0/hda/settings
46 * Also useful, "cat /proc/ide0/hda/[identify, smart_values,
47 * smart_thresholds, capabilities]" will issue an IDENTIFY /
48 * PACKET_IDENTIFY / SMART_READ_VALUES / SMART_READ_THRESHOLDS /
49 * SENSE CAPABILITIES command to /dev/hda, and then dump out the
50 * returned data as 256 16-bit words. The "hdparm" utility will
51 * be updated someday soon to use this mechanism.
53 * Feel free to develop and distribute fancy GUI configuration
54 * utilities for your favorite PCI chipsets. I'll be working on
55 * one for the Promise 20246 someday soon. -ml
59 #include <linux/config.h>
60 #define __NO_VERSION__
61 #include <linux/module.h>
63 #include <asm/uaccess.h>
64 #include <linux/errno.h>
65 #include <linux/sched.h>
66 #include <linux/proc_fs.h>
67 #include <linux/stat.h>
69 #include <linux/pci.h>
70 #include <linux/ctype.h>
71 #include <linux/hdreg.h>
72 #include <linux/ide.h>
78 #include <asm/pci-bridge.h>
82 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
85 static int ide_getxdigit(char c)
91 digit = tolower(c) - 'a' + 10;
97 static int xx_xx_parse_error (const char *data, unsigned long len, const char *msg)
101 if (len >= sizeof(errbuf))
102 len = sizeof(errbuf) - 1;
103 for (i = 0; i < len; ++i) {
112 printk("proc_ide: error: %s: '%s'\n", msg, errbuf);
116 static struct proc_dir_entry * proc_ide_root = NULL;
118 #ifdef CONFIG_BLK_DEV_IDEPCI
119 #include <linux/delay.h>
121 * This is the list of registered PCI chipset driver data structures.
123 static ide_pci_host_proc_t * ide_pci_host_proc_list;
125 #endif /* CONFIG_BLK_DEV_IDEPCI */
129 static int proc_ide_write_config
130 (struct file *file, const char *buffer, unsigned long count, void *data)
132 ide_hwif_t *hwif = (ide_hwif_t *)data;
134 unsigned long startn = 0, n, flags;
135 const char *start = NULL, *msg = NULL;
137 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
140 * Skip over leading whitespace
142 while (count && isspace(*buffer)) {
147 * Do one full pass to verify all parameters,
148 * then do another to actually write the regs.
151 save_flags(flags); /* all CPUs */
153 spin_lock_irqsave(&io_request_lock, flags);
158 unsigned long timeout = jiffies + (3 * HZ);
159 ide_hwgroup_t *mygroup = (ide_hwgroup_t *)(hwif->hwgroup);
160 ide_hwgroup_t *mategroup = NULL;
161 if (hwif->mate && hwif->mate->hwgroup)
162 mategroup = (ide_hwgroup_t *)(hwif->mate->hwgroup);
164 cli(); /* all CPUs; ensure all writes are done together */
166 spin_lock_irqsave(&io_request_lock, flags);
168 while (mygroup->busy ||
169 (mategroup && mategroup->busy)) {
171 sti(); /* all CPUs */
173 spin_unlock_irqrestore(&io_request_lock, flags);
175 if (time_after(jiffies, timeout)) {
176 printk("/proc/ide/%s/config: channel(s) busy, cannot write\n", hwif->name);
178 restore_flags(flags); /* all CPUs */
180 spin_unlock_irqrestore(&io_request_lock, flags);
185 cli(); /* all CPUs */
187 spin_lock_irqsave(&io_request_lock, flags);
195 unsigned int reg = 0, val = 0, is_pci;
199 case 'R': is_pci = 0;
201 case 'P': is_pci = 1;
202 #ifdef CONFIG_BLK_DEV_IDEPCI
203 if (hwif->pci_dev && !hwif->pci_dev->vendor)
205 #endif /* CONFIG_BLK_DEV_IDEPCI */
206 msg = "not a PCI device";
208 default: msg = "expected 'R' or 'P'";
212 while (n > 0 && (d = ide_getxdigit(*p)) >= 0) {
213 reg = (reg << 4) | d;
218 if (!digits || (digits > 4) || (is_pci && reg > 0xff)) {
219 msg = "bad/missing register number";
222 if (n-- == 0 || *p++ != ':') {
227 while (n > 0 && (d = ide_getxdigit(*p)) >= 0) {
228 val = (val << 4) | d;
233 if (digits != 2 && digits != 4 && digits != 8) {
234 msg = "bad data, 2/4/8 digits required";
237 if (n > 0 && !isspace(*p)) {
238 msg = "expected whitespace after data";
241 while (n > 0 && isspace(*p)) {
245 #ifdef CONFIG_BLK_DEV_IDEPCI
246 if (is_pci && (reg & ((digits >> 1) - 1))) {
247 msg = "misaligned access";
250 #endif /* CONFIG_BLK_DEV_IDEPCI */
253 printk("proc_ide_write_config: type=%c, reg=0x%x, val=0x%x, digits=%d\n", is_pci ? "PCI" : "non-PCI", reg, val, digits);
256 #ifdef CONFIG_BLK_DEV_IDEPCI
258 struct pci_dev *dev = hwif->pci_dev;
260 case 2: msg = "byte";
261 rc = pci_write_config_byte(dev, reg, val);
263 case 4: msg = "word";
264 rc = pci_write_config_word(dev, reg, val);
266 case 8: msg = "dword";
267 rc = pci_write_config_dword(dev, reg, val);
272 restore_flags(flags); /* all CPUs */
274 spin_unlock_irqrestore(&io_request_lock, flags);
276 printk("proc_ide_write_config: error writing %s at bus %02x dev %02x reg 0x%x value 0x%x\n",
277 msg, dev->bus->number, dev->devfn, reg, val);
278 printk("proc_ide_write_config: error %d\n", rc);
281 #endif /* CONFIG_BLK_DEV_IDEPCI */
282 } else { /* not pci */
283 #if !defined(__mc68000__) && !defined(CONFIG_APUS)
288 * unless you can explain me what it really does.
289 * On m68k, we don't have outw() and outl() yet,
290 * and I need a good reason to implement it.
292 * BTW, IMHO the main remaining portability problem with the IDE driver
293 * is that it mixes IO (ioport) and MMIO (iomem) access on different platforms.
295 * I think all accesses should be done using
297 * ide_in[bwl](ide_device_instance, offset)
298 * ide_out[bwl](ide_device_instance, value, offset)
300 * so the architecture specific code can #define ide_{in,out}[bwl] to the
301 * appropriate function.
305 case 2: hwif->OUTB(val, reg);
307 case 4: hwif->OUTW(val, reg);
309 case 8: hwif->OUTL(val, reg);
312 #endif /* !__mc68000__ && !CONFIG_APUS */
316 } while (!for_real++);
318 restore_flags(flags); /* all CPUs */
320 spin_unlock_irqrestore(&io_request_lock, flags);
325 restore_flags(flags); /* all CPUs */
327 spin_unlock_irqrestore(&io_request_lock, flags);
329 printk("parse error\n");
330 return xx_xx_parse_error(start, startn, msg);
333 int proc_ide_read_config
334 (char *page, char **start, off_t off, int count, int *eof, void *data)
339 #ifdef CONFIG_BLK_DEV_IDEPCI
340 ide_hwif_t *hwif = (ide_hwif_t *)data;
341 struct pci_dev *dev = hwif->pci_dev;
342 if ((hwif->pci_dev && hwif->pci_dev->vendor) && dev && dev->bus) {
345 out += sprintf(out, "pci bus %02x device %02x vendor %04x "
346 "device %04x channel %d\n",
347 dev->bus->number, dev->devfn,
348 hwif->pci_dev->vendor, hwif->pci_dev->device,
352 int rc = pci_read_config_byte(dev, reg, &val);
354 printk("proc_ide_read_config: error %d reading"
355 " bus %02x dev %02x reg 0x%02x\n",
356 rc, dev->bus->number, dev->devfn, reg);
357 out += sprintf(out, "??%c",
358 (++reg & 0xf) ? ' ' : '\n');
360 out += sprintf(out, "%02x%c",
361 val, (++reg & 0xf) ? ' ' : '\n');
362 } while (reg < 0x100);
364 #endif /* CONFIG_BLK_DEV_IDEPCI */
365 out += sprintf(out, "(none)\n");
367 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
370 EXPORT_SYMBOL(proc_ide_read_config);
372 static int ide_getdigit(char c)
382 int proc_ide_read_drivers
383 (char *page, char **start, off_t off, int count, int *eof, void *data)
387 ide_module_t *p = ide_modules;
388 ide_driver_t *driver;
391 driver = (ide_driver_t *) p->info;
393 out += sprintf(out, "%s version %s\n",
394 driver->name, driver->version);
398 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
401 EXPORT_SYMBOL(proc_ide_read_drivers);
403 int proc_ide_read_imodel
404 (char *page, char **start, off_t off, int count, int *eof, void *data)
406 ide_hwif_t *hwif = (ide_hwif_t *) data;
410 switch (hwif->chipset) {
411 case ide_unknown: name = "(none)"; break;
412 case ide_generic: name = "generic"; break;
413 case ide_pci: name = "pci"; break;
414 case ide_cmd640: name = "cmd640"; break;
415 case ide_dtc2278: name = "dtc2278"; break;
416 case ide_ali14xx: name = "ali14xx"; break;
417 case ide_qd65xx: name = "qd65xx"; break;
418 case ide_umc8672: name = "umc8672"; break;
419 case ide_ht6560b: name = "ht6560b"; break;
420 case ide_pdc4030: name = "pdc4030"; break;
421 case ide_rz1000: name = "rz1000"; break;
422 case ide_trm290: name = "trm290"; break;
423 case ide_cmd646: name = "cmd646"; break;
424 case ide_cy82c693: name = "cy82c693"; break;
425 case ide_4drives: name = "4drives"; break;
426 case ide_pmac: name = "pmac"; break;
427 default: name = "(unknown)"; break;
429 len = sprintf(page, "%s\n", name);
430 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
433 #ifdef CONFIG_ALL_PPC
434 static int proc_ide_read_devspec
435 (char *page, char **start, off_t off, int count, int *eof, void *data)
437 ide_hwif_t *hwif = (ide_hwif_t *) data;
439 struct device_node *ofnode = NULL;
441 #ifdef CONFIG_BLK_DEV_IDE_PMAC
442 extern struct device_node* pmac_ide_get_of_node(int index);
443 if (hwif->chipset == ide_pmac)
444 ofnode = pmac_ide_get_of_node(hwif->index);
445 #endif /* CONFIG_BLK_DEV_IDE_PMAC */
447 if (ofnode == NULL && hwif->pci_dev)
448 ofnode = pci_device_to_OF_node(hwif->pci_dev);
449 #endif /* CONFIG_PCI */
450 len = sprintf(page, "%s\n", ofnode ? ofnode->full_name : "");
451 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
453 #endif /* CONFIG_ALL_PPC */
455 EXPORT_SYMBOL(proc_ide_read_imodel);
457 int proc_ide_read_mate
458 (char *page, char **start, off_t off, int count, int *eof, void *data)
460 ide_hwif_t *hwif = (ide_hwif_t *) data;
463 if (hwif && hwif->mate && hwif->mate->present)
464 len = sprintf(page, "%s\n", hwif->mate->name);
466 len = sprintf(page, "(none)\n");
467 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
470 EXPORT_SYMBOL(proc_ide_read_mate);
472 int proc_ide_read_channel
473 (char *page, char **start, off_t off, int count, int *eof, void *data)
475 ide_hwif_t *hwif = (ide_hwif_t *) data;
478 page[0] = hwif->channel ? '1' : '0';
481 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
484 EXPORT_SYMBOL(proc_ide_read_channel);
486 int proc_ide_read_identify
487 (char *page, char **start, off_t off, int count, int *eof, void *data)
489 ide_drive_t *drive = (ide_drive_t *)data;
492 if (drive && !taskfile_lib_get_identify(drive, page)) {
493 unsigned short *val = (unsigned short *) page;
494 char *out = ((char *)val) + (SECTOR_WORDS * 4);
497 out += sprintf(out, "%04x%c",
498 le16_to_cpu(*val), (++i & 7) ? ' ' : '\n');
500 } while (i < (SECTOR_WORDS * 2));
504 len = sprintf(page, "\n");
505 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
508 EXPORT_SYMBOL(proc_ide_read_identify);
510 int proc_ide_read_settings
511 (char *page, char **start, off_t off, int count, int *eof, void *data)
513 ide_drive_t *drive = (ide_drive_t *) data;
514 ide_settings_t *setting = (ide_settings_t *) drive->settings;
516 int len, rc, mul_factor, div_factor;
518 out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
519 out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
521 mul_factor = setting->mul_factor;
522 div_factor = setting->div_factor;
523 out += sprintf(out, "%-24s", setting->name);
524 if ((rc = ide_read_setting(drive, setting)) >= 0)
525 out += sprintf(out, "%-16d", rc * mul_factor / div_factor);
527 out += sprintf(out, "%-16s", "write-only");
528 out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor);
529 if (setting->rw & SETTING_READ)
530 out += sprintf(out, "r");
531 if (setting->rw & SETTING_WRITE)
532 out += sprintf(out, "w");
533 out += sprintf(out, "\n");
534 setting = setting->next;
537 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
540 EXPORT_SYMBOL(proc_ide_read_settings);
544 int proc_ide_write_settings
545 (struct file *file, const char *buffer, unsigned long count, void *data)
547 ide_drive_t *drive = (ide_drive_t *) data;
548 char name[MAX_LEN + 1];
549 int for_real = 0, len;
551 const char *start = NULL;
552 ide_settings_t *setting;
554 if (!capable(CAP_SYS_ADMIN))
557 * Skip over leading whitespace
559 while (count && isspace(*buffer)) {
564 * Do one full pass to verify all parameters,
565 * then do another to actually write the new settings.
573 unsigned int val = 0;
576 while (n > 0 && *p != ':') {
582 len = IDE_MIN(p - start, MAX_LEN);
583 strncpy(name, start, IDE_MIN(len, MAX_LEN));
593 while (n > 0 && (d = ide_getdigit(*p)) >= 0) {
594 val = (val * 10) + d;
599 if (n > 0 && !isspace(*p))
601 while (n > 0 && isspace(*p)) {
605 setting = ide_find_setting_by_name(drive, name);
610 ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor);
612 } while (!for_real++);
615 printk("proc_ide_write_settings(): parse error\n");
619 EXPORT_SYMBOL(proc_ide_write_settings);
621 int proc_ide_read_capacity
622 (char *page, char **start, off_t off, int count, int *eof, void *data)
624 ide_drive_t *drive = (ide_drive_t *) data;
625 ide_driver_t *driver = (ide_driver_t *) drive->driver;
629 len = sprintf(page, "(none)\n");
631 len = sprintf(page,"%llu\n",
632 (u64) ((ide_driver_t *)drive->driver)->capacity(drive));
633 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
636 EXPORT_SYMBOL(proc_ide_read_capacity);
638 int proc_ide_read_geometry
639 (char *page, char **start, off_t off, int count, int *eof, void *data)
641 ide_drive_t *drive = (ide_drive_t *) data;
645 out += sprintf(out,"physical %d/%d/%d\n",
646 drive->cyl, drive->head, drive->sect);
647 out += sprintf(out,"logical %d/%d/%d\n",
648 drive->bios_cyl, drive->bios_head, drive->bios_sect);
651 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
654 EXPORT_SYMBOL(proc_ide_read_geometry);
656 int proc_ide_read_dmodel
657 (char *page, char **start, off_t off, int count, int *eof, void *data)
659 ide_drive_t *drive = (ide_drive_t *) data;
660 struct hd_driveid *id = drive->id;
663 len = sprintf(page, "%.40s\n",
664 (id && id->model[0]) ? (char *)id->model : "(none)");
665 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
668 EXPORT_SYMBOL(proc_ide_read_dmodel);
670 int proc_ide_read_driver
671 (char *page, char **start, off_t off, int count, int *eof, void *data)
673 ide_drive_t *drive = (ide_drive_t *) data;
674 ide_driver_t *driver = (ide_driver_t *) drive->driver;
678 len = sprintf(page, "(none)\n");
680 len = sprintf(page, "%s version %s\n",
681 driver->name, driver->version);
682 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
685 EXPORT_SYMBOL(proc_ide_read_driver);
687 int proc_ide_write_driver
688 (struct file *file, const char *buffer, unsigned long count, void *data)
690 ide_drive_t *drive = (ide_drive_t *) data;
692 if (!capable(CAP_SYS_ADMIN))
694 if (ide_replace_subdriver(drive, buffer))
699 EXPORT_SYMBOL(proc_ide_write_driver);
701 int proc_ide_read_media
702 (char *page, char **start, off_t off, int count, int *eof, void *data)
704 ide_drive_t *drive = (ide_drive_t *) data;
708 switch (drive->media) {
709 case ide_disk: media = "disk\n";
711 case ide_cdrom: media = "cdrom\n";
713 case ide_tape: media = "tape\n";
715 case ide_floppy:media = "floppy\n";
717 default: media = "UNKNOWN\n";
722 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
725 EXPORT_SYMBOL(proc_ide_read_media);
727 static ide_proc_entry_t generic_drive_entries[] = {
728 { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, proc_ide_write_driver },
729 { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL },
730 { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL },
731 { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL },
732 { "settings", S_IFREG|S_IRUSR|S_IWUSR,proc_ide_read_settings, proc_ide_write_settings },
733 { NULL, 0, NULL, NULL }
736 void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data)
738 struct proc_dir_entry *ent;
742 while (p->name != NULL) {
743 ent = create_proc_entry(p->name, p->mode, dir);
747 ent->read_proc = p->read_proc;
748 ent->write_proc = p->write_proc;
753 EXPORT_SYMBOL(ide_add_proc_entries);
755 void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
759 while (p->name != NULL) {
760 remove_proc_entry(p->name, dir);
765 EXPORT_SYMBOL(ide_remove_proc_entries);
767 void create_proc_ide_drives(ide_hwif_t *hwif)
770 struct proc_dir_entry *ent;
771 struct proc_dir_entry *parent = hwif->proc;
774 for (d = 0; d < MAX_DRIVES; d++) {
775 ide_drive_t *drive = &hwif->drives[d];
776 ide_driver_t *driver = drive->driver;
783 drive->proc = proc_mkdir(drive->name, parent);
785 ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
787 ide_add_proc_entries(drive->proc, generic_subdriver_entries, drive);
788 ide_add_proc_entries(drive->proc, driver->proc, drive);
791 sprintf(name,"ide%d/%s", (drive->name[2]-'a')/2, drive->name);
792 ent = proc_symlink(drive->name, proc_ide_root, name);
797 EXPORT_SYMBOL(create_proc_ide_drives);
799 void recreate_proc_ide_device(ide_hwif_t *hwif, ide_drive_t *drive)
801 struct proc_dir_entry *ent;
802 struct proc_dir_entry *parent = hwif->proc;
804 // ide_driver_t *driver = drive->driver;
806 if (drive->present && !drive->proc) {
807 drive->proc = proc_mkdir(drive->name, parent);
809 ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
812 * assume that we have these already, however, should test FIXME!
814 * ide_add_proc_entries(drive->proc, generic_subdriver_entries, drive);
815 * ide_add_proc_entries(drive->proc, driver->proc, drive);
819 sprintf(name,"ide%d/%s", (drive->name[2]-'a')/2, drive->name);
820 ent = proc_symlink(drive->name, proc_ide_root, name);
826 EXPORT_SYMBOL(recreate_proc_ide_device);
828 void destroy_proc_ide_device(ide_hwif_t *hwif, ide_drive_t *drive)
830 ide_driver_t *driver = drive->driver;
834 ide_remove_proc_entries(drive->proc, driver->proc);
835 ide_remove_proc_entries(drive->proc, generic_drive_entries);
836 remove_proc_entry(drive->name, proc_ide_root);
837 remove_proc_entry(drive->name, hwif->proc);
842 EXPORT_SYMBOL(destroy_proc_ide_device);
844 void destroy_proc_ide_drives(ide_hwif_t *hwif)
848 for (d = 0; d < MAX_DRIVES; d++) {
849 ide_drive_t *drive = &hwif->drives[d];
851 destroy_proc_ide_device(hwif, drive);
855 EXPORT_SYMBOL(destroy_proc_ide_drives);
857 static ide_proc_entry_t hwif_entries[] = {
858 { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL },
859 { "config", S_IFREG|S_IRUGO|S_IWUSR,proc_ide_read_config, proc_ide_write_config },
860 { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL },
861 { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL },
862 #ifdef CONFIG_ALL_PPC
863 { "devspec", S_IFREG|S_IRUGO, proc_ide_read_devspec, NULL },
865 { NULL, 0, NULL, NULL }
868 void create_proc_ide_interfaces(void)
872 for (h = 0; h < MAX_HWIFS; h++) {
873 ide_hwif_t *hwif = &ide_hwifs[h];
878 hwif->proc = proc_mkdir(hwif->name, proc_ide_root);
881 ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
883 create_proc_ide_drives(hwif);
887 EXPORT_SYMBOL(create_proc_ide_interfaces);
889 void destroy_proc_ide_interfaces(void)
893 for (h = 0; h < MAX_HWIFS; h++) {
894 ide_hwif_t *hwif = &ide_hwifs[h];
895 int exist = (hwif->proc != NULL);
901 destroy_proc_ide_drives(hwif);
902 ide_remove_proc_entries(hwif->proc, hwif_entries);
903 remove_proc_entry(hwif->name, proc_ide_root);
910 EXPORT_SYMBOL(destroy_proc_ide_interfaces);
912 #ifdef CONFIG_BLK_DEV_IDEPCI
913 void ide_pci_register_host_proc (ide_pci_host_proc_t *p)
915 ide_pci_host_proc_t *tmp;
920 if (ide_pci_host_proc_list) {
921 tmp = ide_pci_host_proc_list;
922 while (tmp->next) tmp = tmp->next;
925 ide_pci_host_proc_list = p;
928 EXPORT_SYMBOL(ide_pci_register_host_proc);
930 #endif /* CONFIG_BLK_DEV_IDEPCI */
932 void proc_ide_create(void)
934 #ifdef CONFIG_BLK_DEV_IDEPCI
935 ide_pci_host_proc_t *p = ide_pci_host_proc_list;
936 #endif /* CONFIG_BLK_DEV_IDEPCI */
938 proc_ide_root = proc_mkdir("ide", 0);
939 if (!proc_ide_root) return;
941 create_proc_ide_interfaces();
943 create_proc_read_entry("drivers", 0, proc_ide_root,
944 proc_ide_read_drivers, NULL);
946 #ifdef CONFIG_BLK_DEV_IDEPCI
949 if (p->name != NULL && p->set == 1 && p->get_info != NULL)
951 p->parent = proc_ide_root;
952 create_proc_info_entry(p->name, 0, p->parent, p->get_info);
957 #endif /* CONFIG_BLK_DEV_IDEPCI */
960 EXPORT_SYMBOL(proc_ide_create);
962 void proc_ide_destroy(void)
964 #ifdef CONFIG_BLK_DEV_IDEPCI
965 ide_pci_host_proc_t *p = ide_pci_host_proc_list;
968 while ((p->name != NULL) && (p->set) && (p->get_info != NULL)) {
970 sprintf(name, "ide/%s", p->name);
972 remove_proc_entry(p->name, p->parent);
973 if (p->next == NULL) break;
976 #endif /* CONFIG_BLK_DEV_IDEPCI */
977 remove_proc_entry("ide/drivers", proc_ide_root);
978 destroy_proc_ide_interfaces();
979 remove_proc_entry("ide", 0);
982 EXPORT_SYMBOL(proc_ide_destroy);