aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/debugfs.c
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2010-07-07 21:13:48 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-07-12 16:05:31 -0400
commit1311843c58ca606bab8bfe4cf6c0fe50deb9986d (patch)
treef716fbf88c163e33ef622ecb5e9c1d37df006bc7 /drivers/net/wireless/libertas/debugfs.c
parent643f82e32f14faf0d0944c804203a6681b6b0a1e (diff)
libertas: Added support for host sleep feature
Existing "ethtool -s ethX wol X" command configures hostsleep parameters, but those are activated only during suspend/resume, there is no way to configure host sleep without actual suspend. This patch adds debugfs command to enable/disable host sleep based on already configured host sleep parameters using wol command. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Kiran Divekar <dkiran@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/debugfs.c')
-rw-r--r--drivers/net/wireless/libertas/debugfs.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 17367463c855..acaf81164624 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -124,6 +124,70 @@ out_unlock:
124 return ret; 124 return ret;
125} 125}
126 126
127static ssize_t lbs_host_sleep_write(struct file *file,
128 const char __user *user_buf, size_t count,
129 loff_t *ppos)
130{
131 struct lbs_private *priv = file->private_data;
132 ssize_t buf_size, ret;
133 int host_sleep;
134 unsigned long addr = get_zeroed_page(GFP_KERNEL);
135 char *buf = (char *)addr;
136 if (!buf)
137 return -ENOMEM;
138
139 buf_size = min(count, len - 1);
140 if (copy_from_user(buf, user_buf, buf_size)) {
141 ret = -EFAULT;
142 goto out_unlock;
143 }
144 ret = sscanf(buf, "%d", &host_sleep);
145 if (ret != 1) {
146 ret = -EINVAL;
147 goto out_unlock;
148 }
149
150 if (host_sleep == 0)
151 ret = lbs_set_host_sleep(priv, 0);
152 else if (host_sleep == 1) {
153 if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
154 lbs_pr_info("wake parameters not configured");
155 ret = -EINVAL;
156 goto out_unlock;
157 }
158 ret = lbs_set_host_sleep(priv, 1);
159 } else {
160 lbs_pr_err("invalid option\n");
161 ret = -EINVAL;
162 }
163
164 if (!ret)
165 ret = count;
166
167out_unlock:
168 free_page(addr);
169 return ret;
170}
171
172static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
173 size_t count, loff_t *ppos)
174{
175 struct lbs_private *priv = file->private_data;
176 ssize_t ret;
177 size_t pos = 0;
178 unsigned long addr = get_zeroed_page(GFP_KERNEL);
179 char *buf = (char *)addr;
180 if (!buf)
181 return -ENOMEM;
182
183 pos += snprintf(buf, len, "%d\n", priv->is_host_sleep_activated);
184
185 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
186
187 free_page(addr);
188 return ret;
189}
190
127/* 191/*
128 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might 192 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might
129 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the 193 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the
@@ -675,6 +739,8 @@ static const struct lbs_debugfs_files debugfs_files[] = {
675 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), }, 739 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), },
676 { "sleepparams", 0644, FOPS(lbs_sleepparams_read, 740 { "sleepparams", 0644, FOPS(lbs_sleepparams_read,
677 lbs_sleepparams_write), }, 741 lbs_sleepparams_write), },
742 { "hostsleep", 0644, FOPS(lbs_host_sleep_read,
743 lbs_host_sleep_write), },
678}; 744};
679 745
680static const struct lbs_debugfs_files debugfs_events_files[] = { 746static const struct lbs_debugfs_files debugfs_events_files[] = {