2017-11-07 13:58:43 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-11-05 04:29:31 +00:00
|
|
|
/*
|
2014-03-18 07:14:20 +00:00
|
|
|
* /proc interface for comedi
|
|
|
|
*
|
|
|
|
* COMEDI - Linux Control and Measurement Device Interface
|
|
|
|
* Copyright (C) 1998 David A. Schleef <ds@schleef.org>
|
|
|
|
*/
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/*
|
2014-03-18 07:14:20 +00:00
|
|
|
* This is some serious bloatware.
|
|
|
|
*
|
|
|
|
* Taken from Dave A.'s PCL-711 driver, 'cuz I thought it
|
|
|
|
* was cool.
|
|
|
|
*/
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2021-11-17 12:05:59 +00:00
|
|
|
#include <linux/comedi/comedidev.h>
|
2012-06-19 09:17:46 +00:00
|
|
|
#include "comedi_internal.h"
|
2008-11-05 04:29:31 +00:00
|
|
|
#include <linux/proc_fs.h>
|
2013-04-08 15:39:33 +00:00
|
|
|
#include <linux/seq_file.h>
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2013-04-08 15:39:33 +00:00
|
|
|
static int comedi_read(struct seq_file *m, void *v)
|
2008-11-05 04:29:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int devices_q = 0;
|
2009-03-17 02:05:25 +00:00
|
|
|
struct comedi_driver *driv;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2014-03-18 07:14:20 +00:00
|
|
|
seq_printf(m, "comedi version " COMEDI_RELEASE "\nformat string: %s\n",
|
|
|
|
"\"%2d: %-20s %-20s %4d\", i, driver_name, board_name, n_subdevices");
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
|
2013-11-08 15:03:36 +00:00
|
|
|
struct comedi_device *dev = comedi_dev_get_from_minor(i);
|
|
|
|
|
2012-12-19 22:35:23 +00:00
|
|
|
if (!dev)
|
2009-03-17 02:03:56 +00:00
|
|
|
continue;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2013-11-08 15:03:36 +00:00
|
|
|
down_read(&dev->attach_lock);
|
2008-11-05 04:29:31 +00:00
|
|
|
if (dev->attached) {
|
|
|
|
devices_q = 1;
|
2013-04-08 15:39:33 +00:00
|
|
|
seq_printf(m, "%2d: %-20s %-20s %4d\n",
|
|
|
|
i, dev->driver->driver_name,
|
|
|
|
dev->board_name, dev->n_subdevices);
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|
2013-11-08 15:03:36 +00:00
|
|
|
up_read(&dev->attach_lock);
|
|
|
|
comedi_dev_put(dev);
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|
2009-03-17 02:04:23 +00:00
|
|
|
if (!devices_q)
|
2013-04-08 15:39:33 +00:00
|
|
|
seq_puts(m, "no devices\n");
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2013-06-27 13:50:58 +00:00
|
|
|
mutex_lock(&comedi_drivers_list_lock);
|
2008-11-05 04:29:31 +00:00
|
|
|
for (driv = comedi_drivers; driv; driv = driv->next) {
|
2013-04-08 15:39:33 +00:00
|
|
|
seq_printf(m, "%s:\n", driv->driver_name);
|
|
|
|
for (i = 0; i < driv->num_names; i++)
|
|
|
|
seq_printf(m, " %s\n",
|
|
|
|
*(char **)((char *)driv->board_name +
|
|
|
|
i * driv->offset));
|
|
|
|
|
2009-03-17 02:04:23 +00:00
|
|
|
if (!driv->num_names)
|
2013-04-08 15:39:33 +00:00
|
|
|
seq_printf(m, " %s\n", driv->driver_name);
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|
2013-06-27 13:50:58 +00:00
|
|
|
mutex_unlock(&comedi_drivers_list_lock);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2013-04-08 15:39:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-12-30 11:26:50 +00:00
|
|
|
void __init comedi_proc_init(void)
|
2008-11-05 04:29:31 +00:00
|
|
|
{
|
2018-05-15 13:57:23 +00:00
|
|
|
if (!proc_create_single("comedi", 0444, NULL, comedi_read))
|
2016-12-30 11:27:41 +00:00
|
|
|
pr_warn("comedi: unable to create proc entry\n");
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void comedi_proc_cleanup(void)
|
|
|
|
{
|
2010-05-03 22:32:04 +00:00
|
|
|
remove_proc_entry("comedi", NULL);
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|