diff options
author | Eliad Peller <eliad@wizery.com> | 2011-04-17 04:20:47 -0400 |
---|---|---|
committer | Luciano Coelho <coelho@ti.com> | 2011-05-02 03:27:03 -0400 |
commit | 1fe9e2464c667903d7eec0314db26c462ca9d276 (patch) | |
tree | 6e78ac77f74168869d6c8fb8886c5a3868876b76 /drivers/net/wireless/wl12xx/debugfs.c | |
parent | 2370841bf1a735661db3d3ae63385be3475b7452 (diff) |
wl12xx: add debugfs entries for dtim_interval and beacon_interval
When configuring ACX_WAKE_UP_CONDITIONS (before entering psm), we
tell the firmware to wake up once in N DTIMs/beacons.
Allow control of this value via debugfs (for debugging purposes).
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/debugfs.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/debugfs.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 70ab1986788e..88c6efe33ecc 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c | |||
@@ -291,6 +291,136 @@ static const struct file_operations gpio_power_ops = { | |||
291 | .llseek = default_llseek, | 291 | .llseek = default_llseek, |
292 | }; | 292 | }; |
293 | 293 | ||
294 | static ssize_t dtim_interval_read(struct file *file, char __user *user_buf, | ||
295 | size_t count, loff_t *ppos) | ||
296 | { | ||
297 | struct wl1271 *wl = file->private_data; | ||
298 | u8 value; | ||
299 | |||
300 | if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_DTIM || | ||
301 | wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM) | ||
302 | value = wl->conf.conn.listen_interval; | ||
303 | else | ||
304 | value = 0; | ||
305 | |||
306 | return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value); | ||
307 | } | ||
308 | |||
309 | static ssize_t dtim_interval_write(struct file *file, | ||
310 | const char __user *user_buf, | ||
311 | size_t count, loff_t *ppos) | ||
312 | { | ||
313 | struct wl1271 *wl = file->private_data; | ||
314 | char buf[10]; | ||
315 | size_t len; | ||
316 | unsigned long value; | ||
317 | int ret; | ||
318 | |||
319 | len = min(count, sizeof(buf) - 1); | ||
320 | if (copy_from_user(buf, user_buf, len)) | ||
321 | return -EFAULT; | ||
322 | buf[len] = '\0'; | ||
323 | |||
324 | ret = strict_strtoul(buf, 0, &value); | ||
325 | if (ret < 0) { | ||
326 | wl1271_warning("illegal value for dtim_interval"); | ||
327 | return -EINVAL; | ||
328 | } | ||
329 | |||
330 | if (value < 1 || value > 10) { | ||
331 | wl1271_warning("dtim value is not in valid range"); | ||
332 | return -ERANGE; | ||
333 | } | ||
334 | |||
335 | mutex_lock(&wl->mutex); | ||
336 | |||
337 | wl->conf.conn.listen_interval = value; | ||
338 | /* for some reason there are different event types for 1 and >1 */ | ||
339 | if (value == 1) | ||
340 | wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_DTIM; | ||
341 | else | ||
342 | wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM; | ||
343 | |||
344 | /* | ||
345 | * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only | ||
346 | * take effect on the next time we enter psm. | ||
347 | */ | ||
348 | mutex_unlock(&wl->mutex); | ||
349 | return count; | ||
350 | } | ||
351 | |||
352 | static const struct file_operations dtim_interval_ops = { | ||
353 | .read = dtim_interval_read, | ||
354 | .write = dtim_interval_write, | ||
355 | .open = wl1271_open_file_generic, | ||
356 | .llseek = default_llseek, | ||
357 | }; | ||
358 | |||
359 | static ssize_t beacon_interval_read(struct file *file, char __user *user_buf, | ||
360 | size_t count, loff_t *ppos) | ||
361 | { | ||
362 | struct wl1271 *wl = file->private_data; | ||
363 | u8 value; | ||
364 | |||
365 | if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_BEACON || | ||
366 | wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_BEACONS) | ||
367 | value = wl->conf.conn.listen_interval; | ||
368 | else | ||
369 | value = 0; | ||
370 | |||
371 | return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value); | ||
372 | } | ||
373 | |||
374 | static ssize_t beacon_interval_write(struct file *file, | ||
375 | const char __user *user_buf, | ||
376 | size_t count, loff_t *ppos) | ||
377 | { | ||
378 | struct wl1271 *wl = file->private_data; | ||
379 | char buf[10]; | ||
380 | size_t len; | ||
381 | unsigned long value; | ||
382 | int ret; | ||
383 | |||
384 | len = min(count, sizeof(buf) - 1); | ||
385 | if (copy_from_user(buf, user_buf, len)) | ||
386 | return -EFAULT; | ||
387 | buf[len] = '\0'; | ||
388 | |||
389 | ret = strict_strtoul(buf, 0, &value); | ||
390 | if (ret < 0) { | ||
391 | wl1271_warning("illegal value for beacon_interval"); | ||
392 | return -EINVAL; | ||
393 | } | ||
394 | |||
395 | if (value < 1 || value > 255) { | ||
396 | wl1271_warning("beacon interval value is not in valid range"); | ||
397 | return -ERANGE; | ||
398 | } | ||
399 | |||
400 | mutex_lock(&wl->mutex); | ||
401 | |||
402 | wl->conf.conn.listen_interval = value; | ||
403 | /* for some reason there are different event types for 1 and >1 */ | ||
404 | if (value == 1) | ||
405 | wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_BEACON; | ||
406 | else | ||
407 | wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_BEACONS; | ||
408 | |||
409 | /* | ||
410 | * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only | ||
411 | * take effect on the next time we enter psm. | ||
412 | */ | ||
413 | mutex_unlock(&wl->mutex); | ||
414 | return count; | ||
415 | } | ||
416 | |||
417 | static const struct file_operations beacon_interval_ops = { | ||
418 | .read = beacon_interval_read, | ||
419 | .write = beacon_interval_write, | ||
420 | .open = wl1271_open_file_generic, | ||
421 | .llseek = default_llseek, | ||
422 | }; | ||
423 | |||
294 | static int wl1271_debugfs_add_files(struct wl1271 *wl, | 424 | static int wl1271_debugfs_add_files(struct wl1271 *wl, |
295 | struct dentry *rootdir) | 425 | struct dentry *rootdir) |
296 | { | 426 | { |
@@ -399,6 +529,8 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, | |||
399 | DEBUGFS_ADD(excessive_retries, rootdir); | 529 | DEBUGFS_ADD(excessive_retries, rootdir); |
400 | 530 | ||
401 | DEBUGFS_ADD(gpio_power, rootdir); | 531 | DEBUGFS_ADD(gpio_power, rootdir); |
532 | DEBUGFS_ADD(dtim_interval, rootdir); | ||
533 | DEBUGFS_ADD(beacon_interval, rootdir); | ||
402 | 534 | ||
403 | return 0; | 535 | return 0; |
404 | 536 | ||