aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_debugfs.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_debugfs.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
index c1805e5f8964..3f7ff8d0cf5a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
@@ -24,6 +24,7 @@
24#include "wl1271_debugfs.h" 24#include "wl1271_debugfs.h"
25 25
26#include <linux/skbuff.h> 26#include <linux/skbuff.h>
27#include <linux/slab.h>
27 28
28#include "wl1271.h" 29#include "wl1271.h"
29#include "wl1271_acx.h" 30#include "wl1271_acx.h"
@@ -237,6 +238,64 @@ static const struct file_operations tx_queue_len_ops = {
237 .open = wl1271_open_file_generic, 238 .open = wl1271_open_file_generic,
238}; 239};
239 240
241static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
242 size_t count, loff_t *ppos)
243{
244 struct wl1271 *wl = file->private_data;
245 bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
246
247 int res;
248 char buf[10];
249
250 res = scnprintf(buf, sizeof(buf), "%d\n", state);
251
252 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
253}
254
255static ssize_t gpio_power_write(struct file *file,
256 const char __user *user_buf,
257 size_t count, loff_t *ppos)
258{
259 struct wl1271 *wl = file->private_data;
260 char buf[10];
261 size_t len;
262 unsigned long value;
263 int ret;
264
265 mutex_lock(&wl->mutex);
266
267 len = min(count, sizeof(buf) - 1);
268 if (copy_from_user(buf, user_buf, len)) {
269 ret = -EFAULT;
270 goto out;
271 }
272 buf[len] = '\0';
273
274 ret = strict_strtoul(buf, 0, &value);
275 if (ret < 0) {
276 wl1271_warning("illegal value in gpio_power");
277 goto out;
278 }
279
280 if (value) {
281 wl->set_power(true);
282 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
283 } else {
284 wl->set_power(false);
285 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
286 }
287
288out:
289 mutex_unlock(&wl->mutex);
290 return count;
291}
292
293static const struct file_operations gpio_power_ops = {
294 .read = gpio_power_read,
295 .write = gpio_power_write,
296 .open = wl1271_open_file_generic
297};
298
240static void wl1271_debugfs_delete_files(struct wl1271 *wl) 299static void wl1271_debugfs_delete_files(struct wl1271 *wl)
241{ 300{
242 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); 301 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
@@ -333,6 +392,8 @@ static void wl1271_debugfs_delete_files(struct wl1271 *wl)
333 DEBUGFS_DEL(tx_queue_len); 392 DEBUGFS_DEL(tx_queue_len);
334 DEBUGFS_DEL(retry_count); 393 DEBUGFS_DEL(retry_count);
335 DEBUGFS_DEL(excessive_retries); 394 DEBUGFS_DEL(excessive_retries);
395
396 DEBUGFS_DEL(gpio_power);
336} 397}
337 398
338static int wl1271_debugfs_add_files(struct wl1271 *wl) 399static int wl1271_debugfs_add_files(struct wl1271 *wl)
@@ -434,6 +495,8 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl)
434 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir); 495 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
435 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir); 496 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
436 497
498 DEBUGFS_ADD(gpio_power, wl->debugfs.rootdir);
499
437out: 500out:
438 if (ret < 0) 501 if (ret < 0)
439 wl1271_debugfs_delete_files(wl); 502 wl1271_debugfs_delete_files(wl);