]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/isdn/gigaset/proc.c
Merge branch 'stable/for-linus-4.6' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-artful-kernel.git] / drivers / isdn / gigaset / proc.c
CommitLineData
982da5a1
HL
1/*
2 * Stuff used by all variants of the driver
3 *
70440cf2 4 * Copyright (c) 2001 by Stefan Eilers,
982da5a1
HL
5 * Hansjoerg Lipp <hjlipp@web.de>,
6 * Tilman Schmidt <tilman@imap.cc>.
7 *
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 * =====================================================================
982da5a1
HL
14 */
15
16#include "gigaset.h"
982da5a1 17
01107d34
GKH
18static ssize_t show_cidmode(struct device *dev,
19 struct device_attribute *attr, char *buf)
982da5a1 20{
01107d34 21 struct cardstate *cs = dev_get_drvdata(dev);
69049cc8 22
4d1ff582 23 return sprintf(buf, "%u\n", cs->cidmode);
982da5a1
HL
24}
25
01107d34 26static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
917f5085 27 const char *buf, size_t count)
982da5a1 28{
01107d34 29 struct cardstate *cs = dev_get_drvdata(dev);
982da5a1
HL
30 long int value;
31 char *end;
32
33 value = simple_strtol(buf, &end, 0);
34 while (*end)
35 if (!isspace(*end++))
36 return -EINVAL;
37 if (value < 0 || value > 1)
475be4d8 38 return -EINVAL;
982da5a1 39
abfd1dc7 40 if (mutex_lock_interruptible(&cs->mutex))
d9ba9c91 41 return -ERESTARTSYS;
982da5a1
HL
42
43 cs->waiting = 1;
44 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
784d5858 45 NULL, value, NULL)) {
982da5a1 46 cs->waiting = 0;
abfd1dc7 47 mutex_unlock(&cs->mutex);
982da5a1
HL
48 return -ENOMEM;
49 }
982da5a1
HL
50 gigaset_schedule_event(cs);
51
52 wait_event(cs->waitqueue, !cs->waiting);
53
abfd1dc7 54 mutex_unlock(&cs->mutex);
982da5a1
HL
55
56 return count;
57}
58
475be4d8 59static DEVICE_ATTR(cidmode, S_IRUGO | S_IWUSR, show_cidmode, set_cidmode);
982da5a1
HL
60
61/* free sysfs for device */
b1d47464 62void gigaset_free_dev_sysfs(struct cardstate *cs)
982da5a1 63{
01107d34 64 if (!cs->tty_dev)
3dda4e37
HL
65 return;
66
784d5858 67 gig_dbg(DEBUG_INIT, "removing sysfs entries");
01107d34 68 device_remove_file(cs->tty_dev, &dev_attr_cidmode);
982da5a1 69}
982da5a1
HL
70
71/* initialize sysfs for device */
b1d47464 72void gigaset_init_dev_sysfs(struct cardstate *cs)
982da5a1 73{
01107d34 74 if (!cs->tty_dev)
3dda4e37
HL
75 return;
76
784d5858 77 gig_dbg(DEBUG_INIT, "setting up sysfs");
01107d34 78 if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
42e3d611 79 pr_err("could not create sysfs attribute\n");
982da5a1 80}