-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 24120 b: refs/heads/master c: 982da5a h: refs/heads/master v: v3
- Loading branch information
Hansjoerg Lipp
authored and
Linus Torvalds
committed
Mar 26, 2006
1 parent
740f25c
commit 6044dca
Showing
2 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: ee8a4b7f857fe7ba243e65c8925798cf8eda5ab0 | ||
refs/heads/master: 982da5a196a0859eedc5ca1ff88feaf1bc6d6e4e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Stuff used by all variants of the driver | ||
* | ||
* Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>, | ||
* Hansjoerg Lipp <hjlipp@web.de>, | ||
* Tilman Schmidt <tilman@imap.cc>. | ||
* | ||
* ===================================================================== | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* 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 <linux/ctype.h> | ||
|
||
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) | ||
} | ||
|
||
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); | ||
long int value; | ||
char *end; | ||
|
||
value = simple_strtol(buf, &end, 0); | ||
while (*end) | ||
if (!isspace(*end++)) | ||
return -EINVAL; | ||
if (value < 0 || value > 1) | ||
return -EINVAL; | ||
|
||
if (down_interruptible(&cs->sem)) | ||
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); | ||
return -ENOMEM; | ||
} | ||
|
||
dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); | ||
gigaset_schedule_event(cs); | ||
|
||
wait_event(cs->waitqueue, !cs->waiting); | ||
|
||
up(&cs->sem); | ||
|
||
return count; | ||
} | ||
|
||
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"); | ||
device_remove_file(&interface->dev, &dev_attr_cidmode); | ||
} | ||
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"); | ||
device_create_file(&interface->dev, &dev_attr_cidmode); | ||
} | ||
EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); |