2008-11-04 21:29:31 -07:00
|
|
|
/*
|
|
|
|
module/proc.c
|
|
|
|
/proc interface for comedi
|
|
|
|
|
|
|
|
COMEDI - Linux Control and Measurement Device Interface
|
|
|
|
Copyright (C) 1998 David A. Schleef <ds@schleef.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is some serious bloatware.
|
|
|
|
|
|
|
|
Taken from Dave A.'s PCL-711 driver, 'cuz I thought it
|
|
|
|
was cool.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "comedidev.h"
|
2012-06-19 03:17:46 -06:00
|
|
|
#include "comedi_internal.h"
|
2008-11-04 21:29:31 -07:00
|
|
|
#include <linux/proc_fs.h>
|
2010-05-03 16:32:04 -06:00
|
|
|
#include <linux/string.h>
|
2008-11-04 21:29:31 -07:00
|
|
|
|
2010-05-03 16:32:04 -06:00
|
|
|
static int comedi_read(char *buf, char **start, off_t offset, int len,
|
|
|
|
int *eof, void *data)
|
2008-11-04 21:29:31 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int devices_q = 0;
|
|
|
|
int l = 0;
|
2009-03-16 20:05:25 -06:00
|
|
|
struct comedi_driver *driv;
|
2008-11-04 21:29:31 -07:00
|
|
|
|
|
|
|
l += sprintf(buf + l,
|
2009-06-08 09:34:41 -06:00
|
|
|
"comedi version " COMEDI_RELEASE "\n"
|
|
|
|
"format string: %s\n",
|
2010-04-30 16:43:12 -06:00
|
|
|
"\"%2d: %-20s %-20s %4d\", i, "
|
|
|
|
"driver_name, board_name, n_subdevices");
|
2008-11-04 21:29:31 -07:00
|
|
|
|
|
|
|
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
|
2012-12-19 15:35:23 -07:00
|
|
|
struct comedi_device *dev = comedi_dev_from_minor(i);
|
2008-11-04 21:29:31 -07:00
|
|
|
|
2012-12-19 15:35:23 -07:00
|
|
|
if (!dev)
|
2009-03-16 20:03:56 -06:00
|
|
|
continue;
|
2008-11-04 21:29:31 -07:00
|
|
|
|
|
|
|
if (dev->attached) {
|
|
|
|
devices_q = 1;
|
|
|
|
l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n",
|
2009-06-08 09:34:41 -06:00
|
|
|
i,
|
|
|
|
dev->driver->driver_name,
|
|
|
|
dev->board_name, dev->n_subdevices);
|
2008-11-04 21:29:31 -07:00
|
|
|
}
|
|
|
|
}
|
2009-03-16 20:04:23 -06:00
|
|
|
if (!devices_q)
|
2008-11-04 21:29:31 -07:00
|
|
|
l += sprintf(buf + l, "no devices\n");
|
|
|
|
|
|
|
|
for (driv = comedi_drivers; driv; driv = driv->next) {
|
|
|
|
l += sprintf(buf + l, "%s:\n", driv->driver_name);
|
|
|
|
for (i = 0; i < driv->num_names; i++) {
|
|
|
|
l += sprintf(buf + l, " %s\n",
|
2009-06-08 09:34:41 -06:00
|
|
|
*(char **)((char *)driv->board_name +
|
|
|
|
i * driv->offset));
|
2008-11-04 21:29:31 -07:00
|
|
|
}
|
2009-03-16 20:04:23 -06:00
|
|
|
if (!driv->num_names)
|
2008-11-04 21:29:31 -07:00
|
|
|
l += sprintf(buf + l, " %s\n", driv->driver_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
void comedi_proc_init(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *comedi_proc;
|
|
|
|
|
2010-05-03 16:32:04 -06:00
|
|
|
comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, NULL);
|
2008-11-04 21:29:31 -07:00
|
|
|
if (comedi_proc)
|
2010-05-03 16:32:04 -06:00
|
|
|
comedi_proc->read_proc = comedi_read;
|
2008-11-04 21:29:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void comedi_proc_cleanup(void)
|
|
|
|
{
|
2010-05-03 16:32:04 -06:00
|
|
|
remove_proc_entry("comedi", NULL);
|
2008-11-04 21:29:31 -07:00
|
|
|
}
|