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