gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / staging / comedi / proc.c
blob8bc8e42beb90b2874967f12d95d63d0e3c22d830
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * /proc interface for comedi
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 1998 David A. Schleef <ds@schleef.org>
7 */
9 /*
10 * This is some serious bloatware.
12 * Taken from Dave A.'s PCL-711 driver, 'cuz I thought it
13 * was cool.
16 #include "comedidev.h"
17 #include "comedi_internal.h"
18 #include <linux/proc_fs.h>
19 #include <linux/seq_file.h>
21 static int comedi_read(struct seq_file *m, void *v)
23 int i;
24 int devices_q = 0;
25 struct comedi_driver *driv;
27 seq_printf(m, "comedi version " COMEDI_RELEASE "\nformat string: %s\n",
28 "\"%2d: %-20s %-20s %4d\", i, driver_name, board_name, n_subdevices");
30 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
31 struct comedi_device *dev = comedi_dev_get_from_minor(i);
33 if (!dev)
34 continue;
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);
43 up_read(&dev->attach_lock);
44 comedi_dev_put(dev);
46 if (!devices_q)
47 seq_puts(m, "no devices\n");
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));
57 if (!driv->num_names)
58 seq_printf(m, " %s\n", driv->driver_name);
60 mutex_unlock(&comedi_drivers_list_lock);
62 return 0;
65 void __init comedi_proc_init(void)
67 if (!proc_create_single("comedi", 0444, NULL, comedi_read))
68 pr_warn("comedi: unable to create proc entry\n");
71 void comedi_proc_cleanup(void)
73 remove_proc_entry("comedi", NULL);