at v3.9-rc6 93 lines 2.5 kB view raw
1/* 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#include "comedidev.h" 32#include "comedi_internal.h" 33#include <linux/proc_fs.h> 34#include <linux/string.h> 35 36static int comedi_read(char *buf, char **start, off_t offset, int len, 37 int *eof, void *data) 38{ 39 int i; 40 int devices_q = 0; 41 int l = 0; 42 struct comedi_driver *driv; 43 44 l += sprintf(buf + l, 45 "comedi version " COMEDI_RELEASE "\n" 46 "format string: %s\n", 47 "\"%2d: %-20s %-20s %4d\", i, " 48 "driver_name, board_name, n_subdevices"); 49 50 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { 51 struct comedi_device *dev = comedi_dev_from_minor(i); 52 53 if (!dev) 54 continue; 55 56 if (dev->attached) { 57 devices_q = 1; 58 l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n", 59 i, 60 dev->driver->driver_name, 61 dev->board_name, dev->n_subdevices); 62 } 63 } 64 if (!devices_q) 65 l += sprintf(buf + l, "no devices\n"); 66 67 for (driv = comedi_drivers; driv; driv = driv->next) { 68 l += sprintf(buf + l, "%s:\n", driv->driver_name); 69 for (i = 0; i < driv->num_names; i++) { 70 l += sprintf(buf + l, " %s\n", 71 *(char **)((char *)driv->board_name + 72 i * driv->offset)); 73 } 74 if (!driv->num_names) 75 l += sprintf(buf + l, " %s\n", driv->driver_name); 76 } 77 78 return l; 79} 80 81void comedi_proc_init(void) 82{ 83 struct proc_dir_entry *comedi_proc; 84 85 comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, NULL); 86 if (comedi_proc) 87 comedi_proc->read_proc = comedi_read; 88} 89 90void comedi_proc_cleanup(void) 91{ 92 remove_proc_entry("comedi", NULL); 93}