i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / isdn / gigaset / proc.c
blobb943efbff44de05cff2efae9f017607c94123244
1 /*
2 * Stuff used by all variants of the driver
4 * Copyright (c) 2001 by Stefan Eilers,
5 * Hansjoerg Lipp <hjlipp@web.de>,
6 * Tilman Schmidt <tilman@imap.cc>.
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 * =====================================================================
16 #include "gigaset.h"
18 static ssize_t show_cidmode(struct device *dev,
19 struct device_attribute *attr, char *buf)
21 struct cardstate *cs = dev_get_drvdata(dev);
23 return sprintf(buf, "%u\n", cs->cidmode);
26 static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
27 const char *buf, size_t count)
29 struct cardstate *cs = dev_get_drvdata(dev);
30 long int value;
31 char *end;
33 value = simple_strtol(buf, &end, 0);
34 while (*end)
35 if (!isspace(*end++))
36 return -EINVAL;
37 if (value < 0 || value > 1)
38 return -EINVAL;
40 if (mutex_lock_interruptible(&cs->mutex))
41 return -ERESTARTSYS;
43 cs->waiting = 1;
44 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
45 NULL, value, NULL)) {
46 cs->waiting = 0;
47 mutex_unlock(&cs->mutex);
48 return -ENOMEM;
50 gigaset_schedule_event(cs);
52 wait_event(cs->waitqueue, !cs->waiting);
54 mutex_unlock(&cs->mutex);
56 return count;
59 static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
61 /* free sysfs for device */
62 void gigaset_free_dev_sysfs(struct cardstate *cs)
64 if (!cs->tty_dev)
65 return;
67 gig_dbg(DEBUG_INIT, "removing sysfs entries");
68 device_remove_file(cs->tty_dev, &dev_attr_cidmode);
71 /* initialize sysfs for device */
72 void gigaset_init_dev_sysfs(struct cardstate *cs)
74 if (!cs->tty_dev)
75 return;
77 gig_dbg(DEBUG_INIT, "setting up sysfs");
78 if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
79 pr_err("could not create sysfs attribute\n");