blob: 36ae2cd92ad9f1bc5f34faa4bcd5a45f7e7c7bf1 [file] [log] [blame]
David Schleefed9eccb2008-11-04 20:29:31 -08001/*
2 module/proc.c
3 /proc interface for comedi
4
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1998 David A. Schleef <ds@schleef.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22*/
23
24/*
25 This is some serious bloatware.
26
27 Taken from Dave A.'s PCL-711 driver, 'cuz I thought it
28 was cool.
29*/
30
31#define __NO_VERSION__
32#include "comedidev.h"
33#include <linux/proc_fs.h>
Bill Pembertonb6c77752009-03-16 22:03:24 -040034/* #include <linux/string.h> */
David Schleefed9eccb2008-11-04 20:29:31 -080035
36int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
37 int *eof, void *data);
38
Bill Pemberton139dfbd2009-03-16 22:05:25 -040039extern struct comedi_driver *comedi_drivers;
David Schleefed9eccb2008-11-04 20:29:31 -080040
41int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
42 int *eof, void *data)
43{
44 int i;
45 int devices_q = 0;
46 int l = 0;
Bill Pemberton139dfbd2009-03-16 22:05:25 -040047 struct comedi_driver *driv;
David Schleefed9eccb2008-11-04 20:29:31 -080048
49 l += sprintf(buf + l,
50 "comedi version " COMEDI_RELEASE "\n"
51 "format string: %s\n",
52 "\"%2d: %-20s %-20s %4d\",i,driver_name,board_name,n_subdevices");
53
54 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
55 struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i);
Bill Pemberton71b5f4f2009-03-16 22:05:08 -040056 struct comedi_device *dev;
David Schleefed9eccb2008-11-04 20:29:31 -080057
Bill Pembertonc7427402009-03-16 22:03:56 -040058 if (dev_file_info == NULL)
59 continue;
David Schleefed9eccb2008-11-04 20:29:31 -080060 dev = dev_file_info->device;
61
62 if (dev->attached) {
63 devices_q = 1;
64 l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n",
65 i,
66 dev->driver->driver_name,
67 dev->board_name, dev->n_subdevices);
68 }
69 }
Bill Pemberton82675f32009-03-16 22:04:23 -040070 if (!devices_q)
David Schleefed9eccb2008-11-04 20:29:31 -080071 l += sprintf(buf + l, "no devices\n");
David Schleefed9eccb2008-11-04 20:29:31 -080072
73 for (driv = comedi_drivers; driv; driv = driv->next) {
74 l += sprintf(buf + l, "%s:\n", driv->driver_name);
75 for (i = 0; i < driv->num_names; i++) {
76 l += sprintf(buf + l, " %s\n",
77 *(char **)((char *)driv->board_name +
78 i * driv->offset));
79 }
Bill Pemberton82675f32009-03-16 22:04:23 -040080 if (!driv->num_names)
David Schleefed9eccb2008-11-04 20:29:31 -080081 l += sprintf(buf + l, " %s\n", driv->driver_name);
David Schleefed9eccb2008-11-04 20:29:31 -080082 }
83
84 return l;
85}
86
J.R. Mauroa8275fc2008-11-14 20:01:14 -050087#ifdef CONFIG_PROC_FS
David Schleefed9eccb2008-11-04 20:29:31 -080088void comedi_proc_init(void)
89{
90 struct proc_dir_entry *comedi_proc;
91
92 comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, 0);
93 if (comedi_proc)
94 comedi_proc->read_proc = comedi_read_procmem;
95}
96
97void comedi_proc_cleanup(void)
98{
99 remove_proc_entry("comedi", 0);
100}
J.R. Mauroa8275fc2008-11-14 20:01:14 -0500101#endif