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