1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/spinlock.h>
27#include <linux/device.h>
28#include "i2400m.h"
29
30
31#define D_SUBMODULE sysfs
32#include "debug-levels.h"
33
34
35
36
37
38
39
40
41static
42ssize_t i2400m_idle_timeout_store(struct device *dev,
43 struct device_attribute *attr,
44 const char *buf, size_t size)
45{
46 ssize_t result;
47 struct i2400m *i2400m = net_dev_to_i2400m(to_net_dev(dev));
48 unsigned val;
49
50 result = -EINVAL;
51 if (sscanf(buf, "%u\n", &val) != 1)
52 goto error_no_unsigned;
53 if (val != 0 && (val < 100 || val > 300000 || val % 100 != 0)) {
54 dev_err(dev, "idle_timeout: %u: invalid msecs specification; "
55 "valid values are 0, 100-300000 in 100 increments\n",
56 val);
57 goto error_bad_value;
58 }
59 result = i2400m_set_idle_timeout(i2400m, val);
60 if (result >= 0)
61 result = size;
62error_no_unsigned:
63error_bad_value:
64 return result;
65}
66
67static
68DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR,
69 NULL, i2400m_idle_timeout_store);
70
71static
72struct attribute *i2400m_dev_attrs[] = {
73 &dev_attr_i2400m_idle_timeout.attr,
74 NULL,
75};
76
77struct attribute_group i2400m_dev_attr_group = {
78 .name = NULL,
79 .attrs = i2400m_dev_attrs,
80};
81