From 917f5085ddb3498033551e711fb22f48ddeb8378 Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:00 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: code cleanup With Hansjoerg Lipp Source code formatting cleanups for the Siemens Gigaset drivers, such as line length, comments, removal of unused declarations, and typo corrections. It does not introduce any functional changes. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index c6915fa2be6c..c30ea80d517a 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -11,23 +11,21 @@ * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * ===================================================================== - * ToDo: ... - * ===================================================================== - * Version: $Id: proc.c,v 1.5.2.13 2006/02/04 18:28:16 hjlipp Exp $ - * ===================================================================== */ #include "gigaset.h" #include -static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, + char *buf) { struct usb_interface *intf = to_usb_interface(dev); struct cardstate *cs = usb_get_intfdata(intf); - return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); // FIXME use scnprintf for 13607 bit architectures (if PAGE_SIZE==4096) + return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); } -static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct cardstate *cs = usb_get_intfdata(intf); -- cgit v1.2.2 From 784d5858aac58c06608def862d73ae9a32f5ee23 Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:04 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: logging usage With Hansjoerg Lipp Improve error reporting of the Gigaset drivers, by using the dev_err/dev_warn/dev_info macros from device.h instead of err/warn/info from usb.h whereever possible. Also rename the private dbg macro to gig_dbg in order to avoid confusion with the macro of the same name in usb.h. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index c30ea80d517a..695495ad0668 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -44,13 +44,13 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, cs->waiting = 1; if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, - NULL, value, NULL)) { + NULL, value, NULL)) { cs->waiting = 0; up(&cs->sem); return -ENOMEM; } - dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); + gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); gigaset_schedule_event(cs); wait_event(cs->waitqueue, !cs->waiting); @@ -65,7 +65,7 @@ static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); /* free sysfs for device */ void gigaset_free_dev_sysfs(struct usb_interface *interface) { - dbg(DEBUG_INIT, "removing sysfs entries"); + gig_dbg(DEBUG_INIT, "removing sysfs entries"); device_remove_file(&interface->dev, &dev_attr_cidmode); } EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); @@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); /* initialize sysfs for device */ void gigaset_init_dev_sysfs(struct usb_interface *interface) { - dbg(DEBUG_INIT, "setting up sysfs"); + gig_dbg(DEBUG_INIT, "setting up sysfs"); device_create_file(&interface->dev, &dev_attr_cidmode); } EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); -- cgit v1.2.2 From b1d47464c947f08125dc4ac4a2321ced9e2fed29 Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:07 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: sysfs usage With Hansjoerg Lipp Correct the way the Gigaset drivers create their sysfs entries. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index 695495ad0668..912fed670742 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -19,16 +19,14 @@ static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf) { - struct usb_interface *intf = to_usb_interface(dev); - struct cardstate *cs = usb_get_intfdata(intf); + struct cardstate *cs = dev_get_drvdata(dev); return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); } static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct usb_interface *intf = to_usb_interface(dev); - struct cardstate *cs = usb_get_intfdata(intf); + struct cardstate *cs = dev_get_drvdata(dev); long int value; char *end; @@ -63,17 +61,15 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); /* free sysfs for device */ -void gigaset_free_dev_sysfs(struct usb_interface *interface) +void gigaset_free_dev_sysfs(struct cardstate *cs) { gig_dbg(DEBUG_INIT, "removing sysfs entries"); - device_remove_file(&interface->dev, &dev_attr_cidmode); + device_remove_file(cs->dev, &dev_attr_cidmode); } -EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); /* initialize sysfs for device */ -void gigaset_init_dev_sysfs(struct usb_interface *interface) +void gigaset_init_dev_sysfs(struct cardstate *cs) { gig_dbg(DEBUG_INIT, "setting up sysfs"); - device_create_file(&interface->dev, &dev_attr_cidmode); + device_create_file(cs->dev, &dev_attr_cidmode); } -EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); -- cgit v1.2.2 From abfd1dc7c18e4be89715071a524324c7b2515565 Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:12 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: mutex conversion With Hansjoerg Lipp Convert the semaphores used by the Gigaset drivers to mutexes. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index 912fed670742..8f124e8e604b 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -37,14 +37,14 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, if (value < 0 || value > 1) return -EINVAL; - if (down_interruptible(&cs->sem)) + if (mutex_lock_interruptible(&cs->mutex)) return -ERESTARTSYS; // FIXME -EINTR? cs->waiting = 1; if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, NULL, value, NULL)) { cs->waiting = 0; - up(&cs->sem); + mutex_unlock(&cs->mutex); return -ENOMEM; } @@ -53,7 +53,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, wait_event(cs->waitqueue, !cs->waiting); - up(&cs->sem); + mutex_unlock(&cs->mutex); return count; } -- cgit v1.2.2 From 70440cf24ce6841fc5a01c38e2a732cf0bc2792a Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:14 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: remove forward references With Hansjoerg Lipp Remove four unnecessary forward function declarations and an obsolete E-mail address from the Siemens Gigaset drivers. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index 8f124e8e604b..80d8ef1874f3 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -1,7 +1,7 @@ /* * Stuff used by all variants of the driver * - * Copyright (c) 2001 by Stefan Eilers , + * Copyright (c) 2001 by Stefan Eilers, * Hansjoerg Lipp , * Tilman Schmidt . * -- cgit v1.2.2 From 69049cc87dccb1e6fb54aa25c63033efac805dbd Mon Sep 17 00:00:00 2001 From: Tilman Schmidt Date: Mon, 10 Apr 2006 22:55:16 -0700 Subject: [PATCH] isdn4linux: Siemens Gigaset drivers: make some variables non-atomic With Hansjoerg Lipp Replace some atomic_t variables in the Gigaset drivers by non-atomic ones, using spinlocks instead to assure atomicity, as proposed in discussions on the linux-kernel mailing list. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/gigaset/proc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/isdn/gigaset/proc.c') diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index 80d8ef1874f3..d267a636b53c 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -19,8 +19,15 @@ static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf) { + int ret; + unsigned long flags; struct cardstate *cs = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); + + spin_lock_irqsave(&cs->lock, flags); + ret = sprintf(buf, "%u\n", cs->cidmode); + spin_unlock_irqrestore(&cs->lock, flags); + + return ret; } static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, -- cgit v1.2.2