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 #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>
73 #include <linux/seq_file.h>
78 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
81 static int ide_getxdigit(char c
)
87 digit
= tolower(c
) - 'a' + 10;
93 static int xx_xx_parse_error (const char *data
, unsigned long len
, const char *msg
)
97 if (len
>= sizeof(errbuf
))
98 len
= sizeof(errbuf
) - 1;
99 for (i
= 0; i
< len
; ++i
) {
108 printk("proc_ide: error: %s: '%s'\n", msg
, errbuf
);
112 static struct proc_dir_entry
* proc_ide_root
= NULL
;
114 #ifdef CONFIG_BLK_DEV_IDEPCI
115 #include <linux/delay.h>
117 * This is the list of registered PCI chipset driver data structures.
119 static ide_pci_host_proc_t
* ide_pci_host_proc_list
;
121 #endif /* CONFIG_BLK_DEV_IDEPCI */
123 static int proc_ide_write_config
124 (struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
126 ide_hwif_t
*hwif
= (ide_hwif_t
*)data
;
128 unsigned long startn
= 0, n
, flags
;
129 const char *start
= NULL
, *msg
= NULL
;
131 if (!capable(CAP_SYS_ADMIN
) || !capable(CAP_SYS_RAWIO
))
134 * Skip over leading whitespace
136 while (count
&& isspace(*buffer
)) {
141 * Do one full pass to verify all parameters,
142 * then do another to actually write the regs.
144 spin_lock_irqsave(&ide_lock
, flags
);
148 unsigned long timeout
= jiffies
+ (3 * HZ
);
149 ide_hwgroup_t
*mygroup
= (ide_hwgroup_t
*)(hwif
->hwgroup
);
150 ide_hwgroup_t
*mategroup
= NULL
;
151 if (hwif
->mate
&& hwif
->mate
->hwgroup
)
152 mategroup
= (ide_hwgroup_t
*)(hwif
->mate
->hwgroup
);
153 spin_lock_irqsave(&ide_lock
, flags
);
154 while (mygroup
->busy
||
155 (mategroup
&& mategroup
->busy
)) {
156 spin_unlock_irqrestore(&ide_lock
, flags
);
157 if (time_after(jiffies
, timeout
)) {
158 printk("/proc/ide/%s/config: channel(s) busy, cannot write\n", hwif
->name
);
159 spin_unlock_irqrestore(&ide_lock
, flags
);
162 spin_lock_irqsave(&ide_lock
, flags
);
169 unsigned int reg
= 0, val
= 0, is_pci
;
173 case 'R': is_pci
= 0;
175 case 'P': is_pci
= 1;
176 #ifdef CONFIG_BLK_DEV_IDEPCI
177 if (hwif
->pci_dev
&& !hwif
->pci_dev
->vendor
)
179 #endif /* CONFIG_BLK_DEV_IDEPCI */
180 msg
= "not a PCI device";
182 default: msg
= "expected 'R' or 'P'";
186 while (n
> 0 && (d
= ide_getxdigit(*p
)) >= 0) {
187 reg
= (reg
<< 4) | d
;
192 if (!digits
|| (digits
> 4) || (is_pci
&& reg
> 0xff)) {
193 msg
= "bad/missing register number";
196 if (n
-- == 0 || *p
++ != ':') {
201 while (n
> 0 && (d
= ide_getxdigit(*p
)) >= 0) {
202 val
= (val
<< 4) | d
;
207 if (digits
!= 2 && digits
!= 4 && digits
!= 8) {
208 msg
= "bad data, 2/4/8 digits required";
211 if (n
> 0 && !isspace(*p
)) {
212 msg
= "expected whitespace after data";
215 while (n
> 0 && isspace(*p
)) {
219 #ifdef CONFIG_BLK_DEV_IDEPCI
220 if (is_pci
&& (reg
& ((digits
>> 1) - 1))) {
221 msg
= "misaligned access";
224 #endif /* CONFIG_BLK_DEV_IDEPCI */
227 printk("proc_ide_write_config: type=%c, reg=0x%x, val=0x%x, digits=%d\n", is_pci
? "PCI" : "non-PCI", reg
, val
, digits
);
230 #ifdef CONFIG_BLK_DEV_IDEPCI
232 struct pci_dev
*dev
= hwif
->pci_dev
;
234 case 2: msg
= "byte";
235 rc
= pci_write_config_byte(dev
, reg
, val
);
237 case 4: msg
= "word";
238 rc
= pci_write_config_word(dev
, reg
, val
);
240 case 8: msg
= "dword";
241 rc
= pci_write_config_dword(dev
, reg
, val
);
245 spin_unlock_irqrestore(&ide_lock
, flags
);
246 printk("proc_ide_write_config: error writing %s at bus %02x dev %02x reg 0x%x value 0x%x\n",
247 msg
, dev
->bus
->number
, dev
->devfn
, reg
, val
);
248 printk("proc_ide_write_config: error %d\n", rc
);
251 #endif /* CONFIG_BLK_DEV_IDEPCI */
252 } else { /* not pci */
253 #if !defined(__mc68000__) && !defined(CONFIG_APUS)
258 * unless you can explain me what it really does.
259 * On m68k, we don't have outw() and outl() yet,
260 * and I need a good reason to implement it.
262 * BTW, IMHO the main remaining portability problem with the IDE driver
263 * is that it mixes IO (ioport) and MMIO (iomem) access on different platforms.
265 * I think all accesses should be done using
267 * ide_in[bwl](ide_device_instance, offset)
268 * ide_out[bwl](ide_device_instance, value, offset)
270 * so the architecture specific code can #define ide_{in,out}[bwl] to the
271 * appropriate function.
275 case 2: hwif
->OUTB(val
, reg
);
277 case 4: hwif
->OUTW(val
, reg
);
279 case 8: hwif
->OUTL(val
, reg
);
282 #endif /* !__mc68000__ && !CONFIG_APUS */
286 } while (!for_real
++);
287 spin_unlock_irqrestore(&ide_lock
, flags
);
290 spin_unlock_irqrestore(&ide_lock
, flags
);
291 printk("parse error\n");
292 return xx_xx_parse_error(start
, startn
, msg
);
295 int proc_ide_read_config
296 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
301 #ifdef CONFIG_BLK_DEV_IDEPCI
302 ide_hwif_t
*hwif
= (ide_hwif_t
*)data
;
303 struct pci_dev
*dev
= hwif
->pci_dev
;
304 if ((hwif
->pci_dev
&& hwif
->pci_dev
->vendor
) && dev
&& dev
->bus
) {
307 out
+= sprintf(out
, "pci bus %02x device %02x vendor %04x "
308 "device %04x channel %d\n",
309 dev
->bus
->number
, dev
->devfn
,
310 hwif
->pci_dev
->vendor
, hwif
->pci_dev
->device
,
314 int rc
= pci_read_config_byte(dev
, reg
, &val
);
316 printk("proc_ide_read_config: error %d reading"
317 " bus %02x dev %02x reg 0x%02x\n",
318 rc
, dev
->bus
->number
, dev
->devfn
, reg
);
319 out
+= sprintf(out
, "??%c",
320 (++reg
& 0xf) ? ' ' : '\n');
322 out
+= sprintf(out
, "%02x%c",
323 val
, (++reg
& 0xf) ? ' ' : '\n');
324 } while (reg
< 0x100);
326 #endif /* CONFIG_BLK_DEV_IDEPCI */
327 out
+= sprintf(out
, "(none)\n");
329 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
332 EXPORT_SYMBOL(proc_ide_read_config
);
334 static int ide_getdigit(char c
)
344 static int proc_ide_read_imodel
345 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
347 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
351 switch (hwif
->chipset
) {
352 case ide_unknown
: name
= "(none)"; break;
353 case ide_generic
: name
= "generic"; break;
354 case ide_pci
: name
= "pci"; break;
355 case ide_cmd640
: name
= "cmd640"; break;
356 case ide_dtc2278
: name
= "dtc2278"; break;
357 case ide_ali14xx
: name
= "ali14xx"; break;
358 case ide_qd65xx
: name
= "qd65xx"; break;
359 case ide_umc8672
: name
= "umc8672"; break;
360 case ide_ht6560b
: name
= "ht6560b"; break;
361 case ide_pdc4030
: name
= "pdc4030"; break;
362 case ide_rz1000
: name
= "rz1000"; break;
363 case ide_trm290
: name
= "trm290"; break;
364 case ide_cmd646
: name
= "cmd646"; break;
365 case ide_cy82c693
: name
= "cy82c693"; break;
366 case ide_4drives
: name
= "4drives"; break;
367 case ide_pmac
: name
= "mac-io"; break;
368 case ide_pc9800
: name
= "pc9800"; break;
369 default: name
= "(unknown)"; break;
371 len
= sprintf(page
, "%s\n", name
);
372 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
375 EXPORT_SYMBOL(proc_ide_read_imodel
);
377 int proc_ide_read_mate
378 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
380 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
383 if (hwif
&& hwif
->mate
&& hwif
->mate
->present
)
384 len
= sprintf(page
, "%s\n", hwif
->mate
->name
);
386 len
= sprintf(page
, "(none)\n");
387 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
390 EXPORT_SYMBOL(proc_ide_read_mate
);
392 int proc_ide_read_channel
393 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
395 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
398 page
[0] = hwif
->channel
? '1' : '0';
401 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
404 EXPORT_SYMBOL(proc_ide_read_channel
);
406 int proc_ide_read_identify
407 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
409 ide_drive_t
*drive
= (ide_drive_t
*)data
;
413 len
= sprintf(page
, "\n");
417 unsigned short *val
= (unsigned short *) page
;
420 * The current code can't handle a driverless
421 * identify query taskfile. Now the right fix is
422 * to add a 'default' driver but that is a bit
425 * FIXME: this has to be fixed for hotswap devices
429 err
= taskfile_lib_get_identify(drive
, page
);
430 else /* This relies on the ID changes */
431 val
= (unsigned short *)drive
->id
;
435 char *out
= ((char *)page
) + (SECTOR_WORDS
* 4);
438 out
+= sprintf(out
, "%04x%c",
439 le16_to_cpu(*val
), (++i
& 7) ? ' ' : '\n');
441 } while (i
< (SECTOR_WORDS
* 2));
445 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
448 EXPORT_SYMBOL(proc_ide_read_identify
);
450 int proc_ide_read_settings
451 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
453 ide_drive_t
*drive
= (ide_drive_t
*) data
;
454 ide_settings_t
*setting
= (ide_settings_t
*) drive
->settings
;
456 int len
, rc
, mul_factor
, div_factor
;
458 down(&ide_setting_sem
);
459 out
+= sprintf(out
, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
460 out
+= sprintf(out
, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
462 mul_factor
= setting
->mul_factor
;
463 div_factor
= setting
->div_factor
;
464 out
+= sprintf(out
, "%-24s", setting
->name
);
465 if ((rc
= ide_read_setting(drive
, setting
)) >= 0)
466 out
+= sprintf(out
, "%-16d", rc
* mul_factor
/ div_factor
);
468 out
+= sprintf(out
, "%-16s", "write-only");
469 out
+= sprintf(out
, "%-16d%-16d", (setting
->min
* mul_factor
+ div_factor
- 1) / div_factor
, setting
->max
* mul_factor
/ div_factor
);
470 if (setting
->rw
& SETTING_READ
)
471 out
+= sprintf(out
, "r");
472 if (setting
->rw
& SETTING_WRITE
)
473 out
+= sprintf(out
, "w");
474 out
+= sprintf(out
, "\n");
475 setting
= setting
->next
;
478 up(&ide_setting_sem
);
479 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
482 EXPORT_SYMBOL(proc_ide_read_settings
);
486 int proc_ide_write_settings
487 (struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
489 ide_drive_t
*drive
= (ide_drive_t
*) data
;
490 char name
[MAX_LEN
+ 1];
491 int for_real
= 0, len
;
493 const char *start
= NULL
;
494 ide_settings_t
*setting
;
496 if (!capable(CAP_SYS_ADMIN
))
499 * Skip over leading whitespace
501 while (count
&& isspace(*buffer
)) {
506 * Do one full pass to verify all parameters,
507 * then do another to actually write the new settings.
515 unsigned int val
= 0;
518 while (n
> 0 && *p
!= ':') {
524 len
= IDE_MIN(p
- start
, MAX_LEN
);
525 strlcpy(name
, start
, IDE_MIN(len
, MAX_LEN
));
534 while (n
> 0 && (d
= ide_getdigit(*p
)) >= 0) {
535 val
= (val
* 10) + d
;
540 if (n
> 0 && !isspace(*p
))
542 while (n
> 0 && isspace(*p
)) {
547 down(&ide_setting_sem
);
548 setting
= ide_find_setting_by_name(drive
, name
);
551 up(&ide_setting_sem
);
555 ide_write_setting(drive
, setting
, val
* setting
->div_factor
/ setting
->mul_factor
);
556 up(&ide_setting_sem
);
558 } while (!for_real
++);
561 printk("proc_ide_write_settings(): parse error\n");
565 EXPORT_SYMBOL(proc_ide_write_settings
);
567 int proc_ide_read_capacity
568 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
570 ide_drive_t
*drive
= (ide_drive_t
*) data
;
573 len
= sprintf(page
,"%llu\n",
574 (long long) (DRIVER(drive
)->capacity(drive
)));
575 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
578 EXPORT_SYMBOL(proc_ide_read_capacity
);
580 int proc_ide_read_geometry
581 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
583 ide_drive_t
*drive
= (ide_drive_t
*) data
;
587 out
+= sprintf(out
,"physical %d/%d/%d\n",
588 drive
->cyl
, drive
->head
, drive
->sect
);
589 out
+= sprintf(out
,"logical %d/%d/%d\n",
590 drive
->bios_cyl
, drive
->bios_head
, drive
->bios_sect
);
593 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
596 EXPORT_SYMBOL(proc_ide_read_geometry
);
598 int proc_ide_read_dmodel
599 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
601 ide_drive_t
*drive
= (ide_drive_t
*) data
;
602 struct hd_driveid
*id
= drive
->id
;
605 len
= sprintf(page
, "%.40s\n",
606 (id
&& id
->model
[0]) ? (char *)id
->model
: "(none)");
607 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
610 EXPORT_SYMBOL(proc_ide_read_dmodel
);
612 int proc_ide_read_driver
613 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
615 ide_drive_t
*drive
= (ide_drive_t
*) data
;
616 ide_driver_t
*driver
= drive
->driver
;
619 len
= sprintf(page
, "%s version %s\n",
620 driver
->name
, driver
->version
);
621 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
624 EXPORT_SYMBOL(proc_ide_read_driver
);
626 int proc_ide_write_driver
627 (struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
629 ide_drive_t
*drive
= (ide_drive_t
*) data
;
631 if (!capable(CAP_SYS_ADMIN
))
633 if (ide_replace_subdriver(drive
, buffer
))
638 EXPORT_SYMBOL(proc_ide_write_driver
);
640 int proc_ide_read_media
641 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
643 ide_drive_t
*drive
= (ide_drive_t
*) data
;
647 switch (drive
->media
) {
648 case ide_disk
: media
= "disk\n";
650 case ide_cdrom
: media
= "cdrom\n";
652 case ide_tape
: media
= "tape\n";
654 case ide_floppy
:media
= "floppy\n";
656 default: media
= "UNKNOWN\n";
661 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
664 EXPORT_SYMBOL(proc_ide_read_media
);
666 static ide_proc_entry_t generic_drive_entries
[] = {
667 { "driver", S_IFREG
|S_IRUGO
, proc_ide_read_driver
, proc_ide_write_driver
},
668 { "identify", S_IFREG
|S_IRUSR
, proc_ide_read_identify
, NULL
},
669 { "media", S_IFREG
|S_IRUGO
, proc_ide_read_media
, NULL
},
670 { "model", S_IFREG
|S_IRUGO
, proc_ide_read_dmodel
, NULL
},
671 { "settings", S_IFREG
|S_IRUSR
|S_IWUSR
,proc_ide_read_settings
, proc_ide_write_settings
},
672 { NULL
, 0, NULL
, NULL
}
675 void ide_add_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
, void *data
)
677 struct proc_dir_entry
*ent
;
681 while (p
->name
!= NULL
) {
682 ent
= create_proc_entry(p
->name
, p
->mode
, dir
);
686 ent
->read_proc
= p
->read_proc
;
687 ent
->write_proc
= p
->write_proc
;
692 EXPORT_SYMBOL(ide_add_proc_entries
);
694 void ide_remove_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
)
698 while (p
->name
!= NULL
) {
699 remove_proc_entry(p
->name
, dir
);
704 EXPORT_SYMBOL(ide_remove_proc_entries
);
706 void create_proc_ide_drives(ide_hwif_t
*hwif
)
709 struct proc_dir_entry
*ent
;
710 struct proc_dir_entry
*parent
= hwif
->proc
;
713 for (d
= 0; d
< MAX_DRIVES
; d
++) {
714 ide_drive_t
*drive
= &hwif
->drives
[d
];
721 drive
->proc
= proc_mkdir(drive
->name
, parent
);
723 ide_add_proc_entries(drive
->proc
, generic_drive_entries
, drive
);
724 sprintf(name
,"ide%d/%s", (drive
->name
[2]-'a')/2, drive
->name
);
725 ent
= proc_symlink(drive
->name
, proc_ide_root
, name
);
730 EXPORT_SYMBOL(create_proc_ide_drives
);
732 void destroy_proc_ide_device(ide_hwif_t
*hwif
, ide_drive_t
*drive
)
734 ide_driver_t
*driver
= drive
->driver
;
737 ide_remove_proc_entries(drive
->proc
, driver
->proc
);
738 ide_remove_proc_entries(drive
->proc
, generic_drive_entries
);
739 remove_proc_entry(drive
->name
, proc_ide_root
);
740 remove_proc_entry(drive
->name
, hwif
->proc
);
745 EXPORT_SYMBOL(destroy_proc_ide_device
);
747 void destroy_proc_ide_drives(ide_hwif_t
*hwif
)
751 for (d
= 0; d
< MAX_DRIVES
; d
++) {
752 ide_drive_t
*drive
= &hwif
->drives
[d
];
754 destroy_proc_ide_device(hwif
, drive
);
758 EXPORT_SYMBOL(destroy_proc_ide_drives
);
760 static ide_proc_entry_t hwif_entries
[] = {
761 { "channel", S_IFREG
|S_IRUGO
, proc_ide_read_channel
, NULL
},
762 { "config", S_IFREG
|S_IRUGO
|S_IWUSR
,proc_ide_read_config
, proc_ide_write_config
},
763 { "mate", S_IFREG
|S_IRUGO
, proc_ide_read_mate
, NULL
},
764 { "model", S_IFREG
|S_IRUGO
, proc_ide_read_imodel
, NULL
},
765 { NULL
, 0, NULL
, NULL
}
768 void create_proc_ide_interfaces(void)
772 for (h
= 0; h
< MAX_HWIFS
; h
++) {
773 ide_hwif_t
*hwif
= &ide_hwifs
[h
];
778 hwif
->proc
= proc_mkdir(hwif
->name
, proc_ide_root
);
781 ide_add_proc_entries(hwif
->proc
, hwif_entries
, hwif
);
783 create_proc_ide_drives(hwif
);
787 #ifdef CONFIG_BLK_DEV_IDEPCI
788 void ide_pci_register_host_proc (ide_pci_host_proc_t
*p
)
790 ide_pci_host_proc_t
*tmp
;
795 if (ide_pci_host_proc_list
) {
796 tmp
= ide_pci_host_proc_list
;
797 while (tmp
->next
) tmp
= tmp
->next
;
800 ide_pci_host_proc_list
= p
;
803 EXPORT_SYMBOL(ide_pci_register_host_proc
);
805 #endif /* CONFIG_BLK_DEV_IDEPCI */
807 EXPORT_SYMBOL(create_proc_ide_interfaces
);
809 void destroy_proc_ide_interfaces(void)
813 for (h
= 0; h
< MAX_HWIFS
; h
++) {
814 ide_hwif_t
*hwif
= &ide_hwifs
[h
];
815 int exist
= (hwif
->proc
!= NULL
);
821 destroy_proc_ide_drives(hwif
);
822 ide_remove_proc_entries(hwif
->proc
, hwif_entries
);
823 remove_proc_entry(hwif
->name
, proc_ide_root
);
830 EXPORT_SYMBOL(destroy_proc_ide_interfaces
);
832 extern struct seq_operations ide_drivers_op
;
833 static int ide_drivers_open(struct inode
*inode
, struct file
*file
)
835 return seq_open(file
, &ide_drivers_op
);
837 static struct file_operations ide_drivers_operations
= {
838 .open
= ide_drivers_open
,
841 .release
= seq_release
,
844 void proc_ide_create(void)
846 #ifdef CONFIG_BLK_DEV_IDEPCI
847 ide_pci_host_proc_t
*p
= ide_pci_host_proc_list
;
848 #endif /* CONFIG_BLK_DEV_IDEPCI */
849 struct proc_dir_entry
*entry
;
850 proc_ide_root
= proc_mkdir("ide", 0);
851 if (!proc_ide_root
) return;
853 create_proc_ide_interfaces();
855 entry
= create_proc_entry("drivers", 0, proc_ide_root
);
857 entry
->proc_fops
= &ide_drivers_operations
;
859 #ifdef CONFIG_BLK_DEV_IDEPCI
862 if (p
->name
!= NULL
&& p
->set
== 1 && p
->get_info
!= NULL
)
864 p
->parent
= proc_ide_root
;
865 create_proc_info_entry(p
->name
, 0, p
->parent
, p
->get_info
);
870 #endif /* CONFIG_BLK_DEV_IDEPCI */
873 EXPORT_SYMBOL(proc_ide_create
);
875 void proc_ide_destroy(void)
877 #ifdef CONFIG_BLK_DEV_IDEPCI
878 ide_pci_host_proc_t
*p
;
880 for (p
= ide_pci_host_proc_list
; p
; p
= p
->next
) {
882 remove_proc_entry(p
->name
, p
->parent
);
884 #endif /* CONFIG_BLK_DEV_IDEPCI */
885 remove_proc_entry("ide/drivers", proc_ide_root
);
886 destroy_proc_ide_interfaces();
887 remove_proc_entry("ide", 0);
890 EXPORT_SYMBOL(proc_ide_destroy
);