diff options
author | Karl Hiramoto <karl@hiramoto.org> | 2010-07-08 16:55:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-09 03:09:21 -0400 |
commit | c69fb76e8f53b36b81fd7c8a1ed251aaf6bb0386 (patch) | |
tree | 73808e42a51273fec5034892237a3c374417fa5f /drivers/atm/adummy.c | |
parent | 005066122b58f3b350736cc896af46aea2e32d23 (diff) |
atm/adummy: add syfs DEVICE_ATTR to change signal
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/adummy.c')
-rw-r--r-- | drivers/atm/adummy.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c index 6d44f07b69f8..46b94762125b 100644 --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c | |||
@@ -40,6 +40,42 @@ struct adummy_dev { | |||
40 | 40 | ||
41 | static LIST_HEAD(adummy_devs); | 41 | static LIST_HEAD(adummy_devs); |
42 | 42 | ||
43 | static ssize_t __set_signal(struct device *dev, | ||
44 | struct device_attribute *attr, | ||
45 | const char *buf, size_t len) | ||
46 | { | ||
47 | struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev); | ||
48 | int signal; | ||
49 | |||
50 | if (sscanf(buf, "%d", &signal) == 1) { | ||
51 | |||
52 | if (signal < ATM_PHY_SIG_LOST || signal > ATM_PHY_SIG_FOUND) | ||
53 | signal = ATM_PHY_SIG_UNKNOWN; | ||
54 | |||
55 | atm_dev_signal_change(atm_dev, signal); | ||
56 | return 1; | ||
57 | } | ||
58 | return -EINVAL; | ||
59 | } | ||
60 | |||
61 | static ssize_t __show_signal(struct device *dev, | ||
62 | struct device_attribute *attr, char *buf) | ||
63 | { | ||
64 | struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev); | ||
65 | return sprintf(buf, "%d\n", atm_dev->signal); | ||
66 | } | ||
67 | static DEVICE_ATTR(signal, 0644, __show_signal, __set_signal); | ||
68 | |||
69 | static struct attribute *adummy_attrs[] = { | ||
70 | &dev_attr_signal.attr, | ||
71 | NULL | ||
72 | }; | ||
73 | |||
74 | static struct attribute_group adummy_group_attrs = { | ||
75 | .name = NULL, /* We want them in dev's root folder */ | ||
76 | .attrs = adummy_attrs | ||
77 | }; | ||
78 | |||
43 | static int __init | 79 | static int __init |
44 | adummy_start(struct atm_dev *dev) | 80 | adummy_start(struct atm_dev *dev) |
45 | { | 81 | { |
@@ -128,6 +164,9 @@ static int __init adummy_init(void) | |||
128 | adummy_dev->atm_dev = atm_dev; | 164 | adummy_dev->atm_dev = atm_dev; |
129 | atm_dev->dev_data = adummy_dev; | 165 | atm_dev->dev_data = adummy_dev; |
130 | 166 | ||
167 | if (sysfs_create_group(&atm_dev->class_dev.kobj, &adummy_group_attrs)) | ||
168 | dev_err(&atm_dev->class_dev, "Could not register attrs for adummy\n"); | ||
169 | |||
131 | if (adummy_start(atm_dev)) { | 170 | if (adummy_start(atm_dev)) { |
132 | printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n"); | 171 | printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n"); |
133 | err = -ENODEV; | 172 | err = -ENODEV; |