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 * =====================================================================
17 #include <linux/ctype.h>
19 static ssize_t show_cidmode(struct class_device *class, char *buf)
23 struct cardstate *cs = class_get_devdata(class);
25 spin_lock_irqsave(&cs->lock, flags);
26 ret = sprintf(buf, "%u\n", cs->cidmode);
27 spin_unlock_irqrestore(&cs->lock, flags);
32 static ssize_t set_cidmode(struct class_device *class,
33 const char *buf, size_t count)
35 struct cardstate *cs = class_get_devdata(class);
39 value = simple_strtol(buf, &end, 0);
43 if (value < 0 || value > 1)
46 if (mutex_lock_interruptible(&cs->mutex))
47 return -ERESTARTSYS; // FIXME -EINTR?
50 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
53 mutex_unlock(&cs->mutex);
57 gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
58 gigaset_schedule_event(cs);
60 wait_event(cs->waitqueue, !cs->waiting);
62 mutex_unlock(&cs->mutex);
67 static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
69 /* free sysfs for device */
70 void gigaset_free_dev_sysfs(struct cardstate *cs)
75 gig_dbg(DEBUG_INIT, "removing sysfs entries");
76 class_device_remove_file(cs->class, &class_device_attr_cidmode);
79 /* initialize sysfs for device */
80 void gigaset_init_dev_sysfs(struct cardstate *cs)
85 gig_dbg(DEBUG_INIT, "setting up sysfs");
86 class_device_create_file(cs->class, &class_device_attr_cidmode);