diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2010-01-14 06:10:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-14 06:10:54 -0500 |
commit | 9a58a80a701bdb2d220cdab4914218df5b48d781 (patch) | |
tree | 01eeb65ec70f22ec326d0938d002cc6a2aec73e8 /drivers/isdn/hardware/eicon | |
parent | 508e14b4a4fb1a824a14f2c5b8d7df67b313f8e4 (diff) |
proc_fops: convert drivers/isdn/ to seq_file
Convert code away from ->read_proc/->write_proc interfaces. Switch to
proc_create()/proc_create_data() which make addition of proc entries
reliable wrt NULL ->proc_fops, NULL ->data and so on.
Problem with ->read_proc et al is described here commit
786d7e1612f0b0adb6046f19b906609e4fe8b1ba "Fix rmmod/read/write races in
/proc entries"
[akpm@linux-foundation.org: CONFIG_PROC_FS=n build fix]
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Karsten Keil <keil@b1-systems.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/hardware/eicon')
-rw-r--r-- | drivers/isdn/hardware/eicon/capimain.c | 40 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/diva_didd.c | 45 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/divasi.c | 48 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/divasproc.c | 198 |
4 files changed, 160 insertions, 171 deletions
diff --git a/drivers/isdn/hardware/eicon/capimain.c b/drivers/isdn/hardware/eicon/capimain.c index 98fcdfc7ca55..0f073cd73763 100644 --- a/drivers/isdn/hardware/eicon/capimain.c +++ b/drivers/isdn/hardware/eicon/capimain.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
16 | #include <linux/seq_file.h> | ||
16 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
17 | 18 | ||
18 | #include "os_capi.h" | 19 | #include "os_capi.h" |
@@ -75,25 +76,32 @@ void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb) | |||
75 | /* | 76 | /* |
76 | * proc function for controller info | 77 | * proc function for controller info |
77 | */ | 78 | */ |
78 | static int diva_ctl_read_proc(char *page, char **start, off_t off, | 79 | static int diva_ctl_proc_show(struct seq_file *m, void *v) |
79 | int count, int *eof, struct capi_ctr *ctrl) | ||
80 | { | 80 | { |
81 | struct capi_ctr *ctrl = m->private; | ||
81 | diva_card *card = (diva_card *) ctrl->driverdata; | 82 | diva_card *card = (diva_card *) ctrl->driverdata; |
82 | int len = 0; | 83 | |
83 | 84 | seq_printf(m, "%s\n", ctrl->name); | |
84 | len += sprintf(page + len, "%s\n", ctrl->name); | 85 | seq_printf(m, "Serial No. : %s\n", ctrl->serial); |
85 | len += sprintf(page + len, "Serial No. : %s\n", ctrl->serial); | 86 | seq_printf(m, "Id : %d\n", card->Id); |
86 | len += sprintf(page + len, "Id : %d\n", card->Id); | 87 | seq_printf(m, "Channels : %d\n", card->d.channels); |
87 | len += sprintf(page + len, "Channels : %d\n", card->d.channels); | 88 | |
88 | 89 | return 0; | |
89 | if (off + count >= len) | 90 | } |
90 | *eof = 1; | 91 | |
91 | if (len < off) | 92 | static int diva_ctl_proc_open(struct inode *inode, struct file *file) |
92 | return 0; | 93 | { |
93 | *start = page + off; | 94 | return single_open(file, diva_ctl_proc_show, NULL); |
94 | return ((count < len - off) ? count : len - off); | ||
95 | } | 95 | } |
96 | 96 | ||
97 | static const struct file_operations diva_ctl_proc_fops = { | ||
98 | .owner = THIS_MODULE, | ||
99 | .open = diva_ctl_proc_open, | ||
100 | .read = seq_read, | ||
101 | .llseek = seq_lseek, | ||
102 | .release = single_release, | ||
103 | }; | ||
104 | |||
97 | /* | 105 | /* |
98 | * set additional os settings in capi_ctr struct | 106 | * set additional os settings in capi_ctr struct |
99 | */ | 107 | */ |
@@ -102,7 +110,7 @@ void diva_os_set_controller_struct(struct capi_ctr *ctrl) | |||
102 | ctrl->driver_name = DRIVERLNAME; | 110 | ctrl->driver_name = DRIVERLNAME; |
103 | ctrl->load_firmware = NULL; | 111 | ctrl->load_firmware = NULL; |
104 | ctrl->reset_ctr = NULL; | 112 | ctrl->reset_ctr = NULL; |
105 | ctrl->ctr_read_proc = diva_ctl_read_proc; | 113 | ctrl->proc_fops = &diva_ctl_proc_fops; |
106 | ctrl->owner = THIS_MODULE; | 114 | ctrl->owner = THIS_MODULE; |
107 | } | 115 | } |
108 | 116 | ||
diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c index 993b14cf1778..5d06a7437824 100644 --- a/drivers/isdn/hardware/eicon/diva_didd.c +++ b/drivers/isdn/hardware/eicon/diva_didd.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/proc_fs.h> | 17 | #include <linux/proc_fs.h> |
18 | #include <linux/seq_file.h> | ||
18 | #include <net/net_namespace.h> | 19 | #include <net/net_namespace.h> |
19 | 20 | ||
20 | #include "platform.h" | 21 | #include "platform.h" |
@@ -62,39 +63,41 @@ static char *getrev(const char *revision) | |||
62 | return rev; | 63 | return rev; |
63 | } | 64 | } |
64 | 65 | ||
65 | static int | 66 | static int divadidd_proc_show(struct seq_file *m, void *v) |
66 | proc_read(char *page, char **start, off_t off, int count, int *eof, | ||
67 | void *data) | ||
68 | { | 67 | { |
69 | int len = 0; | ||
70 | char tmprev[32]; | 68 | char tmprev[32]; |
71 | 69 | ||
72 | strcpy(tmprev, main_revision); | 70 | strcpy(tmprev, main_revision); |
73 | len += sprintf(page + len, "%s\n", DRIVERNAME); | 71 | seq_printf(m, "%s\n", DRIVERNAME); |
74 | len += sprintf(page + len, "name : %s\n", DRIVERLNAME); | 72 | seq_printf(m, "name : %s\n", DRIVERLNAME); |
75 | len += sprintf(page + len, "release : %s\n", DRIVERRELEASE_DIDD); | 73 | seq_printf(m, "release : %s\n", DRIVERRELEASE_DIDD); |
76 | len += sprintf(page + len, "build : %s(%s)\n", | 74 | seq_printf(m, "build : %s(%s)\n", |
77 | diva_didd_common_code_build, DIVA_BUILD); | 75 | diva_didd_common_code_build, DIVA_BUILD); |
78 | len += sprintf(page + len, "revision : %s\n", getrev(tmprev)); | 76 | seq_printf(m, "revision : %s\n", getrev(tmprev)); |
79 | 77 | ||
80 | if (off + count >= len) | 78 | return 0; |
81 | *eof = 1; | ||
82 | if (len < off) | ||
83 | return 0; | ||
84 | *start = page + off; | ||
85 | return ((count < len - off) ? count : len - off); | ||
86 | } | 79 | } |
87 | 80 | ||
81 | static int divadidd_proc_open(struct inode *inode, struct file *file) | ||
82 | { | ||
83 | return single_open(file, divadidd_proc_show, NULL); | ||
84 | } | ||
85 | |||
86 | static const struct file_operations divadidd_proc_fops = { | ||
87 | .owner = THIS_MODULE, | ||
88 | .open = divadidd_proc_open, | ||
89 | .read = seq_read, | ||
90 | .llseek = seq_lseek, | ||
91 | .release = single_release, | ||
92 | }; | ||
93 | |||
88 | static int DIVA_INIT_FUNCTION create_proc(void) | 94 | static int DIVA_INIT_FUNCTION create_proc(void) |
89 | { | 95 | { |
90 | proc_net_eicon = proc_mkdir("eicon", init_net.proc_net); | 96 | proc_net_eicon = proc_mkdir("eicon", init_net.proc_net); |
91 | 97 | ||
92 | if (proc_net_eicon) { | 98 | if (proc_net_eicon) { |
93 | if ((proc_didd = | 99 | proc_didd = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon, |
94 | create_proc_entry(DRIVERLNAME, S_IFREG | S_IRUGO, | 100 | &divadidd_proc_fops); |
95 | proc_net_eicon))) { | ||
96 | proc_didd->read_proc = proc_read; | ||
97 | } | ||
98 | return (1); | 101 | return (1); |
99 | } | 102 | } |
100 | return (0); | 103 | return (0); |
diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c index 69e71ebe7841..f577719ab3fa 100644 --- a/drivers/isdn/hardware/eicon/divasi.c +++ b/drivers/isdn/hardware/eicon/divasi.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
18 | #include <linux/proc_fs.h> | 18 | #include <linux/proc_fs.h> |
19 | #include <linux/skbuff.h> | 19 | #include <linux/skbuff.h> |
20 | #include <linux/seq_file.h> | ||
20 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | 23 | ||
@@ -86,39 +87,40 @@ static void diva_um_timer_function(unsigned long data); | |||
86 | extern struct proc_dir_entry *proc_net_eicon; | 87 | extern struct proc_dir_entry *proc_net_eicon; |
87 | static struct proc_dir_entry *um_idi_proc_entry = NULL; | 88 | static struct proc_dir_entry *um_idi_proc_entry = NULL; |
88 | 89 | ||
89 | static int | 90 | static int um_idi_proc_show(struct seq_file *m, void *v) |
90 | um_idi_proc_read(char *page, char **start, off_t off, int count, int *eof, | ||
91 | void *data) | ||
92 | { | 91 | { |
93 | int len = 0; | ||
94 | char tmprev[32]; | 92 | char tmprev[32]; |
95 | 93 | ||
96 | len += sprintf(page + len, "%s\n", DRIVERNAME); | 94 | seq_printf(m, "%s\n", DRIVERNAME); |
97 | len += sprintf(page + len, "name : %s\n", DRIVERLNAME); | 95 | seq_printf(m, "name : %s\n", DRIVERLNAME); |
98 | len += sprintf(page + len, "release : %s\n", DRIVERRELEASE_IDI); | 96 | seq_printf(m, "release : %s\n", DRIVERRELEASE_IDI); |
99 | strcpy(tmprev, main_revision); | 97 | strcpy(tmprev, main_revision); |
100 | len += sprintf(page + len, "revision : %s\n", getrev(tmprev)); | 98 | seq_printf(m, "revision : %s\n", getrev(tmprev)); |
101 | len += sprintf(page + len, "build : %s\n", DIVA_BUILD); | 99 | seq_printf(m, "build : %s\n", DIVA_BUILD); |
102 | len += sprintf(page + len, "major : %d\n", major); | 100 | seq_printf(m, "major : %d\n", major); |
103 | 101 | ||
104 | if (off + count >= len) | 102 | return 0; |
105 | *eof = 1; | 103 | } |
106 | if (len < off) | 104 | |
107 | return 0; | 105 | static int um_idi_proc_open(struct inode *inode, struct file *file) |
108 | *start = page + off; | 106 | { |
109 | return ((count < len - off) ? count : len - off); | 107 | return single_open(file, um_idi_proc_show, NULL); |
110 | } | 108 | } |
111 | 109 | ||
110 | static const struct file_operations um_idi_proc_fops = { | ||
111 | .owner = THIS_MODULE, | ||
112 | .open = um_idi_proc_open, | ||
113 | .read = seq_read, | ||
114 | .llseek = seq_lseek, | ||
115 | .release = single_release, | ||
116 | }; | ||
117 | |||
112 | static int DIVA_INIT_FUNCTION create_um_idi_proc(void) | 118 | static int DIVA_INIT_FUNCTION create_um_idi_proc(void) |
113 | { | 119 | { |
114 | um_idi_proc_entry = create_proc_entry(DRIVERLNAME, | 120 | um_idi_proc_entry = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon, |
115 | S_IFREG | S_IRUGO | S_IWUSR, | 121 | &um_idi_proc_fops); |
116 | proc_net_eicon); | ||
117 | if (!um_idi_proc_entry) | 122 | if (!um_idi_proc_entry) |
118 | return (0); | 123 | return (0); |
119 | |||
120 | um_idi_proc_entry->read_proc = um_idi_proc_read; | ||
121 | |||
122 | return (1); | 124 | return (1); |
123 | } | 125 | } |
124 | 126 | ||
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c index 040827288ec9..46d44a942624 100644 --- a/drivers/isdn/hardware/eicon/divasproc.c +++ b/drivers/isdn/hardware/eicon/divasproc.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/poll.h> | 15 | #include <linux/poll.h> |
16 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
17 | #include <linux/seq_file.h> | ||
17 | #include <linux/list.h> | 18 | #include <linux/list.h> |
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
19 | 20 | ||
@@ -141,14 +142,10 @@ void remove_divas_proc(void) | |||
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
144 | /* | 145 | static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, |
145 | ** write group_optimization | 146 | size_t count, loff_t *pos) |
146 | */ | ||
147 | static int | ||
148 | write_grp_opt(struct file *file, const char __user *buffer, unsigned long count, | ||
149 | void *data) | ||
150 | { | 147 | { |
151 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | 148 | diva_os_xdi_adapter_t *a = PDE(file->f_path.dentry->d_inode)->data; |
152 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 149 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
153 | 150 | ||
154 | if ((count == 1) || (count == 2)) { | 151 | if ((count == 1) || (count == 2)) { |
@@ -172,14 +169,10 @@ write_grp_opt(struct file *file, const char __user *buffer, unsigned long count, | |||
172 | return (-EINVAL); | 169 | return (-EINVAL); |
173 | } | 170 | } |
174 | 171 | ||
175 | /* | 172 | static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer, |
176 | ** write dynamic_l1_down | 173 | size_t count, loff_t *pos) |
177 | */ | ||
178 | static int | ||
179 | write_d_l1_down(struct file *file, const char __user *buffer, unsigned long count, | ||
180 | void *data) | ||
181 | { | 174 | { |
182 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | 175 | diva_os_xdi_adapter_t *a = PDE(file->f_path.dentry->d_inode)->data; |
183 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 176 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
184 | 177 | ||
185 | if ((count == 1) || (count == 2)) { | 178 | if ((count == 1) || (count == 2)) { |
@@ -203,63 +196,62 @@ write_d_l1_down(struct file *file, const char __user *buffer, unsigned long coun | |||
203 | return (-EINVAL); | 196 | return (-EINVAL); |
204 | } | 197 | } |
205 | 198 | ||
206 | 199 | static int d_l1_down_proc_show(struct seq_file *m, void *v) | |
207 | /* | ||
208 | ** read dynamic_l1_down | ||
209 | */ | ||
210 | static int | ||
211 | read_d_l1_down(char *page, char **start, off_t off, int count, int *eof, | ||
212 | void *data) | ||
213 | { | 200 | { |
214 | int len = 0; | 201 | diva_os_xdi_adapter_t *a = m->private; |
215 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | ||
216 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 202 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
217 | 203 | ||
218 | len += sprintf(page + len, "%s\n", | 204 | seq_printf(m, "%s\n", |
219 | (IoAdapter->capi_cfg. | 205 | (IoAdapter->capi_cfg. |
220 | cfg_1 & DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? "1" : | 206 | cfg_1 & DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? "1" : |
221 | "0"); | 207 | "0"); |
208 | return 0; | ||
209 | } | ||
222 | 210 | ||
223 | if (off + count >= len) | 211 | static int d_l1_down_proc_open(struct inode *inode, struct file *file) |
224 | *eof = 1; | 212 | { |
225 | if (len < off) | 213 | return single_open(file, d_l1_down_proc_show, PDE(inode)->data); |
226 | return 0; | ||
227 | *start = page + off; | ||
228 | return ((count < len - off) ? count : len - off); | ||
229 | } | 214 | } |
230 | 215 | ||
231 | /* | 216 | static const struct file_operations d_l1_down_proc_fops = { |
232 | ** read group_optimization | 217 | .owner = THIS_MODULE, |
233 | */ | 218 | .open = d_l1_down_proc_open, |
234 | static int | 219 | .read = seq_read, |
235 | read_grp_opt(char *page, char **start, off_t off, int count, int *eof, | 220 | .llseek = seq_lseek, |
236 | void *data) | 221 | .release = single_release, |
222 | .write = d_l1_down_proc_write, | ||
223 | }; | ||
224 | |||
225 | static int grp_opt_proc_show(struct seq_file *m, void *v) | ||
237 | { | 226 | { |
238 | int len = 0; | 227 | diva_os_xdi_adapter_t *a = m->private; |
239 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | ||
240 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 228 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
241 | 229 | ||
242 | len += sprintf(page + len, "%s\n", | 230 | seq_printf(m, "%s\n", |
243 | (IoAdapter->capi_cfg. | 231 | (IoAdapter->capi_cfg. |
244 | cfg_1 & DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) | 232 | cfg_1 & DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) |
245 | ? "1" : "0"); | 233 | ? "1" : "0"); |
234 | return 0; | ||
235 | } | ||
246 | 236 | ||
247 | if (off + count >= len) | 237 | static int grp_opt_proc_open(struct inode *inode, struct file *file) |
248 | *eof = 1; | 238 | { |
249 | if (len < off) | 239 | return single_open(file, grp_opt_proc_show, PDE(inode)->data); |
250 | return 0; | ||
251 | *start = page + off; | ||
252 | return ((count < len - off) ? count : len - off); | ||
253 | } | 240 | } |
254 | 241 | ||
255 | /* | 242 | static const struct file_operations grp_opt_proc_fops = { |
256 | ** info write | 243 | .owner = THIS_MODULE, |
257 | */ | 244 | .open = grp_opt_proc_open, |
258 | static int | 245 | .read = seq_read, |
259 | info_write(struct file *file, const char __user *buffer, unsigned long count, | 246 | .llseek = seq_lseek, |
260 | void *data) | 247 | .release = single_release, |
248 | .write = grp_opt_proc_write, | ||
249 | }; | ||
250 | |||
251 | static ssize_t info_proc_write(struct file *file, const char __user *buffer, | ||
252 | size_t count, loff_t *pos) | ||
261 | { | 253 | { |
262 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | 254 | diva_os_xdi_adapter_t *a = PDE(file->f_path.dentry->d_inode)->data; |
263 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 255 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
264 | char c[4]; | 256 | char c[4]; |
265 | 257 | ||
@@ -277,63 +269,46 @@ info_write(struct file *file, const char __user *buffer, unsigned long count, | |||
277 | return (-EINVAL); | 269 | return (-EINVAL); |
278 | } | 270 | } |
279 | 271 | ||
280 | /* | 272 | static int info_proc_show(struct seq_file *m, void *v) |
281 | ** info read | ||
282 | */ | ||
283 | static int | ||
284 | info_read(char *page, char **start, off_t off, int count, int *eof, | ||
285 | void *data) | ||
286 | { | 273 | { |
287 | int i = 0; | 274 | int i = 0; |
288 | int len = 0; | ||
289 | char *p; | 275 | char *p; |
290 | char tmpser[16]; | 276 | char tmpser[16]; |
291 | diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; | 277 | diva_os_xdi_adapter_t *a = m->private; |
292 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; | 278 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
293 | 279 | ||
294 | len += | 280 | seq_printf(m, "Name : %s\n", IoAdapter->Properties.Name); |
295 | sprintf(page + len, "Name : %s\n", | 281 | seq_printf(m, "DSP state : %08x\n", a->dsp_mask); |
296 | IoAdapter->Properties.Name); | 282 | seq_printf(m, "Channels : %02d\n", IoAdapter->Properties.Channels); |
297 | len += sprintf(page + len, "DSP state : %08x\n", a->dsp_mask); | 283 | seq_printf(m, "E. max/used : %03d/%03d\n", |
298 | len += sprintf(page + len, "Channels : %02d\n", | ||
299 | IoAdapter->Properties.Channels); | ||
300 | len += sprintf(page + len, "E. max/used : %03d/%03d\n", | ||
301 | IoAdapter->e_max, IoAdapter->e_count); | 284 | IoAdapter->e_max, IoAdapter->e_count); |
302 | diva_get_vserial_number(IoAdapter, tmpser); | 285 | diva_get_vserial_number(IoAdapter, tmpser); |
303 | len += sprintf(page + len, "Serial : %s\n", tmpser); | 286 | seq_printf(m, "Serial : %s\n", tmpser); |
304 | len += | 287 | seq_printf(m, "IRQ : %d\n", IoAdapter->irq_info.irq_nr); |
305 | sprintf(page + len, "IRQ : %d\n", | 288 | seq_printf(m, "CardIndex : %d\n", a->CardIndex); |
306 | IoAdapter->irq_info.irq_nr); | 289 | seq_printf(m, "CardOrdinal : %d\n", a->CardOrdinal); |
307 | len += sprintf(page + len, "CardIndex : %d\n", a->CardIndex); | 290 | seq_printf(m, "Controller : %d\n", a->controller); |
308 | len += sprintf(page + len, "CardOrdinal : %d\n", a->CardOrdinal); | 291 | seq_printf(m, "Bus-Type : %s\n", |
309 | len += sprintf(page + len, "Controller : %d\n", a->controller); | ||
310 | len += sprintf(page + len, "Bus-Type : %s\n", | ||
311 | (a->Bus == | 292 | (a->Bus == |
312 | DIVAS_XDI_ADAPTER_BUS_ISA) ? "ISA" : "PCI"); | 293 | DIVAS_XDI_ADAPTER_BUS_ISA) ? "ISA" : "PCI"); |
313 | len += sprintf(page + len, "Port-Name : %s\n", a->port_name); | 294 | seq_printf(m, "Port-Name : %s\n", a->port_name); |
314 | if (a->Bus == DIVAS_XDI_ADAPTER_BUS_PCI) { | 295 | if (a->Bus == DIVAS_XDI_ADAPTER_BUS_PCI) { |
315 | len += | 296 | seq_printf(m, "PCI-bus : %d\n", a->resources.pci.bus); |
316 | sprintf(page + len, "PCI-bus : %d\n", | 297 | seq_printf(m, "PCI-func : %d\n", a->resources.pci.func); |
317 | a->resources.pci.bus); | ||
318 | len += | ||
319 | sprintf(page + len, "PCI-func : %d\n", | ||
320 | a->resources.pci.func); | ||
321 | for (i = 0; i < 8; i++) { | 298 | for (i = 0; i < 8; i++) { |
322 | if (a->resources.pci.bar[i]) { | 299 | if (a->resources.pci.bar[i]) { |
323 | len += | 300 | seq_printf(m, |
324 | sprintf(page + len, | ||
325 | "Mem / I/O %d : 0x%x / mapped : 0x%lx", | 301 | "Mem / I/O %d : 0x%x / mapped : 0x%lx", |
326 | i, a->resources.pci.bar[i], | 302 | i, a->resources.pci.bar[i], |
327 | (unsigned long) a->resources. | 303 | (unsigned long) a->resources. |
328 | pci.addr[i]); | 304 | pci.addr[i]); |
329 | if (a->resources.pci.length[i]) { | 305 | if (a->resources.pci.length[i]) { |
330 | len += | 306 | seq_printf(m, |
331 | sprintf(page + len, | ||
332 | " / length : %d", | 307 | " / length : %d", |
333 | a->resources.pci. | 308 | a->resources.pci. |
334 | length[i]); | 309 | length[i]); |
335 | } | 310 | } |
336 | len += sprintf(page + len, "\n"); | 311 | seq_putc(m, '\n'); |
337 | } | 312 | } |
338 | } | 313 | } |
339 | } | 314 | } |
@@ -353,16 +328,25 @@ info_read(char *page, char **start, off_t off, int count, int *eof, | |||
353 | } else { | 328 | } else { |
354 | p = "ready"; | 329 | p = "ready"; |
355 | } | 330 | } |
356 | len += sprintf(page + len, "State : %s\n", p); | 331 | seq_printf(m, "State : %s\n", p); |
357 | 332 | ||
358 | if (off + count >= len) | 333 | return 0; |
359 | *eof = 1; | 334 | } |
360 | if (len < off) | 335 | |
361 | return 0; | 336 | static int info_proc_open(struct inode *inode, struct file *file) |
362 | *start = page + off; | 337 | { |
363 | return ((count < len - off) ? count : len - off); | 338 | return single_open(file, info_proc_show, PDE(inode)->data); |
364 | } | 339 | } |
365 | 340 | ||
341 | static const struct file_operations info_proc_fops = { | ||
342 | .owner = THIS_MODULE, | ||
343 | .open = info_proc_open, | ||
344 | .read = seq_read, | ||
345 | .llseek = seq_lseek, | ||
346 | .release = single_release, | ||
347 | .write = info_proc_write, | ||
348 | }; | ||
349 | |||
366 | /* | 350 | /* |
367 | ** adapter proc init/de-init | 351 | ** adapter proc init/de-init |
368 | */ | 352 | */ |
@@ -380,28 +364,20 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a) | |||
380 | return (0); | 364 | return (0); |
381 | a->proc_adapter_dir = (void *) de; | 365 | a->proc_adapter_dir = (void *) de; |
382 | 366 | ||
383 | if (!(pe = | 367 | pe = proc_create_data(info_proc_name, S_IRUGO | S_IWUSR, de, |
384 | create_proc_entry(info_proc_name, S_IFREG | S_IRUGO | S_IWUSR, de))) | 368 | &info_proc_fops, a); |
369 | if (!pe) | ||
385 | return (0); | 370 | return (0); |
386 | a->proc_info = (void *) pe; | 371 | a->proc_info = (void *) pe; |
387 | pe->write_proc = info_write; | ||
388 | pe->read_proc = info_read; | ||
389 | pe->data = a; | ||
390 | 372 | ||
391 | if ((pe = create_proc_entry(grp_opt_proc_name, | 373 | pe = proc_create_data(grp_opt_proc_name, S_IRUGO | S_IWUSR, de, |
392 | S_IFREG | S_IRUGO | S_IWUSR, de))) { | 374 | &grp_opt_proc_fops, a); |
375 | if (pe) | ||
393 | a->proc_grp_opt = (void *) pe; | 376 | a->proc_grp_opt = (void *) pe; |
394 | pe->write_proc = write_grp_opt; | 377 | pe = proc_create_data(d_l1_down_proc_name, S_IRUGO | S_IWUSR, de, |
395 | pe->read_proc = read_grp_opt; | 378 | &d_l1_down_proc_fops, a); |
396 | pe->data = a; | 379 | if (pe) |
397 | } | ||
398 | if ((pe = create_proc_entry(d_l1_down_proc_name, | ||
399 | S_IFREG | S_IRUGO | S_IWUSR, de))) { | ||
400 | a->proc_d_l1_down = (void *) pe; | 380 | a->proc_d_l1_down = (void *) pe; |
401 | pe->write_proc = write_d_l1_down; | ||
402 | pe->read_proc = read_d_l1_down; | ||
403 | pe->data = a; | ||
404 | } | ||
405 | 381 | ||
406 | DBG_TRC(("proc entry %s created", tmp)); | 382 | DBG_TRC(("proc entry %s created", tmp)); |
407 | 383 | ||