2 * linux/drivers/ide/ide-proc.c Version 1.05 Mar 05, 2003
4 * Copyright (C) 1997-1998 Mark Lord
5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
9 * This is the /proc/ide/ filesystem implementation.
11 * The major reason this exists is to provide sufficient access
12 * to driver and config data, such that user-mode programs can
13 * be developed to handle chipset tuning for most PCI interfaces.
14 * This should provide better utilities, and less kernel bloat.
16 * The entire pci config space for a PCI interface chipset can be
17 * retrieved by just reading it. e.g. "cat /proc/ide3/config"
19 * To modify registers *safely*, do something like:
20 * echo "P40:88" >/proc/ide/ide3/config
21 * That expression writes 0x88 to pci config register 0x40
22 * on the chip which controls ide3. Multiple tuples can be issued,
23 * and the writes will be completed as an atomic set:
24 * echo "P40:88 P41:35 P42:00 P43:00" >/proc/ide/ide3/config
26 * All numbers must be specified using pairs of ascii hex digits.
27 * It is important to note that these writes will be performed
28 * after waiting for the IDE controller (both interfaces)
29 * to be completely idle, to ensure no corruption of I/O in progress.
31 * Non-PCI registers can also be written, using "R" in place of "P"
32 * in the above examples. The size of the port transfer is determined
33 * by the number of pairs of hex digits given for the data. If a two
34 * digit value is given, the write will be a byte operation; if four
35 * digits are used, the write will be performed as a 16-bit operation;
36 * and if eight digits are specified, a 32-bit "dword" write will be
37 * performed. Odd numbers of digits are not permitted.
39 * If there is an error *anywhere* in the string of registers/data
40 * then *none* of the writes will be performed.
42 * Drive/Driver settings can be retrieved by reading the drive's
43 * "settings" files. e.g. "cat /proc/ide0/hda/settings"
44 * To write a new value "val" into a specific setting "name", use:
45 * echo "name:val" >/proc/ide/ide0/hda/settings
47 * Also useful, "cat /proc/ide0/hda/[identify, smart_values,
48 * smart_thresholds, capabilities]" will issue an IDENTIFY /
49 * PACKET_IDENTIFY / SMART_READ_VALUES / SMART_READ_THRESHOLDS /
50 * SENSE CAPABILITIES command to /dev/hda, and then dump out the
51 * returned data as 256 16-bit words. The "hdparm" utility will
52 * be updated someday soon to use this mechanism.
54 * Feel free to develop and distribute fancy GUI configuration
55 * utilities for your favorite PCI chipsets. I'll be working on
56 * one for the Promise 20246 someday soon. -ml
60 #include <linux/config.h>
61 #define __NO_VERSION__
62 #include <linux/module.h>
64 #include <asm/uaccess.h>
65 #include <linux/errno.h>
66 #include <linux/sched.h>
67 #include <linux/proc_fs.h>
68 #include <linux/stat.h>
70 #include <linux/pci.h>
71 #include <linux/ctype.h>
72 #include <linux/hdreg.h>
73 #include <linux/ide.h>
79 #include <asm/pci-bridge.h>
83 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
86 static int ide_getxdigit(char c)
92 digit = tolower(c) - 'a' + 10;
98 static int xx_xx_parse_error (const char *data, unsigned long len, const char *msg)
102 if (len >= sizeof(errbuf))
103 len = sizeof(errbuf) - 1;
104 for (i = 0; i < len; ++i) {
113 printk("proc_ide: error: %s: '%s'\n", msg, errbuf);
117 static struct proc_dir_entry * proc_ide_root = NULL;
119 #ifdef CONFIG_BLK_DEV_IDEPCI
120 #include <linux/delay.h>
122 * This is the list of registered PCI chipset driver data structures.
124 static ide_pci_host_proc_t * ide_pci_host_proc_list;
126 #endif /* CONFIG_BLK_DEV_IDEPCI */
130 static int proc_ide_write_config
131 (struct file *file, const char *buffer, unsigned long count, void *data)
133 ide_hwif_t *hwif = (ide_hwif_t *)data;
135 unsigned long startn = 0, n, flags;
136 const char *start = NULL, *msg = NULL;
138 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
141 * Skip over leading whitespace
143 while (count && isspace(*buffer)) {
148 * Do one full pass to verify all parameters,
149 * then do another to actually write the regs.
152 save_flags(flags); /* all CPUs */
154 spin_lock_irqsave(&io_request_lock, flags);
159 unsigned long timeout = jiffies + (3 * HZ);
160 ide_hwgroup_t *mygroup = (ide_hwgroup_t *)(hwif->hwgroup);
161 ide_hwgroup_t *mategroup = NULL;
162 if (hwif->mate && hwif->mate->hwgroup)
163 mategroup = (ide_hwgroup_t *)(hwif->mate->hwgroup);
165 cli(); /* all CPUs; ensure all writes are done together */
167 spin_lock_irqsave(&io_request_lock, flags);
169 while (mygroup->busy ||
170 (mategroup && mategroup->busy)) {
172 sti(); /* all CPUs */
174 spin_unlock_irqrestore(&io_request_lock, flags);
176 if (time_after(jiffies, timeout)) {
177 printk("/proc/ide/%s/config: channel(s) busy, cannot write\n", hwif->name);
179 restore_flags(flags); /* all CPUs */
181 spin_unlock_irqrestore(&io_request_lock, flags);
186 cli(); /* all CPUs */
188 spin_lock_irqsave(&io_request_lock, flags);
196 unsigned int reg = 0, val = 0, is_pci;
200 case 'R': is_pci = 0;
202 case 'P': is_pci = 1;
203 #ifdef CONFIG_BLK_DEV_IDEPCI
204 if (hwif->pci_dev && !hwif->pci_dev->vendor)
206 #endif /* CONFIG_BLK_DEV_IDEPCI */
207 msg = "not a PCI device";
209 default: msg = "expected 'R' or 'P'";
213 while (n > 0 && (d = ide_getxdigit(*p)) >= 0) {
214 reg = (reg << 4) | d;
219 if (!digits || (digits > 4) || (is_pci && reg > 0xff)) {
220 msg = "bad/missing register number";
223 if (n-- == 0 || *p++ != ':') {
228 while (n > 0 && (d = ide_getxdigit(*p)) >= 0) {
229 val = (val << 4) | d;
234 if (digits != 2 && digits != 4 && digits != 8) {
235 msg = "bad data, 2/4/8 digits required";
238 if (n > 0 && !isspace(*p)) {
239 msg = "expected whitespace after data";
242 while (n > 0 && isspace(*p)) {
246 #ifdef CONFIG_BLK_DEV_IDEPCI
247 if (is_pci && (reg & ((digits >> 1) - 1))) {
248 msg = "misaligned access";
251 #endif /* CONFIG_BLK_DEV_IDEPCI */
254 printk("proc_ide_write_config: type=%c, reg=0x%x, val=0x%x, digits=%d\n", is_pci ? "PCI" : "non-PCI", reg, val, digits);
257 #ifdef CONFIG_BLK_DEV_IDEPCI
259 struct pci_dev *dev = hwif->pci_dev;
261 case 2: msg = "byte";
262 rc = pci_write_config_byte(dev, reg, val);
264 case 4: msg = "word";
265 rc = pci_write_config_word(dev, reg, val);
267 case 8: msg = "dword";
268 rc = pci_write_config_dword(dev, reg, val);
273 restore_flags(flags); /* all CPUs */
275 spin_unlock_irqrestore(&io_request_lock, flags);
277 printk("proc_ide_write_config: error writing %s at bus %02x dev %02x reg 0x%x value 0x%x\n",
278 msg, dev->bus->number, dev->devfn, reg, val);
279 printk("proc_ide_write_config: error %d\n", rc);
282 #endif /* CONFIG_BLK_DEV_IDEPCI */
283 } else { /* not pci */
284 #if !defined(__mc68000__) && !defined(CONFIG_APUS)
289 * unless you can explain me what it really does.
290 * On m68k, we don't have outw() and outl() yet,
291 * and I need a good reason to implement it.
293 * BTW, IMHO the main remaining portability problem with the IDE driver
294 * is that it mixes IO (ioport) and MMIO (iomem) access on different platforms.
296 * I think all accesses should be done using
298 * ide_in[bwl](ide_device_instance, offset)
299 * ide_out[bwl](ide_device_instance, value, offset)
301 * so the architecture specific code can #define ide_{in,out}[bwl] to the
302 * appropriate function.
306 case 2: hwif->OUTB(val, reg);
308 case 4: hwif->OUTW(val, reg);
310 case 8: hwif->OUTL(val, reg);
313 #endif /* !__mc68000__ && !CONFIG_APUS */
317 } while (!for_real++);
319 restore_flags(flags); /* all CPUs */
321 spin_unlock_irqrestore(&io_request_lock, flags);
326 restore_flags(flags); /* all CPUs */
328 spin_unlock_irqrestore(&io_request_lock, flags);
330 printk("parse error\n");
331 return xx_xx_parse_error(start, startn, msg);
334 int proc_ide_read_config
335 (char *page, char **start, off_t off, int count, int *eof, void *data)
340 #ifdef CONFIG_BLK_DEV_IDEPCI
341 ide_hwif_t *hwif = (ide_hwif_t *)data;
342 struct pci_dev *dev = hwif->pci_dev;
343 if ((hwif->pci_dev && hwif->pci_dev->vendor) && dev && dev->bus) {
346 out += sprintf(out, "pci bus %02x device %02x vendor %04x "
347 "device %04x channel %d\n",
348 dev->bus->number, dev->devfn,
349 hwif->pci_dev->vendor, hwif->pci_dev->device,
353 int rc = pci_read_config_byte(dev, reg, &val);
355 printk("proc_ide_read_config: error %d reading"
356 " bus %02x dev %02x reg 0x%02x\n",
357 rc, dev->bus->number, dev->devfn, reg);
358 out += sprintf(out, "??%c",
359 (++reg & 0xf) ? ' ' : '\n');
361 out += sprintf(out, "%02x%c",
362 val, (++reg & 0xf) ? ' ' : '\n');
363 } while (reg < 0x100);
365 #endif /* CONFIG_BLK_DEV_IDEPCI */
366 out += sprintf(out, "(none)\n");
368 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
371 EXPORT_SYMBOL(proc_ide_read_config);
373 static int ide_getdigit(char c)
383 int proc_ide_read_drivers
384 (char *page, char **start, off_t off, int count, int *eof, void *data)
388 ide_module_t *p = ide_modules;
389 ide_driver_t *driver;
392 driver = (ide_driver_t *) p->info;
394 out += sprintf(out, "%s version %s\n",
395 driver->name, driver->version);
399 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
402 EXPORT_SYMBOL(proc_ide_read_drivers);
404 int proc_ide_read_imodel
405 (char *page, char **start, off_t off, int count, int *eof, void *data)
407 ide_hwif_t *hwif = (ide_hwif_t *) data;
411 switch (hwif->chipset) {
412 case ide_unknown: name = "(none)"; break;
413 case ide_generic: name = "generic"; break;
414 case ide_pci: name = "pci"; break;
415 case ide_cmd640: name = "cmd640"; break;
416 case ide_dtc2278: name = "dtc2278"; break;
417 case ide_ali14xx: name = "ali14xx"; break;
418 case ide_qd65xx: name = "qd65xx"; break;
419 case ide_umc8672: name = "umc8672"; break;
420 case ide_ht6560b: name = "ht6560b"; break;
421 case ide_pdc4030: name = "pdc4030"; break;
422 case ide_rz1000: name = "rz1000"; break;
423 case ide_trm290: name = "trm290"; break;
424 case ide_cmd646: name = "cmd646"; break;
425 case ide_cy82c693: name = "cy82c693"; break;
426 case ide_4drives: name = "4drives"; break;
427 case ide_pmac: name = "pmac"; break;
428 default: name = "(unknown)"; break;
430 len = sprintf(page, "%s\n", name);
431 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
434 #ifdef CONFIG_ALL_PPC
435 static int proc_ide_read_devspec
436 (char *page, char **start, off_t off, int count, int *eof, void *data)
438 ide_hwif_t *hwif = (ide_hwif_t *) data;
440 struct device_node *ofnode = NULL;
442 #ifdef CONFIG_BLK_DEV_IDE_PMAC
443 extern struct device_node* pmac_ide_get_of_node(int index);
444 if (hwif->chipset == ide_pmac)
445 ofnode = pmac_ide_get_of_node(hwif->index);
446 #endif /* CONFIG_BLK_DEV_IDE_PMAC */
448 if (ofnode == NULL && hwif->pci_dev)
449 ofnode = pci_device_to_OF_node(hwif->pci_dev);
450 #endif /* CONFIG_PCI */
451 len = sprintf(page, "%s\n", ofnode ? ofnode->full_name : "");
452 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
454 #endif /* CONFIG_ALL_PPC */
456 EXPORT_SYMBOL(proc_ide_read_imodel);
458 int proc_ide_read_mate
459 (char *page, char **start, off_t off, int count, int *eof, void *data)
461 ide_hwif_t *hwif = (ide_hwif_t *) data;
464 if (hwif && hwif->mate && hwif->mate->present)
465 len = sprintf(page, "%s\n", hwif->mate->name);
467 len = sprintf(page, "(none)\n");
468 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
471 EXPORT_SYMBOL(proc_ide_read_mate);
473 int proc_ide_read_channel
474 (char *page, char **start, off_t off, int count, int *eof, void *data)
476 ide_hwif_t *hwif = (ide_hwif_t *) data;
479 page[0] = hwif->channel ? '1' : '0';
482 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
485 EXPORT_SYMBOL(proc_ide_read_channel);
487 int proc_ide_read_identify
488 (char *page, char **start, off_t off, int count, int *eof, void *data)
490 ide_drive_t *drive = (ide_drive_t *)data;
494 len = sprintf(page, "\n");
498 unsigned short *val = (unsigned short *) page;
501 * The current code can't handle a driverless
502 * identify query taskfile. Now the right fix is
503 * to add a 'default' driver but that is a bit
506 * FIXME: this has to be fixed for hotswap devices
510 err = taskfile_lib_get_identify(drive, page);
511 else /* This relies on the ID changes */
512 val = (unsigned short *)drive->id;
516 char *out = ((char *)page) + (SECTOR_WORDS * 4);
519 out += sprintf(out, "%04x%c",
520 le16_to_cpu(*val), (++i & 7) ? ' ' : '\n');
522 } while (i < (SECTOR_WORDS * 2));
526 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
529 EXPORT_SYMBOL(proc_ide_read_identify);
531 int proc_ide_read_settings
532 (char *page, char **start, off_t off, int count, int *eof, void *data)
534 ide_drive_t *drive = (ide_drive_t *) data;
535 ide_settings_t *setting = (ide_settings_t *) drive->settings;
537 int len, rc, mul_factor, div_factor;
539 down(&ide_setting_sem);
540 out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
541 out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
543 mul_factor = setting->mul_factor;
544 div_factor = setting->div_factor;
545 out += sprintf(out, "%-24s", setting->name);
546 if ((rc = ide_read_setting(drive, setting)) >= 0)
547 out += sprintf(out, "%-16d", rc * mul_factor / div_factor);
549 out += sprintf(out, "%-16s", "write-only");
550 out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor);
551 if (setting->rw & SETTING_READ)
552 out += sprintf(out, "r");
553 if (setting->rw & SETTING_WRITE)
554 out += sprintf(out, "w");
555 out += sprintf(out, "\n");
556 setting = setting->next;
559 up(&ide_setting_sem);
560 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
563 EXPORT_SYMBOL(proc_ide_read_settings);
567 int proc_ide_write_settings
568 (struct file *file, const char *buffer, unsigned long count, void *data)
570 ide_drive_t *drive = (ide_drive_t *) data;
571 char name[MAX_LEN + 1];
572 int for_real = 0, len;
574 const char *start = NULL;
575 ide_settings_t *setting;
577 if (!capable(CAP_SYS_ADMIN))
580 * Skip over leading whitespace
582 while (count && isspace(*buffer)) {
587 * Do one full pass to verify all parameters,
588 * then do another to actually write the new settings.
596 unsigned int val = 0;
599 while (n > 0 && *p != ':') {
605 len = IDE_MIN(p - start, MAX_LEN);
606 strncpy(name, start, IDE_MIN(len, MAX_LEN));
616 while (n > 0 && (d = ide_getdigit(*p)) >= 0) {
617 val = (val * 10) + d;
622 if (n > 0 && !isspace(*p))
624 while (n > 0 && isspace(*p)) {
629 down(&ide_setting_sem);
630 setting = ide_find_setting_by_name(drive, name);
633 up(&ide_setting_sem);
637 ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor);
638 up(&ide_setting_sem);
640 } while (!for_real++);
643 printk("proc_ide_write_settings(): parse error\n");
647 EXPORT_SYMBOL(proc_ide_write_settings);
649 int proc_ide_read_capacity
650 (char *page, char **start, off_t off, int count, int *eof, void *data)
652 ide_drive_t *drive = (ide_drive_t *) data;
655 len = sprintf(page,"%llu\n",
656 (u64) ((ide_driver_t *)drive->driver)->capacity(drive));
657 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
660 EXPORT_SYMBOL(proc_ide_read_capacity);
662 int proc_ide_read_geometry
663 (char *page, char **start, off_t off, int count, int *eof, void *data)
665 ide_drive_t *drive = (ide_drive_t *) data;
669 out += sprintf(out,"physical %d/%d/%d\n",
670 drive->cyl, drive->head, drive->sect);
671 out += sprintf(out,"logical %d/%d/%d\n",
672 drive->bios_cyl, drive->bios_head, drive->bios_sect);
675 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
678 EXPORT_SYMBOL(proc_ide_read_geometry);
680 int proc_ide_read_dmodel
681 (char *page, char **start, off_t off, int count, int *eof, void *data)
683 ide_drive_t *drive = (ide_drive_t *) data;
684 struct hd_driveid *id = drive->id;
687 len = sprintf(page, "%.40s\n",
688 (id && id->model[0]) ? (char *)id->model : "(none)");
689 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
692 EXPORT_SYMBOL(proc_ide_read_dmodel);
694 int proc_ide_read_driver
695 (char *page, char **start, off_t off, int count, int *eof, void *data)
697 ide_drive_t *drive = (ide_drive_t *) data;
698 ide_driver_t *driver = (ide_driver_t *) drive->driver;
701 len = sprintf(page, "%s version %s\n",
702 driver->name, driver->version);
703 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
706 EXPORT_SYMBOL(proc_ide_read_driver);
708 int proc_ide_write_driver
709 (struct file *file, const char *buffer, unsigned long count, void *data)
711 ide_drive_t *drive = (ide_drive_t *) data;
713 if (!capable(CAP_SYS_ADMIN))
715 if (ide_replace_subdriver(drive, buffer))
720 EXPORT_SYMBOL(proc_ide_write_driver);
722 int proc_ide_read_media
723 (char *page, char **start, off_t off, int count, int *eof, void *data)
725 ide_drive_t *drive = (ide_drive_t *) data;
729 switch (drive->media) {
730 case ide_disk: media = "disk\n";
732 case ide_cdrom: media = "cdrom\n";
734 case ide_tape: media = "tape\n";
736 case ide_floppy:media = "floppy\n";
738 default: media = "UNKNOWN\n";
743 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
746 EXPORT_SYMBOL(proc_ide_read_media);
748 static ide_proc_entry_t generic_drive_entries[] = {
749 { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, proc_ide_write_driver },
750 { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL },
751 { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL },
752 { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL },
753 { "settings", S_IFREG|S_IRUSR|S_IWUSR,proc_ide_read_settings, proc_ide_write_settings },
754 { NULL, 0, NULL, NULL }
757 void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data)
759 struct proc_dir_entry *ent;
763 while (p->name != NULL) {
764 ent = create_proc_entry(p->name, p->mode, dir);
768 ent->read_proc = p->read_proc;
769 ent->write_proc = p->write_proc;
774 EXPORT_SYMBOL(ide_add_proc_entries);
776 void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
780 while (p->name != NULL) {
781 remove_proc_entry(p->name, dir);
786 EXPORT_SYMBOL(ide_remove_proc_entries);
788 void create_proc_ide_drives(ide_hwif_t *hwif)
791 struct proc_dir_entry *ent;
792 struct proc_dir_entry *parent = hwif->proc;
795 for (d = 0; d < MAX_DRIVES; d++) {
796 ide_drive_t *drive = &hwif->drives[d];
803 drive->proc = proc_mkdir(drive->name, parent);
805 ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
806 sprintf(name,"ide%d/%s", (drive->name[2]-'a')/2, drive->name);
807 ent = proc_symlink(drive->name, proc_ide_root, name);
812 EXPORT_SYMBOL(create_proc_ide_drives);
814 void destroy_proc_ide_device(ide_hwif_t *hwif, ide_drive_t *drive)
816 ide_driver_t *driver = drive->driver;
819 ide_remove_proc_entries(drive->proc, driver->proc);
820 ide_remove_proc_entries(drive->proc, generic_drive_entries);
821 remove_proc_entry(drive->name, proc_ide_root);
822 remove_proc_entry(drive->name, hwif->proc);
827 EXPORT_SYMBOL(destroy_proc_ide_device);
829 void destroy_proc_ide_drives(ide_hwif_t *hwif)
833 for (d = 0; d < MAX_DRIVES; d++) {
834 ide_drive_t *drive = &hwif->drives[d];
836 destroy_proc_ide_device(hwif, drive);
840 EXPORT_SYMBOL(destroy_proc_ide_drives);
842 static ide_proc_entry_t hwif_entries[] = {
843 { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL },
844 { "config", S_IFREG|S_IRUGO|S_IWUSR,proc_ide_read_config, proc_ide_write_config },
845 { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL },
846 { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL },
847 #ifdef CONFIG_ALL_PPC
848 { "devspec", S_IFREG|S_IRUGO, proc_ide_read_devspec, NULL },
850 { NULL, 0, NULL, NULL }
853 void create_proc_ide_interfaces(void)
857 for (h = 0; h < MAX_HWIFS; h++) {
858 ide_hwif_t *hwif = &ide_hwifs[h];
863 hwif->proc = proc_mkdir(hwif->name, proc_ide_root);
866 ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
868 create_proc_ide_drives(hwif);
872 EXPORT_SYMBOL(create_proc_ide_interfaces);
874 void destroy_proc_ide_interfaces(void)
878 for (h = 0; h < MAX_HWIFS; h++) {
879 ide_hwif_t *hwif = &ide_hwifs[h];
880 int exist = (hwif->proc != NULL);
886 destroy_proc_ide_drives(hwif);
887 ide_remove_proc_entries(hwif->proc, hwif_entries);
888 remove_proc_entry(hwif->name, proc_ide_root);
895 EXPORT_SYMBOL(destroy_proc_ide_interfaces);
897 #ifdef CONFIG_BLK_DEV_IDEPCI
898 void ide_pci_register_host_proc (ide_pci_host_proc_t *p)
900 ide_pci_host_proc_t *tmp;
905 if (ide_pci_host_proc_list) {
906 tmp = ide_pci_host_proc_list;
907 while (tmp->next) tmp = tmp->next;
910 ide_pci_host_proc_list = p;
913 EXPORT_SYMBOL(ide_pci_register_host_proc);
915 #endif /* CONFIG_BLK_DEV_IDEPCI */
917 void proc_ide_create(void)
919 #ifdef CONFIG_BLK_DEV_IDEPCI
920 ide_pci_host_proc_t *p = ide_pci_host_proc_list;
921 #endif /* CONFIG_BLK_DEV_IDEPCI */
923 proc_ide_root = proc_mkdir("ide", 0);
924 if (!proc_ide_root) return;
926 create_proc_ide_interfaces();
928 create_proc_read_entry("drivers", 0, proc_ide_root,
929 proc_ide_read_drivers, NULL);
931 #ifdef CONFIG_BLK_DEV_IDEPCI
934 if (p->name != NULL && p->set == 1 && p->get_info != NULL)
936 p->parent = proc_ide_root;
937 create_proc_info_entry(p->name, 0, p->parent, p->get_info);
942 #endif /* CONFIG_BLK_DEV_IDEPCI */
945 EXPORT_SYMBOL(proc_ide_create);
947 void proc_ide_destroy(void)
949 #ifdef CONFIG_BLK_DEV_IDEPCI
950 ide_pci_host_proc_t *p;
952 for (p = ide_pci_host_proc_list; p; p = p->next) {
954 remove_proc_entry(p->name, p->parent);
956 #endif /* CONFIG_BLK_DEV_IDEPCI */
957 remove_proc_entry("ide/drivers", proc_ide_root);
958 destroy_proc_ide_interfaces();
959 remove_proc_entry("ide", 0);
962 EXPORT_SYMBOL(proc_ide_destroy);