diff options
author | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-02-28 18:42:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-02 06:10:25 -0500 |
commit | 8987691a4aa6622a1b58bb12c56abaf3d2098fad (patch) | |
tree | 92da0abdf6a29aa60ec5aff6250b1937d4c264d6 /drivers/net/wimax/i2400m/sysfs.c | |
parent | 6a0f7ab8305cb60a43a6c4a548f57adab784e6cd (diff) |
wimax/i2400m: allow control of the base-station idle mode timeout
For power saving reasons, WiMAX links can be put in idle mode while
connected after a certain time of the link not being used for tx or
rx. In this mode, the device pages the base-station regularly and when
data is ready to be transmitted, the link is revived.
This patch allows the user to control the time the device has to be
idle before it decides to go to idle mode from a sysfs
interace.
It also updates the initialization code to acknowledge the module
variable 'idle_mode_disabled' when the firmware is a newer version
(upcoming 1.4 vs 2.6.29's v1.3).
The method for setting the idle mode timeout in the older firmwares is
much more limited and can be only done at initialization time. Thus,
the sysfs file will return -ENOSYS on older ones.
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wimax/i2400m/sysfs.c')
-rw-r--r-- | drivers/net/wimax/i2400m/sysfs.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/drivers/net/wimax/i2400m/sysfs.c b/drivers/net/wimax/i2400m/sysfs.c new file mode 100644 index 000000000000..1237109f251a --- /dev/null +++ b/drivers/net/wimax/i2400m/sysfs.c | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * Intel Wireless WiMAX Connection 2400m | ||
3 | * Sysfs interfaces to show driver and device information | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com> | ||
7 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | ||
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 version | ||
11 | * 2 as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
21 | * 02110-1301, USA. | ||
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 | * Set the idle timeout (msecs) | ||
37 | * | ||
38 | * FIXME: eventually this should be a common WiMAX stack method, but | ||
39 | * would like to wait to see how other devices manage it. | ||
40 | */ | ||
41 | static | ||
42 | ssize_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; | ||
62 | error_no_unsigned: | ||
63 | error_bad_value: | ||
64 | return result; | ||
65 | } | ||
66 | |||
67 | static | ||
68 | DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR, | ||
69 | NULL, i2400m_idle_timeout_store); | ||
70 | |||
71 | static | ||
72 | struct attribute *i2400m_dev_attrs[] = { | ||
73 | &dev_attr_i2400m_idle_timeout.attr, | ||
74 | NULL, | ||
75 | }; | ||
76 | |||
77 | struct attribute_group i2400m_dev_attr_group = { | ||
78 | .name = NULL, /* we want them in the same directory */ | ||
79 | .attrs = i2400m_dev_attrs, | ||
80 | }; | ||