diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-04-12 16:54:43 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-04-12 16:54:43 -0400 |
commit | a890b15c0990cc8d686edcc85f5fccde71ad5ce9 (patch) | |
tree | 73162355b58283a2531f13fbbf663809f95c1483 /drivers/isdn/gigaset/proc.c | |
parent | 79fa1b677be3a985cc66b9218a4dd09818f1051b (diff) | |
parent | 26ec634c31a11a003040e10b4d650495158632fd (diff) |
Merge branch 'upstream'
Diffstat (limited to 'drivers/isdn/gigaset/proc.c')
-rw-r--r-- | drivers/isdn/gigaset/proc.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index c6915fa2be6c..d267a636b53c 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Stuff used by all variants of the driver | 2 | * Stuff used by all variants of the driver |
3 | * | 3 | * |
4 | * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>, | 4 | * Copyright (c) 2001 by Stefan Eilers, |
5 | * Hansjoerg Lipp <hjlipp@web.de>, | 5 | * Hansjoerg Lipp <hjlipp@web.de>, |
6 | * Tilman Schmidt <tilman@imap.cc>. | 6 | * Tilman Schmidt <tilman@imap.cc>. |
7 | * | 7 | * |
@@ -11,26 +11,29 @@ | |||
11 | * published by the Free Software Foundation; either version 2 of | 11 | * published by the Free Software Foundation; either version 2 of |
12 | * the License, or (at your option) any later version. | 12 | * the License, or (at your option) any later version. |
13 | * ===================================================================== | 13 | * ===================================================================== |
14 | * ToDo: ... | ||
15 | * ===================================================================== | ||
16 | * Version: $Id: proc.c,v 1.5.2.13 2006/02/04 18:28:16 hjlipp Exp $ | ||
17 | * ===================================================================== | ||
18 | */ | 14 | */ |
19 | 15 | ||
20 | #include "gigaset.h" | 16 | #include "gigaset.h" |
21 | #include <linux/ctype.h> | 17 | #include <linux/ctype.h> |
22 | 18 | ||
23 | static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf) | 19 | static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, |
20 | char *buf) | ||
24 | { | 21 | { |
25 | struct usb_interface *intf = to_usb_interface(dev); | 22 | int ret; |
26 | struct cardstate *cs = usb_get_intfdata(intf); | 23 | unsigned long flags; |
27 | return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); // FIXME use scnprintf for 13607 bit architectures (if PAGE_SIZE==4096) | 24 | struct cardstate *cs = dev_get_drvdata(dev); |
25 | |||
26 | spin_lock_irqsave(&cs->lock, flags); | ||
27 | ret = sprintf(buf, "%u\n", cs->cidmode); | ||
28 | spin_unlock_irqrestore(&cs->lock, flags); | ||
29 | |||
30 | return ret; | ||
28 | } | 31 | } |
29 | 32 | ||
30 | static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 33 | static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, |
34 | const char *buf, size_t count) | ||
31 | { | 35 | { |
32 | struct usb_interface *intf = to_usb_interface(dev); | 36 | struct cardstate *cs = dev_get_drvdata(dev); |
33 | struct cardstate *cs = usb_get_intfdata(intf); | ||
34 | long int value; | 37 | long int value; |
35 | char *end; | 38 | char *end; |
36 | 39 | ||
@@ -41,23 +44,23 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, co | |||
41 | if (value < 0 || value > 1) | 44 | if (value < 0 || value > 1) |
42 | return -EINVAL; | 45 | return -EINVAL; |
43 | 46 | ||
44 | if (down_interruptible(&cs->sem)) | 47 | if (mutex_lock_interruptible(&cs->mutex)) |
45 | return -ERESTARTSYS; // FIXME -EINTR? | 48 | return -ERESTARTSYS; // FIXME -EINTR? |
46 | 49 | ||
47 | cs->waiting = 1; | 50 | cs->waiting = 1; |
48 | if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, | 51 | if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, |
49 | NULL, value, NULL)) { | 52 | NULL, value, NULL)) { |
50 | cs->waiting = 0; | 53 | cs->waiting = 0; |
51 | up(&cs->sem); | 54 | mutex_unlock(&cs->mutex); |
52 | return -ENOMEM; | 55 | return -ENOMEM; |
53 | } | 56 | } |
54 | 57 | ||
55 | dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); | 58 | gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); |
56 | gigaset_schedule_event(cs); | 59 | gigaset_schedule_event(cs); |
57 | 60 | ||
58 | wait_event(cs->waitqueue, !cs->waiting); | 61 | wait_event(cs->waitqueue, !cs->waiting); |
59 | 62 | ||
60 | up(&cs->sem); | 63 | mutex_unlock(&cs->mutex); |
61 | 64 | ||
62 | return count; | 65 | return count; |
63 | } | 66 | } |
@@ -65,17 +68,15 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, co | |||
65 | static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); | 68 | static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); |
66 | 69 | ||
67 | /* free sysfs for device */ | 70 | /* free sysfs for device */ |
68 | void gigaset_free_dev_sysfs(struct usb_interface *interface) | 71 | void gigaset_free_dev_sysfs(struct cardstate *cs) |
69 | { | 72 | { |
70 | dbg(DEBUG_INIT, "removing sysfs entries"); | 73 | gig_dbg(DEBUG_INIT, "removing sysfs entries"); |
71 | device_remove_file(&interface->dev, &dev_attr_cidmode); | 74 | device_remove_file(cs->dev, &dev_attr_cidmode); |
72 | } | 75 | } |
73 | EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); | ||
74 | 76 | ||
75 | /* initialize sysfs for device */ | 77 | /* initialize sysfs for device */ |
76 | void gigaset_init_dev_sysfs(struct usb_interface *interface) | 78 | void gigaset_init_dev_sysfs(struct cardstate *cs) |
77 | { | 79 | { |
78 | dbg(DEBUG_INIT, "setting up sysfs"); | 80 | gig_dbg(DEBUG_INIT, "setting up sysfs"); |
79 | device_create_file(&interface->dev, &dev_attr_cidmode); | 81 | device_create_file(cs->dev, &dev_attr_cidmode); |
80 | } | 82 | } |
81 | EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); | ||