17 #include <linux/module.h>
19 #include <asm/uaccess.h>
20 #include <linux/errno.h>
22 #include <linux/stat.h>
24 #include <linux/pci.h>
25 #include <linux/ctype.h>
28 #include <linux/slab.h>
34 static int ide_imodel_proc_show(
struct seq_file *
m,
void *
v)
53 default:
name =
"(unknown)";
break;
66 .open = ide_imodel_proc_open,
72 static int ide_mate_proc_show(
struct seq_file *m,
void *v)
83 static int ide_mate_proc_open(
struct inode *inode,
struct file *file)
90 .open = ide_mate_proc_open,
96 static int ide_channel_proc_show(
struct seq_file *m,
void *v)
104 static int ide_channel_proc_open(
struct inode *inode,
struct file *file)
111 .open = ide_channel_proc_open,
117 static int ide_identify_proc_show(
struct seq_file *m,
void *v)
136 (i % 8) == 7 ?
'\n' :
' ');
144 static int ide_identify_proc_open(
struct inode *inode,
struct file *file)
151 .open = ide_identify_proc_open,
168 const struct ide_proc_devset *ide_find_setting(
const struct ide_proc_devset *
st,
172 if (
strcmp(st->name, name) == 0)
176 return st->name ? st :
NULL;
193 const struct ide_proc_devset *setting)
199 val = ds->
get(drive);
223 const struct ide_proc_devset *setting,
int val)
225 const struct ide_devset *ds = setting->setting;
232 && (val < setting->
min || val > setting->max))
249 cmd.tf.nsect = (
u8)arg;
262 static const struct ide_proc_devset ide_generic_settings[] = {
263 IDE_PROC_DEVSET(current_speed, 0, 70),
264 IDE_PROC_DEVSET(init_speed, 0, 70),
266 IDE_PROC_DEVSET(keepsettings, 0, 1),
267 IDE_PROC_DEVSET(nice1, 0, 1),
268 IDE_PROC_DEVSET(number, 0, 3),
269 IDE_PROC_DEVSET(pio_mode, 0, 255),
270 IDE_PROC_DEVSET(unmaskirq, 0, 1),
271 IDE_PROC_DEVSET(using_dma, 0, 1),
275 static void proc_ide_settings_warn(
void)
278 "obsolete, and will be removed soon!\n");
281 static int ide_settings_proc_show(
struct seq_file *m,
void *v)
283 const struct ide_proc_devset *setting, *
g, *
d;
288 proc_ide_settings_warn();
291 g = ide_generic_settings;
293 seq_printf(m,
"name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
294 seq_printf(m,
"----\t\t\t-----\t\t---\t\t---\t\t----\n");
295 while (g->name || (d && d->name)) {
297 if (g->name && d && d->name) {
298 if (
strcmp(d->name, g->name) < 0)
302 }
else if (d && d->name) {
306 mul_factor = setting->mulf ? setting->mulf(drive) : 1;
307 div_factor = setting->divf ? setting->divf(drive) : 1;
309 rc = ide_read_setting(drive, setting);
315 ds = setting->setting;
326 static int ide_settings_proc_open(
struct inode *inode,
struct file *file)
333 static ssize_t ide_settings_proc_write(
struct file *file,
const char __user *
buffer,
341 const struct ide_proc_devset *setting;
347 proc_ide_settings_warn();
381 while (n > 0 && *p !=
':') {
410 setting = ide_find_setting(ide_generic_settings, name);
413 setting = ide_find_setting(drive->settings, name);
420 mul_factor = setting->mulf ? setting->mulf(drive) : 1;
421 div_factor = setting->divf ? setting->divf(drive) : 1;
422 ide_write_setting(drive, setting, val * div_factor / mul_factor);
426 }
while (!for_real++);
431 printk(
"%s(): parse error\n", __func__);
437 .open = ide_settings_proc_open,
441 .write = ide_settings_proc_write,
444 static int ide_capacity_proc_show(
struct seq_file *m,
void *v)
446 seq_printf(m,
"%llu\n", (
long long)0x7fffffff);
450 static int ide_capacity_proc_open(
struct inode *inode,
struct file *file)
457 .open = ide_capacity_proc_open,
464 static int ide_geometry_proc_show(
struct seq_file *m,
void *v)
475 static int ide_geometry_proc_open(
struct inode *inode,
struct file *file)
482 .open = ide_geometry_proc_open,
489 static int ide_dmodel_proc_show(
struct seq_file *seq,
void *v)
494 seq_printf(seq,
"%.40s\n", m[0] ? m :
"(none)");
498 static int ide_dmodel_proc_open(
struct inode *inode,
struct file *file)
505 .open = ide_dmodel_proc_open,
511 static int ide_driver_proc_show(
struct seq_file *m,
void *v)
520 dev->driver->name, ide_drv->version);
522 seq_printf(m,
"ide-default version 0.9.newide\n");
526 static int ide_driver_proc_open(
struct inode *inode,
struct file *file)
549 "IDE: %s: device_attach(2) error: %d\n",
558 static ssize_t ide_driver_proc_write(
struct file *file,
const char __user *
buffer,
571 if (ide_replace_subdriver(drive, name))
578 .open = ide_driver_proc_open,
582 .write = ide_driver_proc_write,
585 static int ide_media_proc_show(
struct seq_file *m,
void *v)
590 switch (drive->
media) {
591 case ide_disk: media =
"disk\n";
break;
592 case ide_cdrom: media =
"cdrom\n";
break;
593 case ide_tape: media =
"tape\n";
break;
596 default: media =
"UNKNOWN\n";
break;
602 static int ide_media_proc_open(
struct inode *inode,
struct file *file)
609 .open = ide_media_proc_open,
615 static ide_proc_entry_t generic_drive_entries[] = {
624 static void ide_add_proc_entries(
struct proc_dir_entry *dir, ide_proc_entry_t *
p,
void *
data)
630 while (p->name !=
NULL) {
637 static void ide_remove_proc_entries(
struct proc_dir_entry *dir, ide_proc_entry_t *p)
641 while (p->name !=
NULL) {
650 drive->settings = driver->proc_devsets(drive);
653 ide_add_proc_entries(drive->proc, driver->proc_entries(drive), drive);
671 ide_remove_proc_entries(drive->proc, driver->proc_entries(drive));
678 drive->settings =
NULL;
697 ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
707 ide_remove_proc_entries(drive->proc, generic_drive_entries);
714 static ide_proc_entry_t hwif_entries[] = {
729 ide_add_proc_entries(hwif->
proc, hwif_entries, hwif);
736 ide_remove_proc_entries(hwif->
proc, hwif_entries);
742 static int proc_print_driver(
struct device_driver *drv,
void *data)
752 static int ide_drivers_show(
struct seq_file *
s,
void *p)
763 static int ide_drivers_open(
struct inode *inode,
struct file *file)
770 .open = ide_drivers_open,
783 proc_create(
"drivers", 0, proc_ide_root, &ide_drivers_operations);