aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-09-01 20:52:57 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-01 20:52:57 -0400
commit6d703a81ad5fdd102334751ddacb053ecc6ff046 (patch)
tree1bebde3a0c34677296dc4784e800445ea02b4f0a
parent76fbebfbb593bd66780db0a808afe1d21c7ff6d6 (diff)
ide: convert to ->proc_fops
->read_proc, ->write_proc are going away, ->proc_fops should be used instead. The only tricky place is IDENTIFY handling: if for some reason taskfile_lib_get_identify() fails, buffer _is_ changed and at least first byte is overwritten. Emulate old behaviour with returning that first byte to userspace and reporting length=1 despite overall -E. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/ide/ide-cd.c28
-rw-r--r--drivers/ide/ide-disk_proc.c129
-rw-r--r--drivers/ide/ide-floppy_proc.c30
-rw-r--r--drivers/ide/ide-proc.c330
-rw-r--r--drivers/ide/ide-tape.c31
-rw-r--r--include/linux/ide.h24
6 files changed, 365 insertions, 207 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index ad0ab0c0a493..b79ca419d8d9 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/seq_file.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34#include <linux/interrupt.h> 35#include <linux/interrupt.h>
35#include <linux/errno.h> 36#include <linux/errno.h>
@@ -1389,19 +1390,30 @@ static sector_t ide_cdrom_capacity(ide_drive_t *drive)
1389 return capacity * sectors_per_frame; 1390 return capacity * sectors_per_frame;
1390} 1391}
1391 1392
1392static int proc_idecd_read_capacity(char *page, char **start, off_t off, 1393static int idecd_capacity_proc_show(struct seq_file *m, void *v)
1393 int count, int *eof, void *data)
1394{ 1394{
1395 ide_drive_t *drive = data; 1395 ide_drive_t *drive = m->private;
1396 int len;
1397 1396
1398 len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1397 seq_printf(m, "%llu\n", (long long)ide_cdrom_capacity(drive));
1399 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1398 return 0;
1399}
1400
1401static int idecd_capacity_proc_open(struct inode *inode, struct file *file)
1402{
1403 return single_open(file, idecd_capacity_proc_show, PDE(inode)->data);
1400} 1404}
1401 1405
1406static const struct file_operations idecd_capacity_proc_fops = {
1407 .owner = THIS_MODULE,
1408 .open = idecd_capacity_proc_open,
1409 .read = seq_read,
1410 .llseek = seq_lseek,
1411 .release = single_release,
1412};
1413
1402static ide_proc_entry_t idecd_proc[] = { 1414static ide_proc_entry_t idecd_proc[] = {
1403 { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 1415 { "capacity", S_IFREG|S_IRUGO, &idecd_capacity_proc_fops },
1404 { NULL, 0, NULL, NULL } 1416 {}
1405}; 1417};
1406 1418
1407static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive) 1419static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 19f263bf0a9e..60b0590ccc9c 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -1,5 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/seq_file.h>
3 4
4#include "ide-disk.h" 5#include "ide-disk.h"
5 6
@@ -37,77 +38,117 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
37 return ide_raw_taskfile(drive, &cmd, buf, 1); 38 return ide_raw_taskfile(drive, &cmd, buf, 1);
38} 39}
39 40
40static int proc_idedisk_read_cache 41static int idedisk_cache_proc_show(struct seq_file *m, void *v)
41 (char *page, char **start, off_t off, int count, int *eof, void *data)
42{ 42{
43 ide_drive_t *drive = (ide_drive_t *) data; 43 ide_drive_t *drive = (ide_drive_t *) m->private;
44 char *out = page;
45 int len;
46 44
47 if (drive->dev_flags & IDE_DFLAG_ID_READ) 45 if (drive->dev_flags & IDE_DFLAG_ID_READ)
48 len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 46 seq_printf(m, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2);
49 else 47 else
50 len = sprintf(out, "(none)\n"); 48 seq_printf(m, "(none)\n");
49 return 0;
50}
51 51
52 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 52static int idedisk_cache_proc_open(struct inode *inode, struct file *file)
53{
54 return single_open(file, idedisk_cache_proc_show, PDE(inode)->data);
53} 55}
54 56
55static int proc_idedisk_read_capacity 57static const struct file_operations idedisk_cache_proc_fops = {
56 (char *page, char **start, off_t off, int count, int *eof, void *data) 58 .owner = THIS_MODULE,
59 .open = idedisk_cache_proc_open,
60 .read = seq_read,
61 .llseek = seq_lseek,
62 .release = single_release,
63};
64
65static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
57{ 66{
58 ide_drive_t*drive = (ide_drive_t *)data; 67 ide_drive_t*drive = (ide_drive_t *)m->private;
59 int len;
60 68
61 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); 69 seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive));
70 return 0;
71}
62 72
63 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 73static int idedisk_capacity_proc_open(struct inode *inode, struct file *file)
74{
75 return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data);
64} 76}
65 77
66static int proc_idedisk_read_smart(char *page, char **start, off_t off, 78static const struct file_operations idedisk_capacity_proc_fops = {
67 int count, int *eof, void *data, u8 sub_cmd) 79 .owner = THIS_MODULE,
80 .open = idedisk_capacity_proc_open,
81 .read = seq_read,
82 .llseek = seq_lseek,
83 .release = single_release,
84};
85
86static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd)
68{ 87{
69 ide_drive_t *drive = (ide_drive_t *)data; 88 u8 *buf;
70 int len = 0, i = 0; 89
90 buf = kmalloc(SECTOR_SIZE, GFP_KERNEL);
91 if (!buf)
92 return -ENOMEM;
71 93
72 (void)smart_enable(drive); 94 (void)smart_enable(drive);
73 95
74 if (get_smart_data(drive, page, sub_cmd) == 0) { 96 if (get_smart_data(drive, buf, sub_cmd) == 0) {
75 unsigned short *val = (unsigned short *) page; 97 __le16 *val = (__le16 *)buf;
76 char *out = (char *)val + SECTOR_SIZE; 98 int i;
77 99
78 page = out; 100 for (i = 0; i < SECTOR_SIZE / 2; i++) {
79 do { 101 seq_printf(m, "%04x%c", le16_to_cpu(val[i]),
80 out += sprintf(out, "%04x%c", le16_to_cpu(*val), 102 (i % 8) == 7 ? '\n' : ' ');
81 (++i & 7) ? ' ' : '\n'); 103 }
82 val += 1;
83 } while (i < SECTOR_SIZE / 2);
84 len = out - page;
85 } 104 }
105 kfree(buf);
106 return 0;
107}
86 108
87 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 109static int idedisk_sv_proc_show(struct seq_file *m, void *v)
110{
111 return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES);
88} 112}
89 113
90static int proc_idedisk_read_sv 114static int idedisk_sv_proc_open(struct inode *inode, struct file *file)
91 (char *page, char **start, off_t off, int count, int *eof, void *data)
92{ 115{
93 return proc_idedisk_read_smart(page, start, off, count, eof, data, 116 return single_open(file, idedisk_sv_proc_show, PDE(inode)->data);
94 ATA_SMART_READ_VALUES);
95} 117}
96 118
97static int proc_idedisk_read_st 119static const struct file_operations idedisk_sv_proc_fops = {
98 (char *page, char **start, off_t off, int count, int *eof, void *data) 120 .owner = THIS_MODULE,
121 .open = idedisk_sv_proc_open,
122