diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/wireless/wl12xx/wl1271_debugfs.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_debugfs.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_debugfs.c | 63 |
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 | ||
241 | static 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 | |||
255 | static 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 | |||
288 | out: | ||
289 | mutex_unlock(&wl->mutex); | ||
290 | return count; | ||
291 | } | ||
292 | |||
293 | static 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 | |||
240 | static void wl1271_debugfs_delete_files(struct wl1271 *wl) | 299 | static 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 | ||
338 | static int wl1271_debugfs_add_files(struct wl1271 *wl) | 399 | static 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 | |||
437 | out: | 500 | out: |
438 | if (ret < 0) | 501 | if (ret < 0) |
439 | wl1271_debugfs_delete_files(wl); | 502 | wl1271_debugfs_delete_files(wl); |