diff options
author | Hansjoerg Lipp <hjlipp@web.de> | 2006-03-26 04:38:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-26 11:57:05 -0500 |
commit | 982da5a196a0859eedc5ca1ff88feaf1bc6d6e4e (patch) | |
tree | f42c93dfa7abd78f68584be49cb71238f5328326 /drivers/isdn | |
parent | ee8a4b7f857fe7ba243e65c8925798cf8eda5ab0 (diff) |
[PATCH] isdn4linux: Siemens Gigaset drivers - procfs interface
And: Tilman Schmidt <tilman@imap.cc>
This patch adds the procfs interface to the gigaset module. The procfs
interface provides access to status information and statistics about the
Gigaset devices. If the drivers are built with the debugging option it also
allows to change the amount of debugging output on the fly.
Signed-off-by: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Cc: Karsten Keil <kkeil@suse.de>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/gigaset/proc.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c new file mode 100644 index 000000000000..c6915fa2be6c --- /dev/null +++ b/drivers/isdn/gigaset/proc.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * Stuff used by all variants of the driver | ||
3 | * | ||
4 | * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>, | ||
5 | * Hansjoerg Lipp <hjlipp@web.de>, | ||
6 | * Tilman Schmidt <tilman@imap.cc>. | ||
7 | * | ||
8 | * ===================================================================== | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License as | ||
11 | * published by the Free Software Foundation; either version 2 of | ||
12 | * the License, or (at your option) any later version. | ||
13 | * ===================================================================== | ||
14 | * ToDo: ... | ||
15 | * ===================================================================== | ||
16 | * Version: $Id: proc.c,v 1.5.2.13 2006/02/04 18:28:16 hjlipp Exp $ | ||
17 | * ===================================================================== | ||
18 | */ | ||
19 | |||
20 | #include "gigaset.h" | ||
21 | #include <linux/ctype.h> | ||
22 | |||
23 | static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf) | ||
24 | { | ||
25 | struct usb_interface *intf = to_usb_interface(dev); | ||
26 | struct cardstate *cs = usb_get_intfdata(intf); | ||
27 | return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); // FIXME use scnprintf for 13607 bit architectures (if PAGE_SIZE==4096) | ||
28 | } | ||
29 | |||
30 | static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
31 | { | ||
32 | struct usb_interface *intf = to_usb_interface(dev); | ||
33 | struct cardstate *cs = usb_get_intfdata(intf); | ||
34 | long int value; | ||
35 | char *end; | ||
36 | |||
37 | value = simple_strtol(buf, &end, 0); | ||
38 | while (*end) | ||
39 | if (!isspace(*end++)) | ||
40 | return -EINVAL; | ||
41 | if (value < 0 || value > 1) | ||
42 | return -EINVAL; | ||
43 | |||
44 | if (down_interruptible(&cs->sem)) | ||
45 | return -ERESTARTSYS; // FIXME -EINTR? | ||
46 | |||
47 | cs->waiting = 1; | ||
48 | if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, | ||
49 | NULL, value, NULL)) { | ||
50 | cs->waiting = 0; | ||
51 | up(&cs->sem); | ||
52 | return -ENOMEM; | ||
53 | } | ||
54 | |||
55 | dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); | ||
56 | gigaset_schedule_event(cs); | ||
57 | |||
58 | wait_event(cs->waitqueue, !cs->waiting); | ||
59 | |||
60 | up(&cs->sem); | ||
61 | |||
62 | return count; | ||
63 | } | ||
64 | |||
65 | static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); | ||
66 | |||
67 | /* free sysfs for device */ | ||
68 | void gigaset_free_dev_sysfs(struct usb_interface *interface) | ||
69 | { | ||
70 | dbg(DEBUG_INIT, "removing sysfs entries"); | ||
71 | device_remove_file(&interface->dev, &dev_attr_cidmode); | ||
72 | } | ||
73 | EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); | ||
74 | |||
75 | /* initialize sysfs for device */ | ||
76 | void gigaset_init_dev_sysfs(struct usb_interface *interface) | ||
77 | { | ||
78 | dbg(DEBUG_INIT, "setting up sysfs"); | ||
79 | device_create_file(&interface->dev, &dev_attr_cidmode); | ||
80 | } | ||
81 | EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); | ||