1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include "comedidev.h"
32#include "comedi_internal.h"
33#include <linux/proc_fs.h>
34#include <linux/seq_file.h>
35
36static int comedi_read(struct seq_file *m, void *v)
37{
38 int i;
39 int devices_q = 0;
40 struct comedi_driver *driv;
41
42 seq_printf(m,
43 "comedi version " COMEDI_RELEASE "\n"
44 "format string: %s\n",
45 "\"%2d: %-20s %-20s %4d\", i, "
46 "driver_name, board_name, n_subdevices");
47
48 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
49 struct comedi_device *dev = comedi_dev_from_minor(i);
50 if (!dev)
51 continue;
52
53 if (dev->attached) {
54 devices_q = 1;
55 seq_printf(m, "%2d: %-20s %-20s %4d\n",
56 i, dev->driver->driver_name,
57 dev->board_name, dev->n_subdevices);
58 }
59 }
60 if (!devices_q)
61 seq_puts(m, "no devices\n");
62
63 for (driv = comedi_drivers; driv; driv = driv->next) {
64 seq_printf(m, "%s:\n", driv->driver_name);
65 for (i = 0; i < driv->num_names; i++)
66 seq_printf(m, " %s\n",
67 *(char **)((char *)driv->board_name +
68 i * driv->offset));
69
70 if (!driv->num_names)
71 seq_printf(m, " %s\n", driv->driver_name);
72 }
73
74 return 0;
75}
76
77
78
79
80static int comedi_proc_open(struct inode *inode, struct file *file)
81{
82 return single_open(file, comedi_read, NULL);
83}
84
85static const struct file_operations comedi_proc_fops = {
86 .open = comedi_proc_open,
87 .read = seq_read,
88 .llseek = seq_lseek,
89 .release = single_release,
90};
91
92void comedi_proc_init(void)
93{
94 proc_create("comedi", 0644, NULL, &comedi_proc_fops);
95}
96
97void comedi_proc_cleanup(void)
98{
99 remove_proc_entry("comedi", NULL);
100}
101