diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-09-01 20:52:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-01 20:52:57 -0400 |
commit | 6d703a81ad5fdd102334751ddacb053ecc6ff046 (patch) | |
tree | 1bebde3a0c34677296dc4784e800445ea02b4f0a /drivers/ide | |
parent | 76fbebfbb593bd66780db0a808afe1d21c7ff6d6 (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>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-cd.c | 28 | ||||
-rw-r--r-- | drivers/ide/ide-disk_proc.c | 129 | ||||
-rw-r--r-- | drivers/ide/ide-floppy_proc.c | 30 | ||||
-rw-r--r-- | drivers/ide/ide-proc.c | 330 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 31 |
5 files changed, 362 insertions, 186 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 | ||
1392 | static int proc_idecd_read_capacity(char *page, char **start, off_t off, | 1393 | static 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 | |||
1401 | static 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 | ||
1406 | static 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 | |||
1402 | static ide_proc_entry_t idecd_proc[] = { | 1414 | static 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 | ||
1407 | static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive) | 1419 | static 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 | ||
40 | static int proc_idedisk_read_cache | 41 | static 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); | 52 | static 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 | ||
55 | static int proc_idedisk_read_capacity | 57 | static 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 | |||
65 | static 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); | 73 | static 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 | ||
66 | static int proc_idedisk_read_smart(char *page, char **start, off_t off, | 78 | static 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 | |||
86 | static 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); | 109 | static 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 | ||
90 | static int proc_idedisk_read_sv | 114 | static 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 | ||
97 | static int proc_idedisk_read_st | 119 | static 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 | .read = seq_read, | ||
123 | .llseek = seq_lseek, | ||
124 | .release = single_release, | ||
125 | }; | ||
126 | |||
127 | static int idedisk_st_proc_show(struct seq_file *m, void *v) | ||
99 | { | 128 | { |
100 | return proc_idedisk_read_smart(page, start, off, count, eof, data, | 129 | return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS); |
101 | ATA_SMART_READ_THRESHOLDS); | ||
102 | } | 130 | } |
103 | 131 | ||
132 | static int idedisk_st_proc_open(struct inode *inode, struct file *file) | ||
133 | { | ||
134 | return single_open(file, idedisk_st_proc_show, PDE(inode)->data); | ||
135 | } | ||
136 | |||
137 | static const struct file_operations idedisk_st_proc_fops = { | ||
138 | .owner = THIS_MODULE, | ||
139 | .open = idedisk_st_proc_open, | ||
140 | .read = seq_read, | ||
141 | .llseek = seq_lseek, | ||
142 | .release = single_release, | ||
143 | }; | ||
144 | |||
104 | ide_proc_entry_t ide_disk_proc[] = { | 145 | ide_proc_entry_t ide_disk_proc[] = { |
105 | { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, | 146 | { "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops }, |
106 | { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, | 147 | { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops }, |
107 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, | 148 | { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, |
108 | { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, | 149 | { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops }, |
109 | { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, | 150 | { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops }, |
110 | { NULL, 0, NULL, NULL } | 151 | {} |
111 | }; | 152 | }; |
112 | 153 | ||
113 | ide_devset_rw_field(bios_cyl, bios_cyl); | 154 | ide_devset_rw_field(bios_cyl, bios_cyl); |
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c index fcd4d8153df5..d711d9b883de 100644 --- a/drivers/ide/ide-floppy_proc.c +++ b/drivers/ide/ide-floppy_proc.c | |||
@@ -1,22 +1,34 @@ | |||
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-floppy.h" | 5 | #include "ide-floppy.h" |
5 | 6 | ||
6 | static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, | 7 | static int idefloppy_capacity_proc_show(struct seq_file *m, void *v) |
7 | int count, int *eof, void *data) | ||
8 | { | 8 | { |
9 | ide_drive_t*drive = (ide_drive_t *)data; | 9 | ide_drive_t*drive = (ide_drive_t *)m->private; |
10 | int len; | ||
11 | 10 | ||
12 | len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); | 11 | seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive)); |
13 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 12 | return 0; |
14 | } | 13 | } |
15 | 14 | ||
15 | static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file) | ||
16 | { | ||
17 | return single_open(file, idefloppy_capacity_proc_show, PDE(inode)->data); | ||
18 | } | ||
19 | |||
20 | static const struct file_operations idefloppy_capacity_proc_fops = { | ||
21 | .owner = THIS_MODULE, | ||
22 | .open = idefloppy_capacity_proc_open, | ||
23 | .read = seq_read, | ||
24 | .llseek = seq_lseek, | ||
25 | .release = single_release, | ||
26 | }; | ||
27 | |||
16 | ide_proc_entry_t ide_floppy_proc[] = { | 28 | ide_proc_entry_t ide_floppy_proc[] = { |
17 | { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, | 29 | { "capacity", S_IFREG|S_IRUGO, &idefloppy_capacity_proc_fops }, |
18 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, | 30 | { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, |
19 | { NULL, 0, NULL, NULL } | 31 | {} |
20 | }; | 32 | }; |
21 | 33 | ||
22 | ide_devset_rw_field(bios_cyl, bios_cyl); | 34 | ide_devset_rw_field(bios_cyl, bios_cyl); |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 021de41655e6..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; | ||
91 | 107 | ||
92 | len = sprintf(page, "\n"); | 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 | }; | ||
93 | 115 | ||
94 | if (drive) { | 116 | static int ide_identify_proc_show(struct seq_file *m, void *v) |
95 | __le16 *val = (__le16 *)page; | 117 | { |
118 | ide_drive_t *drive = (ide_drive_t *)m->private; | ||
119 | u8 *buf; | ||
96 | 120 | ||
97 | err = taskfile_lib_get_identify(drive, page); | 121 | if (!drive) { |
98 | if (!err) { | 122 | seq_putc(m, '\n'); |
99 | char *out = (char *)page + SECTOR_SIZE; | 123 | return 0; |
124 | } | ||
100 | 125 | ||
101 | page = out; | 126 | buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); |
102 | do { | 127 | if (!buf) |
103 | out += sprintf(out, "%04x%c", | 128 | return -ENOMEM; |
104 | le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); | 129 | if (taskfile_lib_get_identify(drive, buf) == 0) { |
105 | val += 1; | 130 | __le16 *val = (__le16 *)buf; |
106 | } while (i < SECTOR_SIZE / 2); | 131 | int i; |
107 | len = out - page; | 132 | |
133 | for (i = 0; i < SECTOR_SIZE / 2; i++) { | ||
134 | seq_printf(m, "%04x%c", le16_to_cpu(val[i]), | ||
135 | (i % 8) == 7 ? '\n' : ' '); | ||
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 |
@@ -240,22 +283,20 @@ static void proc_ide_settings_warn(void) | |||
240 | warned = 1; | 283 | warned = 1; |
241 | } | 284 | } |
242 | 285 | ||
243 | static int proc_ide_read_settings | 286 | static int ide_settings_proc_show(struct seq_file *m, void *v) |
244 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
245 | { | 287 | { |
246 | const struct ide_proc_devset *setting, *g, *d; | 288 | const struct ide_proc_devset *setting, *g, *d; |
247 | const struct ide_devset *ds; | 289 | const struct ide_devset *ds; |
248 | ide_drive_t *drive = (ide_drive_t *) data; | 290 | ide_drive_t *drive = (ide_drive_t *) m->private; |
249 | char *out = page; | 291 | int rc, mul_factor, div_factor; |
250 | int len, rc, mul_factor, div_factor; | ||
251 | 292 | ||
252 | proc_ide_settings_warn(); | 293 | proc_ide_settings_warn(); |
253 | 294 | ||
254 | mutex_lock(&ide_setting_mtx); | 295 | mutex_lock(&ide_setting_mtx); |
255 | g = ide_generic_settings; | 296 | g = ide_generic_settings; |
256 | d = drive->settings; | 297 | d = drive->settings; |
257 | 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"); |
258 | 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"); |
259 | while (g->name || (d && d->name)) { | 300 | while (g->name || (d && d->name)) { |
260 | /* read settings in the alphabetical order */ | 301 | /* read settings in the alphabetical order */ |
261 | if (g->name && d && d->name) { | 302 | if (g->name && d && d->name) { |
@@ -269,31 +310,35 @@ static int proc_ide_read_settings | |||
269 | setting = g++; | 310 | setting = g++; |
270 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; | 311 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; |
271 | div_factor = setting->divf ? setting->divf(drive) : 1; | 312 | div_factor = setting->divf ? setting->divf(drive) : 1; |
272 | out += sprintf(out, "%-24s", setting->name); | 313 | seq_printf(m, "%-24s", setting->name); |
273 | rc = ide_read_setting(drive, setting); | 314 | rc = ide_read_setting(drive, setting); |
274 | if (rc >= 0) | 315 | if (rc >= 0) |
275 | out += sprintf(out, "%-16d", rc * mul_factor / div_factor); | 316 | seq_printf(m, "%-16d", rc * mul_factor / div_factor); |
276 | else | 317 | else |
277 | out += sprintf(out, "%-16s", "write-only"); | 318 | seq_printf(m, "%-16s", "write-only"); |
278 | 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); |
279 | ds = setting->setting; | 320 | ds = setting->setting; |
280 | if (ds->get) | 321 | if (ds->get) |
281 | out += sprintf(out, "r"); | 322 | seq_printf(m, "r"); |
282 | if (ds->set) | 323 | if (ds->set) |
283 | out += sprintf(out, "w"); | 324 | seq_printf(m, "w"); |
284 | out += sprintf(out, "\n"); | 325 | seq_printf(m, "\n"); |
285 | } | 326 | } |
286 | len = out - page; | ||
287 | mutex_unlock(&ide_setting_mtx); | 327 | mutex_unlock(&ide_setting_mtx); |
288 | 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); | ||
289 | } | 334 | } |
290 | 335 | ||
291 | #define MAX_LEN 30 | 336 | #define MAX_LEN 30 |
292 | 337 | ||
293 | 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, |
294 | unsigned long count, void *data) | 339 | size_t count, loff_t *pos) |
295 | { | 340 | { |
296 | ide_drive_t *drive = (ide_drive_t *) data; | 341 | ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; |
297 | char name[MAX_LEN + 1]; | 342 | char name[MAX_LEN + 1]; |
298 | int for_real = 0, mul_factor, div_factor; | 343 | int for_real = 0, mul_factor, div_factor; |
299 | unsigned long n; | 344 | unsigned long n; |
@@ -388,63 +433,104 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
388 | return count; | 433 | return count; |
389 | parse_error: | 434 | parse_error: |
390 | free_page((unsigned long)buf); | 435 | free_page((unsigned long)buf); |
391 | printk("proc_ide_write_settings(): parse error\n"); | 436 | printk("%s(): parse error\n", __func__); |
392 | return -EINVAL; | 437 | return -EINVAL; |
393 | } | 438 | } |
394 | 439 | ||
395 | int proc_ide_read_capacity | 440 | static const struct file_operations ide_settings_proc_fops = { |
396 | (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) | ||
397 | { | 450 | { |
398 | int len = sprintf(page, "%llu\n", (long long)0x7fffffff); | 451 | seq_printf(m, "%llu\n", (long long)0x7fffffff); |
399 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 452 | return 0; |
400 | } | 453 | } |
401 | 454 | ||
402 | EXPORT_SYMBOL_GPL(proc_ide_read_capacity); | 455 | static int ide_capacity_proc_open(struct inode *inode, struct file *file) |
456 | { | ||
457 | return single_open(file, ide_capacity_proc_show, NULL); | ||
458 | } | ||
403 | 459 | ||
404 | int proc_ide_read_geometry | 460 | const struct file_operations ide_capacity_proc_fops = { |
405 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 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); | ||
468 | |||
469 | static int ide_geometry_proc_show(struct seq_file *m, void *v) | ||
406 | { | 470 | { |
407 | ide_drive_t *drive = (ide_drive_t *) data; | 471 | ide_drive_t *drive = (ide_drive_t *) m->private; |
408 | char *out = page; | ||
409 | int len; | ||
410 | 472 | ||
411 | out += sprintf(out, "physical %d/%d/%d\n", | 473 | seq_printf(m, "physical %d/%d/%d\n", |
412 | drive->cyl, drive->head, drive->sect); | 474 | drive->cyl, drive->head, drive->sect); |
413 | out += sprintf(out, "logical %d/%d/%d\n", | 475 | seq_printf(m, "logical %d/%d/%d\n", |
414 | drive->bios_cyl, drive->bios_head, drive->bios_sect); | 476 | drive->bios_cyl, drive->bios_head, drive->bios_sect); |
477 | return 0; | ||
478 | } | ||
415 | 479 | ||
416 | len = out - page; | 480 | static int ide_geometry_proc_open(struct inode *inode, struct file *file) |
417 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 481 | { |
482 | return single_open(file, ide_geometry_proc_show, PDE(inode)->data); | ||
418 | } | 483 | } |
419 | 484 | ||
420 | 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); | ||
421 | 493 | ||
422 | static int proc_ide_read_dmodel | 494 | static int ide_dmodel_proc_show(struct seq_file *seq, void *v) |
423 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
424 | { | 495 | { |
425 | ide_drive_t *drive = (ide_drive_t *) data; | 496 | ide_drive_t *drive = (ide_drive_t *) seq->private; |
426 | char *m = (char *)&drive->id[ATA_ID_PROD]; | 497 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
427 | int len; | ||
428 | 498 | ||
429 | len = sprintf(page, "%.40s\n", m[0] ? m : "(none)"); | 499 | seq_printf(seq, "%.40s\n", m[0] ? m : "(none)"); |
430 | 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); | ||
431 | } | 506 | } |
432 | 507 | ||
433 | static int proc_ide_read_driver | 508 | static const struct file_operations ide_dmodel_proc_fops = { |
434 | (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) | ||
435 | { | 517 | { |
436 | ide_drive_t *drive = (ide_drive_t *)data; | 518 | ide_drive_t *drive = (ide_drive_t *)m->private; |
437 | struct device *dev = &drive->gendev; | 519 | struct device *dev = &drive->gendev; |
438 | struct ide_driver *ide_drv; | 520 | struct ide_driver *ide_drv; |
439 | int len; | ||
440 | 521 | ||
441 | if (dev->driver) { | 522 | if (dev->driver) { |
442 | ide_drv = to_ide_driver(dev->driver); | 523 | ide_drv = to_ide_driver(dev->driver); |
443 | len = sprintf(page, "%s version %s\n", | 524 | seq_printf(m, "%s version %s\n", |
444 | dev->driver->name, ide_drv->version); | 525 | dev->driver->name, ide_drv->version); |
445 | } else | 526 | } else |
446 | len = sprintf(page, "ide-default version 0.9.newide\n"); | 527 | seq_printf(m, "ide-default version 0.9.newide\n"); |
447 | 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); | ||
448 | } | 534 | } |
449 | 535 | ||
450 | 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) |
@@ -474,10 +560,10 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | |||
474 | return ret; | 560 | return ret; |
475 | } | 561 | } |
476 | 562 | ||
477 | static int proc_ide_write_driver | 563 | static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer, |
478 | (struct file *file, const char __user *buffer, unsigned long count, void *data) | 564 | size_t count, loff_t *pos) |
479 | { | 565 | { |
480 | ide_drive_t *drive = (ide_drive_t *) data; | 566 | ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; |
481 | char name[32]; | 567 | char name[32]; |
482 | 568 | ||
483 | if (!capable(CAP_SYS_ADMIN)) | 569 | if (!capable(CAP_SYS_ADMIN)) |
@@ -492,12 +578,19 @@ static int proc_ide_write_driver | |||
492 | return count; | 578 | return count; |
493 | } | 579 | } |
494 | 580 | ||
495 | static int proc_ide_read_media | 581 | static const struct file_operations ide_driver_proc_fops = { |
496 | (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) | ||
497 | { | 591 | { |
498 | ide_drive_t *drive = (ide_drive_t *) data; | 592 | ide_drive_t *drive = (ide_drive_t *) m->private; |
499 | const char *media; | 593 | const char *media; |
500 | int len; | ||
501 | 594 | ||
502 | switch (drive->media) { | 595 | switch (drive->media) { |
503 | case ide_disk: media = "disk\n"; break; | 596 | case ide_disk: media = "disk\n"; break; |
@@ -507,20 +600,30 @@ static int proc_ide_read_media | |||
507 | case ide_optical: media = "optical\n"; break; | 600 | case ide_optical: media = "optical\n"; break; |
508 | default: media = "UNKNOWN\n"; break; | 601 | default: media = "UNKNOWN\n"; break; |
509 | } | 602 | } |
510 | strcpy(page, media); | 603 | seq_puts(m, media); |
511 | len = strlen(media); | 604 | return 0; |
512 | 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); | ||
513 | } | 610 | } |
514 | 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 | |||
515 | static ide_proc_entry_t generic_drive_entries[] = { | 620 | static ide_proc_entry_t generic_drive_entries[] = { |
516 | { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, | 621 | { "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops }, |
517 | proc_ide_write_driver }, | 622 | { "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops}, |
518 | { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, | 623 | { "media", S_IFREG|S_IRUGO, &ide_media_proc_fops }, |
519 | { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, | 624 | { "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops }, |
520 | { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, | 625 | { "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops}, |
521 | { "settings", S_IFREG|S_IRUSR|S_IWUSR, proc_ide_read_settings, | 626 | {} |
522 | proc_ide_write_settings }, | ||
523 | { NULL, 0, NULL, NULL } | ||
524 | }; | 627 | }; |
525 | 628 | ||
526 | 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) |
@@ -530,11 +633,8 @@ static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p | |||
530 | if (!dir || !p) | 633 | if (!dir || !p) |
531 | return; | 634 | return; |
532 | while (p->name != NULL) { | 635 | while (p->name != NULL) { |
533 | ent = create_proc_entry(p->name, p->mode, dir); | 636 | ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data); |
534 | if (!ent) return; | 637 | if (!ent) return; |
535 | ent->data = data; | ||
536 | ent->read_proc = p->read_proc; | ||
537 | ent->write_proc = p->write_proc; | ||
538 | p++; | 638 | p++; |
539 | } | 639 | } |
540 | } | 640 | } |
@@ -617,10 +717,10 @@ void ide_proc_unregister_device(ide_drive_t *drive) | |||
617 | } | 717 | } |
618 | 718 | ||
619 | static ide_proc_entry_t hwif_entries[] = { | 719 | static ide_proc_entry_t hwif_entries[] = { |
620 | { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL }, | 720 | { "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops }, |
621 | { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL }, | 721 | { "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops }, |
622 | { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL }, | 722 | { "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops }, |
623 | { NULL, 0, NULL, NULL } | 723 | {} |
624 | }; | 724 | }; |
625 | 725 | ||
626 | void ide_proc_register_port(ide_hwif_t *hwif) | 726 | void ide_proc_register_port(ide_hwif_t *hwif) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 7b2032bc357b..9d6f62baac27 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/major.h> | 31 | #include <linux/major.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | #include <linux/genhd.h> | 33 | #include <linux/genhd.h> |
34 | #include <linux/seq_file.h> | ||
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
36 | #include <linux/ide.h> | 37 | #include <linux/ide.h> |
@@ -1816,22 +1817,32 @@ static void ide_tape_release(struct device *dev) | |||
1816 | } | 1817 | } |
1817 | 1818 | ||
1818 | #ifdef CONFIG_IDE_PROC_FS | 1819 | #ifdef CONFIG_IDE_PROC_FS |
1819 | static int proc_idetape_read_name | 1820 | static int idetape_name_proc_show(struct seq_file *m, void *v) |
1820 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
1821 | { | 1821 | { |
1822 | ide_drive_t *drive = (ide_drive_t *) data; | 1822 | ide_drive_t *drive = (ide_drive_t *) m->private; |
1823 | idetape_tape_t *tape = drive->driver_data; | 1823 | idetape_tape_t *tape = drive->driver_data; |
1824 | char *out = page; | ||
1825 | int len; | ||
1826 | 1824 | ||
1827 | len = sprintf(out, "%s\n", tape->name); | 1825 | seq_printf(m, "%s\n", tape->name); |
1828 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 1826 | return 0; |
1827 | } | ||
1828 | |||
1829 | static int idetape_name_proc_open(struct inode *inode, struct file *file) | ||
1830 | { | ||
1831 | return single_open(file, idetape_name_proc_show, PDE(inode)->data); | ||
1829 | } | 1832 | } |
1830 | 1833 | ||
1834 | static const struct file_operations idetape_name_proc_fops = { | ||
1835 | .owner = THIS_MODULE, | ||
1836 | .open = idetape_name_proc_open, | ||
1837 | .read = seq_read, | ||
1838 | .llseek = seq_lseek, | ||
1839 | .release = single_release, | ||
1840 | }; | ||
1841 | |||
1831 | static ide_proc_entry_t idetape_proc[] = { | 1842 | static ide_proc_entry_t idetape_proc[] = { |
1832 | { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL }, | 1843 | { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops }, |
1833 | { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, | 1844 | { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops }, |
1834 | { NULL, 0, NULL, NULL } | 1845 | {} |
1835 | }; | 1846 | }; |
1836 | 1847 | ||
1837 | static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) | 1848 | static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) |