Commit | Line | Data |
---|---|---|
ed9eccbe | 1 | /* |
6f2c9efa MW |
2 | * /proc interface for comedi |
3 | * | |
4 | * COMEDI - Linux Control and Measurement Device Interface | |
5 | * Copyright (C) 1998 David A. Schleef <ds@schleef.org> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | */ | |
ed9eccbe DS |
17 | |
18 | /* | |
6f2c9efa MW |
19 | * This is some serious bloatware. |
20 | * | |
21 | * Taken from Dave A.'s PCL-711 driver, 'cuz I thought it | |
22 | * was cool. | |
23 | */ | |
ed9eccbe | 24 | |
ed9eccbe | 25 | #include "comedidev.h" |
f286766e | 26 | #include "comedi_internal.h" |
ed9eccbe | 27 | #include <linux/proc_fs.h> |
1f817b86 | 28 | #include <linux/seq_file.h> |
ed9eccbe | 29 | |
1f817b86 | 30 | static int comedi_read(struct seq_file *m, void *v) |
ed9eccbe DS |
31 | { |
32 | int i; | |
33 | int devices_q = 0; | |
139dfbdf | 34 | struct comedi_driver *driv; |
ed9eccbe | 35 | |
6f2c9efa MW |
36 | seq_printf(m, "comedi version " COMEDI_RELEASE "\nformat string: %s\n", |
37 | "\"%2d: %-20s %-20s %4d\", i, driver_name, board_name, n_subdevices"); | |
ed9eccbe DS |
38 | |
39 | for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { | |
616a3548 IA |
40 | struct comedi_device *dev = comedi_dev_get_from_minor(i); |
41 | ||
4da5fa9a | 42 | if (!dev) |
c7427409 | 43 | continue; |
ed9eccbe | 44 | |
616a3548 | 45 | down_read(&dev->attach_lock); |
ed9eccbe DS |
46 | if (dev->attached) { |
47 | devices_q = 1; | |
1f817b86 DH |
48 | seq_printf(m, "%2d: %-20s %-20s %4d\n", |
49 | i, dev->driver->driver_name, | |
50 | dev->board_name, dev->n_subdevices); | |
ed9eccbe | 51 | } |
616a3548 IA |
52 | up_read(&dev->attach_lock); |
53 | comedi_dev_put(dev); | |
ed9eccbe | 54 | } |
82675f35 | 55 | if (!devices_q) |
1f817b86 | 56 | seq_puts(m, "no devices\n"); |
ed9eccbe | 57 | |
c383e2d6 | 58 | mutex_lock(&comedi_drivers_list_lock); |
ed9eccbe | 59 | for (driv = comedi_drivers; driv; driv = driv->next) { |
1f817b86 DH |
60 | seq_printf(m, "%s:\n", driv->driver_name); |
61 | for (i = 0; i < driv->num_names; i++) | |
62 | seq_printf(m, " %s\n", | |
63 | *(char **)((char *)driv->board_name + | |
64 | i * driv->offset)); | |
65 | ||
82675f35 | 66 | if (!driv->num_names) |
1f817b86 | 67 | seq_printf(m, " %s\n", driv->driver_name); |
ed9eccbe | 68 | } |
c383e2d6 | 69 | mutex_unlock(&comedi_drivers_list_lock); |
ed9eccbe | 70 | |
1f817b86 DH |
71 | return 0; |
72 | } | |
73 | ||
74 | /* | |
75 | * seq_file wrappers for procfile show routines. | |
76 | */ | |
77 | static int comedi_proc_open(struct inode *inode, struct file *file) | |
78 | { | |
79 | return single_open(file, comedi_read, NULL); | |
ed9eccbe DS |
80 | } |
81 | ||
1f817b86 DH |
82 | static const struct file_operations comedi_proc_fops = { |
83 | .open = comedi_proc_open, | |
84 | .read = seq_read, | |
85 | .llseek = seq_lseek, | |
bae301d3 | 86 | .release = single_release, |
1f817b86 DH |
87 | }; |
88 | ||
ed9eccbe DS |
89 | void comedi_proc_init(void) |
90 | { | |
1f817b86 | 91 | proc_create("comedi", 0644, NULL, &comedi_proc_fops); |
ed9eccbe DS |
92 | } |
93 | ||
94 | void comedi_proc_cleanup(void) | |
95 | { | |
22d11424 | 96 | remove_proc_entry("comedi", NULL); |
ed9eccbe | 97 | } |