diff options
Diffstat (limited to 'drivers/ide/ide-proc.c')
-rw-r--r-- | drivers/ide/ide-proc.c | 340 |
1 files changed, 217 insertions, 123 deletions
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 3242698832a4..28d09a5d8450 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -30,11 +30,9 @@ | |||
30 | 30 | ||
31 | static struct proc_dir_entry *proc_ide_root; | 31 | static struct proc_dir_entry *proc_ide_root; |
32 | 32 | ||
33 | static int proc_ide_read_imodel | 33 | static int ide_imodel_proc_show(struct seq_file *m, void *v) |
34 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
35 | { | 34 | { |
36 | ide_hwif_t *hwif = (ide_hwif_t *) data; | 35 | ide_hwif_t *hwif = (ide_hwif_t *) m->private; |
37 | int len; | ||
38 | const char *name; | 36 | const char *name; |
39 | 37 | ||
40 | switch (hwif->chipset) { | 38 | switch (hwif->chipset) { |
@@ -53,63 +51,108 @@ static int proc_ide_read_imodel | |||
53 | case ide_acorn: name = "acorn"; break; | 51 | case ide_acorn: name = "acorn"; break; |
54 | default: name = "(unknown)"; break; | 52 | default: name = "(unknown)"; break; |
55 | } | 53 | } |
56 | len = sprintf(page, "%s\n", name); | 54 | seq_printf(m, "%s\n", name); |
57 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 55 | return 0; |
58 | } | 56 | } |
59 | 57 | ||
60 | static int proc_ide_read_mate | 58 | static int ide_imodel_proc_open(struct inode *inode, struct file *file) |
61 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
62 | { | 59 | { |
63 | ide_hwif_t *hwif = (ide_hwif_t *) data; | 60 | return single_open(file, ide_imodel_proc_show, PDE(inode)->data); |
64 | int len; | 61 | } |
62 | |||
63 | static const struct file_operations ide_imodel_proc_fops = { | ||
64 | .owner = THIS_MODULE, | ||
65 | .open = ide_imodel_proc_open, | ||
66 | .read = seq_read, | ||
67 | .llseek = seq_lseek, | ||
68 | .release = single_release, | ||
69 | }; | ||
70 | |||
71 | static int ide_mate_proc_show(struct seq_file *m, void *v) | ||
72 | { | ||
73 | ide_hwif_t *hwif = (ide_hwif_t *) m->private; | ||
65 | 74 | ||
66 | if (hwif && hwif->mate) | 75 | if (hwif && hwif->mate) |
67 | len = sprintf(page, "%s\n", hwif->mate->name); | 76 | seq_printf(m, "%s\n", hwif->mate->name); |
68 | else | 77 | else |
69 | len = sprintf(page, "(none)\n"); | 78 | seq_printf(m, "(none)\n"); |
70 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 79 | return 0; |
80 | } | ||
81 | |||
82 | static int ide_mate_proc_open(struct inode *inode, struct file *file) | ||
83 | { | ||
84 | return single_open(file, ide_mate_proc_show, PDE(inode)->data); | ||
71 | } | 85 | } |
72 | 86 | ||
73 | static int proc_ide_read_channel | 87 | static const struct file_operations ide_mate_proc_fops = { |
74 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 88 | .owner = THIS_MODULE, |
89 | .open = ide_mate_proc_open, | ||
90 | .read = seq_read, | ||
91 | .llseek = seq_lseek, | ||
92 | .release = single_release, | ||
93 | }; | ||
94 | |||
95 | static int ide_channel_proc_show(struct seq_file *m, void *v) | ||
75 | { | 96 | { |
76 | ide_hwif_t *hwif = (ide_hwif_t *) data; | 97 | ide_hwif_t *hwif = (ide_hwif_t *) m->private; |
77 | int len; | ||
78 | 98 | ||
79 | page[0] = hwif->channel ? '1' : '0'; | 99 | seq_printf(m, "%c\n", hwif->channel ? '1' : '0'); |
80 | page[1] = '\n'; | 100 | return 0; |
81 | len = 2; | ||
82 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
83 | } | 101 | } |
84 | 102 | ||
85 | static int proc_ide_read_identify | 103 | static int ide_channel_proc_open(struct inode *inode, struct file *file) |
86 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
87 | { | 104 | { |
88 | ide_drive_t *drive = (ide_drive_t *)data; | 105 | return single_open(file, ide_channel_proc_show, PDE(inode)->data); |
89 | int len = 0, i = 0; | 106 | } |
90 | int err = 0; | 107 | |
108 | static const struct file_operations ide_channel_proc_fops = { | ||
109 | .owner = THIS_MODULE, | ||
110 | .open = ide_channel_proc_open, | ||
111 | .read = seq_read, | ||
112 | .llseek = seq_lseek, | ||
113 | .release = single_release, | ||
114 | }; | ||
91 | 115 | ||
92 | len = sprintf(page, "\n"); | 116 | static int ide_identify_proc_show(struct seq_file *m, void *v) |
117 | { | ||
118 | ide_drive_t *drive = (ide_drive_t *)m->private; | ||
119 | u8 *buf; | ||
93 | 120 | ||
94 | if (drive) { | 121 | if (!drive) { |
95 | __le16 *val = (__le16 *)page; | 122 | seq_putc(m, '\n'); |
123 | return 0; | ||
124 | } | ||
96 | 125 | ||
97 | err = taskfile_lib_get_identify(drive, page); | 126 | buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); |
98 | if (!err) { | 127 | if (!buf) |
99 | char *out = (char *)page + SECTOR_SIZE; | 128 | return -ENOMEM; |
129 | if (taskfile_lib_get_identify(drive, buf) == 0) { | ||
130 | __le16 *val = (__le16 *)buf; | ||
131 | int i; | ||
100 | 132 | ||
101 | page = out; | 133 | for (i = 0; i < SECTOR_SIZE / 2; i++) { |
102 | do { | 134 | seq_printf(m, "%04x%c", le16_to_cpu(val[i]), |
103 | out += sprintf(out, "%04x%c", | 135 | (i % 8) == 7 ? '\n' : ' '); |
104 | le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); | ||
105 | val += 1; | ||
106 | } while (i < SECTOR_SIZE / 2); | ||
107 | len = out - page; | ||
108 | } | 136 | } |
109 | } | 137 | } else |
110 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 138 | seq_putc(m, buf[0]); |
139 | kfree(buf); | ||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int ide_identify_proc_open(struct inode *inode, struct file *file) | ||
144 | { | ||
145 | return single_open(file, ide_identify_proc_show, PDE(inode)->data); | ||
111 | } | 146 | } |
112 | 147 | ||
148 | static const struct file_operations ide_identify_proc_fops = { | ||
149 | .owner = THIS_MODULE, | ||
150 | .open = ide_identify_proc_open, | ||
151 | .read = seq_read, | ||
152 | .llseek = seq_lseek, | ||
153 | .release = single_release, | ||
154 | }; | ||
155 | |||
113 | /** | 156 | /** |
114 | * ide_find_setting - find a specific setting | 157 | * ide_find_setting - find a specific setting |
115 | * @st: setting table pointer | 158 | * @st: setting table pointer |
@@ -195,7 +238,6 @@ ide_devset_get(xfer_rate, current_speed); | |||
195 | static int set_xfer_rate (ide_drive_t *drive, int arg) | 238 | static int set_xfer_rate (ide_drive_t *drive, int arg) |
196 | { | 239 | { |
197 | struct ide_cmd cmd; | 240 | struct ide_cmd cmd; |
198 | int err; | ||
199 | 241 | ||
200 | if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) | 242 | if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) |
201 | return -EINVAL; | 243 | return -EINVAL; |
@@ -206,14 +248,9 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
206 | cmd.tf.nsect = (u8)arg; | 248 | cmd.tf.nsect = (u8)arg; |
207 | cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; | 249 | cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; |
208 | cmd.valid.in.tf = IDE_VALID_NSECT; | 250 | cmd.valid.in.tf = IDE_VALID_NSECT; |
251 | cmd.tf_flags = IDE_TFLAG_SET_XFER; | ||
209 | 252 | ||
210 | err = ide_no_data_taskfile(drive, &cmd); | 253 | return ide_no_data_taskfile(drive, &cmd); |
211 | |||
212 | if (!err) { | ||
213 | ide_set_xfer_rate(drive, (u8) arg); | ||
214 | ide_driveid_update(drive); | ||
215 | } | ||
216 | return err; | ||
217 | } | 254 | } |
218 | 255 | ||
219 | ide_devset_rw(current_speed, xfer_rate); | 256 | ide_devset_rw(current_speed, xfer_rate); |
@@ -246,22 +283,20 @@ static void proc_ide_settings_warn(void) | |||
246 | warned = 1; | 283 | warned = 1; |
247 | } | 284 | } |
248 | 285 | ||
249 | static int proc_ide_read_settings | 286 | static int ide_settings_proc_show(struct seq_file *m, void *v) |
250 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
251 | { | 287 | { |
252 | const struct ide_proc_devset *setting, *g, *d; | 288 | const struct ide_proc_devset *setting, *g, *d; |
253 | const struct ide_devset *ds; | 289 | const struct ide_devset *ds; |
254 | ide_drive_t *drive = (ide_drive_t *) data; | 290 | ide_drive_t *drive = (ide_drive_t *) m->private; |
255 | char *out = page; | 291 | int rc, mul_factor, div_factor; |
256 | int len, rc, mul_factor, div_factor; | ||
257 | 292 | ||
258 | proc_ide_settings_warn(); | 293 | proc_ide_settings_warn(); |
259 | 294 | ||
260 | mutex_lock(&ide_setting_mtx); | 295 | mutex_lock(&ide_setting_mtx); |
261 | g = ide_generic_settings; | 296 | g = ide_generic_settings; |
262 | d = drive->settings; | 297 | d = drive->settings; |
263 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); | 298 | seq_printf(m, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); |
264 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); | 299 | seq_printf(m, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); |
265 | while (g->name || (d && d->name)) { | 300 | while (g->name || (d && d->name)) { |
266 | /* read settings in the alphabetical order */ | 301 | /* read settings in the alphabetical order */ |
267 | if (g->name && d && d->name) { | 302 | if (g->name && d && d->name) { |
@@ -275,31 +310,35 @@ static int proc_ide_read_settings | |||
275 | setting = g++; | 310 | setting = g++; |
276 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; | 311 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; |
277 | div_factor = setting->divf ? setting->divf(drive) : 1; | 312 | div_factor = setting->divf ? setting->divf(drive) : 1; |
278 | out += sprintf(out, "%-24s", setting->name); | 313 | seq_printf(m, "%-24s", setting->name); |
279 | rc = ide_read_setting(drive, setting); | 314 | rc = ide_read_setting(drive, setting); |
280 | if (rc >= 0) | 315 | if (rc >= 0) |
281 | out += sprintf(out, "%-16d", rc * mul_factor / div_factor); | 316 | seq_printf(m, "%-16d", rc * mul_factor / div_factor); |
282 | else | 317 | else |
283 | out += sprintf(out, "%-16s", "write-only"); | 318 | seq_printf(m, "%-16s", "write-only"); |
284 | out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); | 319 | seq_printf(m, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); |
285 | ds = setting->setting; | 320 | ds = setting->setting; |
286 | if (ds->get) | 321 | if (ds->get) |
287 | out += sprintf(out, "r"); | 322 | seq_printf(m, "r"); |
288 | if (ds->set) | 323 | if (ds->set) |
289 | out += sprintf(out, "w"); | 324 | seq_printf(m, "w"); |
290 | out += sprintf(out, "\n"); | 325 | seq_printf(m, "\n"); |
291 | } | 326 | } |
292 | len = out - page; | ||
293 | mutex_unlock(&ide_setting_mtx); | 327 | mutex_unlock(&ide_setting_mtx); |
294 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 328 | return 0; |
329 | } | ||
330 | |||
331 | static int ide_settings_proc_open(struct inode *inode, struct file *file) | ||
332 | { | ||
333 | return single_open(file, ide_settings_proc_show, PDE(inode)->data); | ||
295 | } | 334 | } |
296 | 335 | ||
297 | #define MAX_LEN 30 | 336 | #define MAX_LEN 30 |
298 | 337 | ||
299 | static int proc_ide_write_settings(struct file *file, const char __user *buffer, | 338 | static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer, |
300 | unsigned long count, void *data) | 339 | size_t count, loff_t *pos) |
301 | { | 340 | { |
302 | ide_drive_t *drive = (ide_drive_t *) data; | 341 | ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; |
303 | char name[MAX_LEN + 1]; | 342 | char name[MAX_LEN + 1]; |
304 | int for_real = 0, mul_factor, div_factor; | 343 | int for_real = 0, mul_factor, div_factor; |
305 | unsigned long n; | 344 | unsigned long n; |
@@ -394,63 +433,104 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
394 | return count; | 433 | return count; |
395 | parse_error: | 434 | parse_error: |
396 | free_page((unsigned long)buf); | 435 | free_page((unsigned long)buf); |
397 | printk("proc_ide_write_settings(): parse error\n"); | 436 | printk("%s(): parse error\n", __func__); |
398 | return -EINVAL; | 437 | return -EINVAL; |
399 | } | 438 | } |
400 | 439 | ||
401 | int proc_ide_read_capacity | 440 | static const struct file_operations ide_settings_proc_fops = { |
402 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 441 | .owner = THIS_MODULE, |
442 | .open = ide_settings_proc_open, | ||
443 | .read = seq_read, | ||
444 | .llseek = seq_lseek, | ||
445 | .release = single_release, | ||
446 | .write = ide_settings_proc_write, | ||
447 | }; | ||
448 | |||
449 | static int ide_capacity_proc_show(struct seq_file *m, void *v) | ||
450 | { | ||
451 | seq_printf(m, "%llu\n", (long long)0x7fffffff); | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int ide_capacity_proc_open(struct inode *inode, struct file *file) | ||
403 | { | 456 | { |
404 | int len = sprintf(page, "%llu\n", (long long)0x7fffffff); | 457 | return single_open(file, ide_capacity_proc_show, NULL); |
405 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
406 | } | 458 | } |
407 | 459 | ||
408 | EXPORT_SYMBOL_GPL(proc_ide_read_capacity); | 460 | const struct file_operations ide_capacity_proc_fops = { |
461 | .owner = THIS_MODULE, | ||
462 | .open = ide_capacity_proc_open, | ||
463 | .read = seq_read, | ||
464 | .llseek = seq_lseek, | ||
465 | .release = single_release, | ||
466 | }; | ||
467 | EXPORT_SYMBOL_GPL(ide_capacity_proc_fops); | ||
409 | 468 | ||
410 | int proc_ide_read_geometry | 469 | static int ide_geometry_proc_show(struct seq_file *m, void *v) |
411 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
412 | { | 470 | { |
413 | ide_drive_t *drive = (ide_drive_t *) data; | 471 | ide_drive_t *drive = (ide_drive_t *) m->private; |
414 | char *out = page; | ||
415 | int len; | ||
416 | 472 | ||
417 | out += sprintf(out, "physical %d/%d/%d\n", | 473 | seq_printf(m, "physical %d/%d/%d\n", |
418 | drive->cyl, drive->head, drive->sect); | 474 | drive->cyl, drive->head, drive->sect); |
419 | out += sprintf(out, "logical %d/%d/%d\n", | 475 | seq_printf(m, "logical %d/%d/%d\n", |
420 | drive->bios_cyl, drive->bios_head, drive->bios_sect); | 476 | drive->bios_cyl, drive->bios_head, drive->bios_sect); |
477 | return 0; | ||
478 | } | ||
421 | 479 | ||
422 | len = out - page; | 480 | static int ide_geometry_proc_open(struct inode *inode, struct file *file) |
423 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 481 | { |
482 | return single_open(file, ide_geometry_proc_show, PDE(inode)->data); | ||
424 | } | 483 | } |
425 | 484 | ||
426 | EXPORT_SYMBOL(proc_ide_read_geometry); | 485 | const struct file_operations ide_geometry_proc_fops = { |
486 | .owner = THIS_MODULE, | ||
487 | .open = ide_geometry_proc_open, | ||
488 | .read = seq_read, | ||
489 | .llseek = seq_lseek, | ||
490 | .release = single_release, | ||
491 | }; | ||
492 | EXPORT_SYMBOL(ide_geometry_proc_fops); | ||
427 | 493 | ||
428 | static int proc_ide_read_dmodel | 494 | static int ide_dmodel_proc_show(struct seq_file *seq, void *v) |
429 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
430 | { | 495 | { |
431 | ide_drive_t *drive = (ide_drive_t *) data; | 496 | ide_drive_t *drive = (ide_drive_t *) seq->private; |
432 | char *m = (char *)&drive->id[ATA_ID_PROD]; | 497 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
433 | int len; | ||
434 | 498 | ||
435 | len = sprintf(page, "%.40s\n", m[0] ? m : "(none)"); | 499 | seq_printf(seq, "%.40s\n", m[0] ? m : "(none)"); |
436 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 500 | return 0; |
501 | } | ||
502 | |||
503 | static int ide_dmodel_proc_open(struct inode *inode, struct file *file) | ||
504 | { | ||
505 | return single_open(file, ide_dmodel_proc_show, PDE(inode)->data); | ||
437 | } | 506 | } |
438 | 507 | ||
439 | static int proc_ide_read_driver | 508 | static const struct file_operations ide_dmodel_proc_fops = { |
440 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 509 | .owner = THIS_MODULE, |
510 | .open = ide_dmodel_proc_open, | ||
511 | .read = seq_read, | ||
512 | .llseek = seq_lseek, | ||
513 | .release = single_release, | ||
514 | }; | ||
515 | |||
516 | static int ide_driver_proc_show(struct seq_file *m, void *v) | ||
441 | { | 517 | { |
442 | ide_drive_t *drive = (ide_drive_t *)data; | 518 | ide_drive_t *drive = (ide_drive_t *)m->private; |
443 | struct device *dev = &drive->gendev; | 519 | struct device *dev = &drive->gendev; |
444 | struct ide_driver *ide_drv; | 520 | struct ide_driver *ide_drv; |
445 | int len; | ||
446 | 521 | ||
447 | if (dev->driver) { | 522 | if (dev->driver) { |
448 | ide_drv = to_ide_driver(dev->driver); | 523 | ide_drv = to_ide_driver(dev->driver); |
449 | len = sprintf(page, "%s version %s\n", | 524 | seq_printf(m, "%s version %s\n", |
450 | dev->driver->name, ide_drv->version); | 525 | dev->driver->name, ide_drv->version); |
451 | } else | 526 | } else |
452 | len = sprintf(page, "ide-default version 0.9.newide\n"); | 527 | seq_printf(m, "ide-default version 0.9.newide\n"); |
453 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 528 | return 0; |
529 | } | ||
530 | |||
531 | static int ide_driver_proc_open(struct inode *inode, struct file *file) | ||
532 | { | ||
533 | return single_open(file, ide_driver_proc_show, PDE(inode)->data); | ||
454 | } | 534 | } |
455 | 535 | ||
456 | static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | 536 | static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) |
@@ -480,10 +560,10 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | |||
480 | return ret; | 560 | return ret; |
481 | } | 561 | } |
482 | 562 | ||
483 | static int proc_ide_write_driver | 563 | static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer, |
484 | (struct file *file, const char __user *buffer, unsigned long count, void *data) | 564 | size_t count, loff_t *pos) |
485 | { | 565 | { |
486 | ide_drive_t *drive = (ide_drive_t *) data; | 566 | ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; |
487 | char name[32]; | 567 | char name[32]; |
488 | 568 | ||
489 | if (!capable(CAP_SYS_ADMIN)) | 569 | if (!capable(CAP_SYS_ADMIN)) |
@@ -498,12 +578,19 @@ static int proc_ide_write_driver | |||
498 | return count; | 578 | return count; |
499 | } | 579 | } |
500 | 580 | ||
501 | static int proc_ide_read_media | 581 | static const struct file_operations ide_driver_proc_fops = { |
502 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 582 | .owner = THIS_MODULE, |
583 | .open = ide_driver_proc_open, | ||
584 | .read = seq_read, | ||
585 | .llseek = seq_lseek, | ||
586 | .release = single_release, | ||
587 | .write = ide_driver_proc_write, | ||
588 | }; | ||
589 | |||
590 | static int ide_media_proc_show(struct seq_file *m, void *v) | ||
503 | { | 591 | { |
504 | ide_drive_t *drive = (ide_drive_t *) data; | 592 | ide_drive_t *drive = (ide_drive_t *) m->private; |
505 | const char *media; | 593 | const char *media; |
506 | int len; | ||
507 | 594 | ||
508 | switch (drive->media) { | 595 | switch (drive->media) { |
509 | case ide_disk: media = "disk\n"; break; | 596 | case ide_disk: media = "disk\n"; break; |
@@ -513,20 +600,30 @@ static int proc_ide_read_media | |||
513 | case ide_optical: media = "optical\n"; break; | 600 | case ide_optical: media = "optical\n"; break; |
514 | default: media = "UNKNOWN\n"; break; | 601 | default: media = "UNKNOWN\n"; break; |
515 | } | 602 | } |
516 | strcpy(page, media); | 603 | seq_puts(m, media); |
517 | len = strlen(media); | 604 | return 0; |
518 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 605 | } |
606 | |||
607 | static int ide_media_proc_open(struct inode *inode, struct file *file) | ||
608 | { | ||
609 | return single_open(file, ide_media_proc_show, PDE(inode)->data); | ||
519 | } | 610 | } |
520 | 611 | ||
612 | static const struct file_operations ide_media_proc_fops = { | ||
613 | .owner = THIS_MODULE, | ||
614 | .open = ide_media_proc_open, | ||
615 | .read = seq_read, | ||
616 | .llseek = seq_lseek, | ||
617 | .release = single_release, | ||
618 | }; | ||
619 | |||
521 | static ide_proc_entry_t generic_drive_entries[] = { | 620 | static ide_proc_entry_t generic_drive_entries[] = { |
522 | { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, | 621 | { "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops }, |
523 | proc_ide_write_driver }, | 622 | { "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops}, |
524 | { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, | 623 | { "media", S_IFREG|S_IRUGO, &ide_media_proc_fops }, |
525 | { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, | 624 | { "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops }, |
526 | { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, | 625 | { "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops}, |
527 | { "settings", S_IFREG|S_IRUSR|S_IWUSR, proc_ide_read_settings, | 626 | {} |
528 | proc_ide_write_settings }, | ||
529 | { NULL, 0, NULL, NULL } | ||
530 | }; | 627 | }; |
531 | 628 | ||
532 | static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data) | 629 | static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data) |
@@ -536,11 +633,8 @@ static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p | |||
536 | if (!dir || !p) | 633 | if (!dir || !p) |
537 | return; | 634 | return; |
538 | while (p->name != NULL) { | 635 | while (p->name != NULL) { |
539 | ent = create_proc_entry(p->name, p->mode, dir); | 636 | ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data); |
540 | if (!ent) return; | 637 | if (!ent) return; |
541 | ent->data = data; | ||
542 | ent->read_proc = p->read_proc; | ||
543 | ent->write_proc = p->write_proc; | ||
544 | p++; | 638 | p++; |
545 | } | 639 | } |
546 | } | 640 | } |
@@ -623,10 +717,10 @@ void ide_proc_unregister_device(ide_drive_t *drive) | |||
623 | } | 717 | } |
624 | 718 | ||
625 | static ide_proc_entry_t hwif_entries[] = { | 719 | static ide_proc_entry_t hwif_entries[] = { |
626 | { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL }, | 720 | { "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops }, |
627 | { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL }, | 721 | { "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops }, |
628 | { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL }, | 722 | { "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops }, |
629 | { NULL, 0, NULL, NULL } | 723 | {} |
630 | }; | 724 | }; |
631 | 725 | ||
632 | void ide_proc_register_port(ide_hwif_t *hwif) | 726 | void ide_proc_register_port(ide_hwif_t *hwif) |