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>
7 * Some code was moved here from ide.c, see it for original copyrights.
11 * This is the /proc/ide/ filesystem implementation.
13 * Drive/Driver settings can be retrieved by reading the drive's
14 * "settings" files. e.g. "cat /proc/ide0/hda/settings"
15 * To write a new value "val" into a specific setting "name", use:
16 * echo "name:val" >/proc/ide/ide0/hda/settings
18 * Also useful, "cat /proc/ide0/hda/[identify, smart_values,
19 * smart_thresholds, capabilities]" will issue an IDENTIFY /
20 * PACKET_IDENTIFY / SMART_READ_VALUES / SMART_READ_THRESHOLDS /
21 * SENSE CAPABILITIES command to /dev/hda, and then dump out the
22 * returned data as 256 16-bit words. The "hdparm" utility will
23 * be updated someday soon to use this mechanism.
27 #include <linux/module.h>
29 #include <asm/uaccess.h>
30 #include <linux/errno.h>
31 #include <linux/proc_fs.h>
32 #include <linux/stat.h>
34 #include <linux/pci.h>
35 #include <linux/ctype.h>
36 #include <linux/hdreg.h>
37 #include <linux/ide.h>
38 #include <linux/seq_file.h>
42 static struct proc_dir_entry
*proc_ide_root
;
44 static int proc_ide_read_imodel
45 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
47 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
52 * Neither ide_unknown nor ide_forced should be set at this point.
54 switch (hwif
->chipset
) {
55 case ide_generic
: name
= "generic"; break;
56 case ide_pci
: name
= "pci"; break;
57 case ide_cmd640
: name
= "cmd640"; break;
58 case ide_dtc2278
: name
= "dtc2278"; break;
59 case ide_ali14xx
: name
= "ali14xx"; break;
60 case ide_qd65xx
: name
= "qd65xx"; break;
61 case ide_umc8672
: name
= "umc8672"; break;
62 case ide_ht6560b
: name
= "ht6560b"; break;
63 case ide_rz1000
: name
= "rz1000"; break;
64 case ide_trm290
: name
= "trm290"; break;
65 case ide_cmd646
: name
= "cmd646"; break;
66 case ide_cy82c693
: name
= "cy82c693"; break;
67 case ide_4drives
: name
= "4drives"; break;
68 case ide_pmac
: name
= "mac-io"; break;
69 case ide_au1xxx
: name
= "au1xxx"; break;
70 default: name
= "(unknown)"; break;
72 len
= sprintf(page
, "%s\n", name
);
73 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
76 static int proc_ide_read_mate
77 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
79 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
82 if (hwif
&& hwif
->mate
&& hwif
->mate
->present
)
83 len
= sprintf(page
, "%s\n", hwif
->mate
->name
);
85 len
= sprintf(page
, "(none)\n");
86 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
89 static int proc_ide_read_channel
90 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
92 ide_hwif_t
*hwif
= (ide_hwif_t
*) data
;
95 page
[0] = hwif
->channel
? '1' : '0';
98 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
101 static int proc_ide_read_identify
102 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
104 ide_drive_t
*drive
= (ide_drive_t
*)data
;
108 len
= sprintf(page
, "\n");
111 unsigned short *val
= (unsigned short *) page
;
113 err
= taskfile_lib_get_identify(drive
, page
);
115 char *out
= ((char *)page
) + (SECTOR_WORDS
* 4);
118 out
+= sprintf(out
, "%04x%c",
119 le16_to_cpu(*val
), (++i
& 7) ? ' ' : '\n');
121 } while (i
< (SECTOR_WORDS
* 2));
125 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
129 * __ide_add_setting - add an ide setting option
130 * @drive: drive to use
131 * @name: setting name
132 * @rw: true if the function is read write
133 * @data_type: type of data
134 * @min: range minimum
135 * @max: range maximum
136 * @mul_factor: multiplication scale
137 * @div_factor: divison scale
138 * @data: private data field
140 * @auto_remove: setting auto removal flag
142 * Removes the setting named from the device if it is present.
143 * The function takes the settings_lock to protect against
144 * parallel changes. This function must not be called from IRQ
145 * context. Returns 0 on success or -1 on failure.
147 * BUGS: This code is seriously over-engineered. There is also
148 * magic about how the driver specific features are setup. If
149 * a driver is attached we assume the driver settings are auto
153 static int __ide_add_setting(ide_drive_t
*drive
, const char *name
, int rw
, int data_type
, int min
, int max
, int mul_factor
, int div_factor
, void *data
, ide_procset_t
*set
, int auto_remove
)
155 ide_settings_t
**p
= (ide_settings_t
**) &drive
->settings
, *setting
= NULL
;
157 down(&ide_setting_sem
);
158 while ((*p
) && strcmp((*p
)->name
, name
) < 0)
160 if ((setting
= kzalloc(sizeof(*setting
), GFP_KERNEL
)) == NULL
)
162 if ((setting
->name
= kmalloc(strlen(name
) + 1, GFP_KERNEL
)) == NULL
)
164 strcpy(setting
->name
, name
);
166 setting
->data_type
= data_type
;
169 setting
->mul_factor
= mul_factor
;
170 setting
->div_factor
= div_factor
;
171 setting
->data
= data
;
176 setting
->auto_remove
= 1;
178 up(&ide_setting_sem
);
181 up(&ide_setting_sem
);
186 int ide_add_setting(ide_drive_t
*drive
, const char *name
, int rw
, int data_type
, int min
, int max
, int mul_factor
, int div_factor
, void *data
, ide_procset_t
*set
)
188 return __ide_add_setting(drive
, name
, rw
, data_type
, min
, max
, mul_factor
, div_factor
, data
, set
, 1);
191 EXPORT_SYMBOL(ide_add_setting
);
194 * __ide_remove_setting - remove an ide setting option
195 * @drive: drive to use
196 * @name: setting name
198 * Removes the setting named from the device if it is present.
199 * The caller must hold the setting semaphore.
202 static void __ide_remove_setting (ide_drive_t
*drive
, char *name
)
204 ide_settings_t
**p
, *setting
;
206 p
= (ide_settings_t
**) &drive
->settings
;
208 while ((*p
) && strcmp((*p
)->name
, name
))
210 if ((setting
= (*p
)) == NULL
)
213 (*p
) = setting
->next
;
215 kfree(setting
->name
);
220 * auto_remove_settings - remove driver specific settings
223 * Automatically remove all the driver specific settings for this
224 * drive. This function may not be called from IRQ context. The
225 * caller must hold ide_setting_sem.
228 static void auto_remove_settings (ide_drive_t
*drive
)
230 ide_settings_t
*setting
;
232 setting
= drive
->settings
;
234 if (setting
->auto_remove
) {
235 __ide_remove_setting(drive
, setting
->name
);
238 setting
= setting
->next
;
243 * ide_find_setting_by_name - find a drive specific setting
244 * @drive: drive to scan
245 * @name: setting name
247 * Scan's the device setting table for a matching entry and returns
248 * this or NULL if no entry is found. The caller must hold the
252 static ide_settings_t
*ide_find_setting_by_name(ide_drive_t
*drive
, char *name
)
254 ide_settings_t
*setting
= drive
->settings
;
257 if (strcmp(setting
->name
, name
) == 0)
259 setting
= setting
->next
;
265 * ide_read_setting - read an IDE setting
266 * @drive: drive to read from
267 * @setting: drive setting
269 * Read a drive setting and return the value. The caller
270 * must hold the ide_setting_sem when making this call.
272 * BUGS: the data return and error are the same return value
273 * so an error -EINVAL and true return of the same value cannot
277 static int ide_read_setting(ide_drive_t
*drive
, ide_settings_t
*setting
)
282 if ((setting
->rw
& SETTING_READ
)) {
283 spin_lock_irqsave(&ide_lock
, flags
);
284 switch(setting
->data_type
) {
286 val
= *((u8
*) setting
->data
);
289 val
= *((u16
*) setting
->data
);
292 val
= *((u32
*) setting
->data
);
295 spin_unlock_irqrestore(&ide_lock
, flags
);
301 * ide_write_setting - read an IDE setting
302 * @drive: drive to read from
303 * @setting: drive setting
306 * Write a drive setting if it is possible. The caller
307 * must hold the ide_setting_sem when making this call.
309 * BUGS: the data return and error are the same return value
310 * so an error -EINVAL and true return of the same value cannot
313 * FIXME: This should be changed to enqueue a special request
314 * to the driver to change settings, and then wait on a sema for completion.
315 * The current scheme of polling is kludgy, though safe enough.
318 static int ide_write_setting(ide_drive_t
*drive
, ide_settings_t
*setting
, int val
)
320 if (!capable(CAP_SYS_ADMIN
))
323 return setting
->set(drive
, val
);
324 if (!(setting
->rw
& SETTING_WRITE
))
326 if (val
< setting
->min
|| val
> setting
->max
)
328 if (ide_spin_wait_hwgroup(drive
))
330 switch (setting
->data_type
) {
332 *((u8
*) setting
->data
) = val
;
335 *((u16
*) setting
->data
) = val
;
338 *((u32
*) setting
->data
) = val
;
341 spin_unlock_irq(&ide_lock
);
345 static int set_xfer_rate (ide_drive_t
*drive
, int arg
)
349 if (arg
< 0 || arg
> 70)
352 err
= ide_wait_cmd(drive
,
353 WIN_SETFEATURES
, (u8
) arg
,
354 SETFEATURES_XFER
, 0, NULL
);
357 ide_set_xfer_rate(drive
, (u8
) arg
);
358 ide_driveid_update(drive
);
364 * ide_add_generic_settings - generic ide settings
365 * @drive: drive being configured
367 * Add the generic parts of the system settings to the /proc files.
368 * The caller must not be holding the ide_setting_sem.
371 void ide_add_generic_settings (ide_drive_t
*drive
)
374 * drive setting name read/write access data type min max mul_factor div_factor data pointer set function
376 __ide_add_setting(drive
, "io_32bit", drive
->no_io_32bit
? SETTING_READ
: SETTING_RW
, TYPE_BYTE
, 0, 1 + (SUPPORT_VLB_SYNC
<< 1), 1, 1, &drive
->io_32bit
, set_io_32bit
, 0);
377 __ide_add_setting(drive
, "keepsettings", SETTING_RW
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->keep_settings
, NULL
, 0);
378 __ide_add_setting(drive
, "nice1", SETTING_RW
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->nice1
, NULL
, 0);
379 __ide_add_setting(drive
, "pio_mode", SETTING_WRITE
, TYPE_BYTE
, 0, 255, 1, 1, NULL
, set_pio_mode
, 0);
380 __ide_add_setting(drive
, "unmaskirq", drive
->no_unmask
? SETTING_READ
: SETTING_RW
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->unmask
, NULL
, 0);
381 __ide_add_setting(drive
, "using_dma", SETTING_RW
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->using_dma
, set_using_dma
, 0);
382 __ide_add_setting(drive
, "init_speed", SETTING_RW
, TYPE_BYTE
, 0, 70, 1, 1, &drive
->init_speed
, NULL
, 0);
383 __ide_add_setting(drive
, "current_speed", SETTING_RW
, TYPE_BYTE
, 0, 70, 1, 1, &drive
->current_speed
, set_xfer_rate
, 0);
384 __ide_add_setting(drive
, "number", SETTING_RW
, TYPE_BYTE
, 0, 3, 1, 1, &drive
->dn
, NULL
, 0);
387 static void proc_ide_settings_warn(void)
389 static int warned
= 0;
394 printk(KERN_WARNING
"Warning: /proc/ide/hd?/settings interface is "
395 "obsolete, and will be removed soon!\n");
399 static int proc_ide_read_settings
400 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
402 ide_drive_t
*drive
= (ide_drive_t
*) data
;
403 ide_settings_t
*setting
= (ide_settings_t
*) drive
->settings
;
405 int len
, rc
, mul_factor
, div_factor
;
407 proc_ide_settings_warn();
409 down(&ide_setting_sem
);
410 out
+= sprintf(out
, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
411 out
+= sprintf(out
, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
413 mul_factor
= setting
->mul_factor
;
414 div_factor
= setting
->div_factor
;
415 out
+= sprintf(out
, "%-24s", setting
->name
);
416 if ((rc
= ide_read_setting(drive
, setting
)) >= 0)
417 out
+= sprintf(out
, "%-16d", rc
* mul_factor
/ div_factor
);
419 out
+= sprintf(out
, "%-16s", "write-only");
420 out
+= sprintf(out
, "%-16d%-16d", (setting
->min
* mul_factor
+ div_factor
- 1) / div_factor
, setting
->max
* mul_factor
/ div_factor
);
421 if (setting
->rw
& SETTING_READ
)
422 out
+= sprintf(out
, "r");
423 if (setting
->rw
& SETTING_WRITE
)
424 out
+= sprintf(out
, "w");
425 out
+= sprintf(out
, "\n");
426 setting
= setting
->next
;
429 up(&ide_setting_sem
);
430 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
435 static int proc_ide_write_settings(struct file
*file
, const char __user
*buffer
,
436 unsigned long count
, void *data
)
438 ide_drive_t
*drive
= (ide_drive_t
*) data
;
439 char name
[MAX_LEN
+ 1];
442 ide_settings_t
*setting
;
445 if (!capable(CAP_SYS_ADMIN
))
448 proc_ide_settings_warn();
450 if (count
>= PAGE_SIZE
)
453 s
= buf
= (char *)__get_free_page(GFP_USER
);
457 if (copy_from_user(buf
, buffer
, count
)) {
458 free_page((unsigned long)buf
);
465 * Skip over leading whitespace
467 while (count
&& isspace(*s
)) {
472 * Do one full pass to verify all parameters,
473 * then do another to actually write the new settings.
482 while (n
> 0 && *p
!= ':') {
490 memcpy(name
, q
, p
- q
);
499 val
= simple_strtoul(p
, &q
, 10);
502 if (n
> 0 && !isspace(*p
))
504 while (n
> 0 && isspace(*p
)) {
509 down(&ide_setting_sem
);
510 setting
= ide_find_setting_by_name(drive
, name
);
513 up(&ide_setting_sem
);
517 ide_write_setting(drive
, setting
, val
* setting
->div_factor
/ setting
->mul_factor
);
518 up(&ide_setting_sem
);
520 } while (!for_real
++);
521 free_page((unsigned long)buf
);
524 free_page((unsigned long)buf
);
525 printk("proc_ide_write_settings(): parse error\n");
529 int proc_ide_read_capacity
530 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
532 int len
= sprintf(page
,"%llu\n", (long long)0x7fffffff);
533 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
536 EXPORT_SYMBOL_GPL(proc_ide_read_capacity
);
538 int proc_ide_read_geometry
539 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
541 ide_drive_t
*drive
= (ide_drive_t
*) data
;
545 out
+= sprintf(out
,"physical %d/%d/%d\n",
546 drive
->cyl
, drive
->head
, drive
->sect
);
547 out
+= sprintf(out
,"logical %d/%d/%d\n",
548 drive
->bios_cyl
, drive
->bios_head
, drive
->bios_sect
);
551 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
554 EXPORT_SYMBOL(proc_ide_read_geometry
);
556 static int proc_ide_read_dmodel
557 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
559 ide_drive_t
*drive
= (ide_drive_t
*) data
;
560 struct hd_driveid
*id
= drive
->id
;
563 len
= sprintf(page
, "%.40s\n",
564 (id
&& id
->model
[0]) ? (char *)id
->model
: "(none)");
565 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
568 static int proc_ide_read_driver
569 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
571 ide_drive_t
*drive
= (ide_drive_t
*) data
;
572 struct device
*dev
= &drive
->gendev
;
573 ide_driver_t
*ide_drv
;
577 ide_drv
= container_of(dev
->driver
, ide_driver_t
, gen_driver
);
578 len
= sprintf(page
, "%s version %s\n",
579 dev
->driver
->name
, ide_drv
->version
);
581 len
= sprintf(page
, "ide-default version 0.9.newide\n");
582 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
585 static int ide_replace_subdriver(ide_drive_t
*drive
, const char *driver
)
587 struct device
*dev
= &drive
->gendev
;
591 device_release_driver(dev
);
592 /* FIXME: device can still be in use by previous driver */
593 strlcpy(drive
->driver_req
, driver
, sizeof(drive
->driver_req
));
594 err
= device_attach(dev
);
596 printk(KERN_WARNING
"IDE: %s: device_attach error: %d\n",
598 drive
->driver_req
[0] = 0;
599 if (dev
->driver
== NULL
) {
600 err
= device_attach(dev
);
603 "IDE: %s: device_attach(2) error: %d\n",
606 if (dev
->driver
&& !strcmp(dev
->driver
->name
, driver
))
612 static int proc_ide_write_driver
613 (struct file
*file
, const char __user
*buffer
, unsigned long count
, void *data
)
615 ide_drive_t
*drive
= (ide_drive_t
*) data
;
618 if (!capable(CAP_SYS_ADMIN
))
622 if (copy_from_user(name
, buffer
, count
))
625 if (ide_replace_subdriver(drive
, name
))
630 static int proc_ide_read_media
631 (char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
633 ide_drive_t
*drive
= (ide_drive_t
*) data
;
637 switch (drive
->media
) {
638 case ide_disk
: media
= "disk\n";
640 case ide_cdrom
: media
= "cdrom\n";
642 case ide_tape
: media
= "tape\n";
644 case ide_floppy
:media
= "floppy\n";
646 case ide_optical
:media
= "optical\n";
648 default: media
= "UNKNOWN\n";
653 PROC_IDE_READ_RETURN(page
,start
,off
,count
,eof
,len
);
656 static ide_proc_entry_t generic_drive_entries
[] = {
657 { "driver", S_IFREG
|S_IRUGO
, proc_ide_read_driver
, proc_ide_write_driver
},
658 { "identify", S_IFREG
|S_IRUSR
, proc_ide_read_identify
, NULL
},
659 { "media", S_IFREG
|S_IRUGO
, proc_ide_read_media
, NULL
},
660 { "model", S_IFREG
|S_IRUGO
, proc_ide_read_dmodel
, NULL
},
661 { "settings", S_IFREG
|S_IRUSR
|S_IWUSR
,proc_ide_read_settings
, proc_ide_write_settings
},
662 { NULL
, 0, NULL
, NULL
}
665 static void ide_add_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
, void *data
)
667 struct proc_dir_entry
*ent
;
671 while (p
->name
!= NULL
) {
672 ent
= create_proc_entry(p
->name
, p
->mode
, dir
);
675 ent
->read_proc
= p
->read_proc
;
676 ent
->write_proc
= p
->write_proc
;
681 static void ide_remove_proc_entries(struct proc_dir_entry
*dir
, ide_proc_entry_t
*p
)
685 while (p
->name
!= NULL
) {
686 remove_proc_entry(p
->name
, dir
);
691 void ide_proc_register_driver(ide_drive_t
*drive
, ide_driver_t
*driver
)
693 ide_add_proc_entries(drive
->proc
, driver
->proc
, drive
);
696 EXPORT_SYMBOL(ide_proc_register_driver
);
699 * ide_proc_unregister_driver - remove driver specific data
703 * Clean up the driver specific /proc files and IDE settings
706 * Takes ide_setting_sem and ide_lock.
707 * Caller must hold none of the locks.
710 void ide_proc_unregister_driver(ide_drive_t
*drive
, ide_driver_t
*driver
)
714 ide_remove_proc_entries(drive
->proc
, driver
->proc
);
716 down(&ide_setting_sem
);
717 spin_lock_irqsave(&ide_lock
, flags
);
719 * ide_setting_sem protects the settings list
720 * ide_lock protects the use of settings
722 * so we need to hold both, ide_settings_sem because we want to
723 * modify the settings list, and ide_lock because we cannot take
724 * a setting out that is being used.
726 * OTOH both ide_{read,write}_setting are only ever used under
729 auto_remove_settings(drive
);
730 spin_unlock_irqrestore(&ide_lock
, flags
);
731 up(&ide_setting_sem
);
734 EXPORT_SYMBOL(ide_proc_unregister_driver
);
736 static void create_proc_ide_drives(ide_hwif_t
*hwif
)
739 struct proc_dir_entry
*ent
;
740 struct proc_dir_entry
*parent
= hwif
->proc
;
743 for (d
= 0; d
< MAX_DRIVES
; d
++) {
744 ide_drive_t
*drive
= &hwif
->drives
[d
];
751 drive
->proc
= proc_mkdir(drive
->name
, parent
);
753 ide_add_proc_entries(drive
->proc
, generic_drive_entries
, drive
);
754 sprintf(name
,"ide%d/%s", (drive
->name
[2]-'a')/2, drive
->name
);
755 ent
= proc_symlink(drive
->name
, proc_ide_root
, name
);
760 static void destroy_proc_ide_device(ide_hwif_t
*hwif
, ide_drive_t
*drive
)
763 ide_remove_proc_entries(drive
->proc
, generic_drive_entries
);
764 remove_proc_entry(drive
->name
, proc_ide_root
);
765 remove_proc_entry(drive
->name
, hwif
->proc
);
770 static void destroy_proc_ide_drives(ide_hwif_t
*hwif
)
774 for (d
= 0; d
< MAX_DRIVES
; d
++) {
775 ide_drive_t
*drive
= &hwif
->drives
[d
];
777 destroy_proc_ide_device(hwif
, drive
);
781 static ide_proc_entry_t hwif_entries
[] = {
782 { "channel", S_IFREG
|S_IRUGO
, proc_ide_read_channel
, NULL
},
783 { "mate", S_IFREG
|S_IRUGO
, proc_ide_read_mate
, NULL
},
784 { "model", S_IFREG
|S_IRUGO
, proc_ide_read_imodel
, NULL
},
785 { NULL
, 0, NULL
, NULL
}
788 void ide_proc_register_port(ide_hwif_t
*hwif
)
794 hwif
->proc
= proc_mkdir(hwif
->name
, proc_ide_root
);
799 ide_add_proc_entries(hwif
->proc
, hwif_entries
, hwif
);
802 create_proc_ide_drives(hwif
);
805 EXPORT_SYMBOL_GPL(ide_proc_register_port
);
807 #ifdef CONFIG_BLK_DEV_IDEPCI
808 void ide_pci_create_host_proc(const char *name
, get_info_t
*get_info
)
810 create_proc_info_entry(name
, 0, proc_ide_root
, get_info
);
813 EXPORT_SYMBOL_GPL(ide_pci_create_host_proc
);
816 void ide_proc_unregister_port(ide_hwif_t
*hwif
)
819 destroy_proc_ide_drives(hwif
);
820 ide_remove_proc_entries(hwif
->proc
, hwif_entries
);
821 remove_proc_entry(hwif
->name
, proc_ide_root
);
826 static int proc_print_driver(struct device_driver
*drv
, void *data
)
828 ide_driver_t
*ide_drv
= container_of(drv
, ide_driver_t
, gen_driver
);
829 struct seq_file
*s
= data
;
831 seq_printf(s
, "%s version %s\n", drv
->name
, ide_drv
->version
);
836 static int ide_drivers_show(struct seq_file
*s
, void *p
)
840 err
= bus_for_each_drv(&ide_bus_type
, NULL
, s
, proc_print_driver
);
842 printk(KERN_WARNING
"IDE: %s: bus_for_each_drv error: %d\n",
847 static int ide_drivers_open(struct inode
*inode
, struct file
*file
)
849 return single_open(file
, &ide_drivers_show
, NULL
);
852 static const struct file_operations ide_drivers_operations
= {
853 .open
= ide_drivers_open
,
856 .release
= single_release
,
859 void proc_ide_create(void)
861 struct proc_dir_entry
*entry
;
863 proc_ide_root
= proc_mkdir("ide", NULL
);
868 entry
= create_proc_entry("drivers", 0, proc_ide_root
);
870 entry
->proc_fops
= &ide_drivers_operations
;
873 void proc_ide_destroy(void)
875 remove_proc_entry("drivers", proc_ide_root
);
876 remove_proc_entry("ide", NULL
);