diff options
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 315 |
1 files changed, 172 insertions, 143 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 70745928f3f8..71c8f3fccfa1 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /** | 1 | /* |
2 | * This file contains the handling of command. | 2 | * This file contains the handling of command. |
3 | * It prepares command and sends it to firmware when it is ready. | 3 | * It prepares command and sends it to firmware when it is ready. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/kfifo.h> | 6 | #include <linux/kfifo.h> |
7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
@@ -16,14 +16,14 @@ | |||
16 | #define CAL_RSSI(snr, nf) ((s32)((s32)(snr) + CAL_NF(nf))) | 16 | #define CAL_RSSI(snr, nf) ((s32)((s32)(snr) + CAL_NF(nf))) |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * @brief Simple callback that copies response back into command | 19 | * lbs_cmd_copyback - Simple callback that copies response back into command |
20 | * | 20 | * |
21 | * @param priv A pointer to struct lbs_private structure | 21 | * @priv: A pointer to &struct lbs_private structure |
22 | * @param extra A pointer to the original command structure for which | 22 | * @extra: A pointer to the original command structure for which |
23 | * 'resp' is a response | 23 | * 'resp' is a response |
24 | * @param resp A pointer to the command response | 24 | * @resp: A pointer to the command response |
25 | * | 25 | * |
26 | * @return 0 on success, error on failure | 26 | * returns: 0 on success, error on failure |
27 | */ | 27 | */ |
28 | int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, | 28 | int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, |
29 | struct cmd_header *resp) | 29 | struct cmd_header *resp) |
@@ -38,15 +38,15 @@ int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, | |||
38 | EXPORT_SYMBOL_GPL(lbs_cmd_copyback); | 38 | EXPORT_SYMBOL_GPL(lbs_cmd_copyback); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @brief Simple callback that ignores the result. Use this if | 41 | * lbs_cmd_async_callback - Simple callback that ignores the result. |
42 | * you just want to send a command to the hardware, but don't | 42 | * Use this if you just want to send a command to the hardware, but don't |
43 | * care for the result. | 43 | * care for the result. |
44 | * | 44 | * |
45 | * @param priv ignored | 45 | * @priv: ignored |
46 | * @param extra ignored | 46 | * @extra: ignored |
47 | * @param resp ignored | 47 | * @resp: ignored |
48 | * | 48 | * |
49 | * @return 0 for success | 49 | * returns: 0 for success |
50 | */ | 50 | */ |
51 | static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra, | 51 | static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra, |
52 | struct cmd_header *resp) | 52 | struct cmd_header *resp) |
@@ -56,10 +56,11 @@ static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra, | |||
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
59 | * @brief Checks whether a command is allowed in Power Save mode | 59 | * is_command_allowed_in_ps - tests if a command is allowed in Power Save mode |
60 | * | ||
61 | * @cmd: the command ID | ||
60 | * | 62 | * |
61 | * @param command the command ID | 63 | * returns: 1 if allowed, 0 if not allowed |
62 | * @return 1 if allowed, 0 if not allowed | ||
63 | */ | 64 | */ |
64 | static u8 is_command_allowed_in_ps(u16 cmd) | 65 | static u8 is_command_allowed_in_ps(u16 cmd) |
65 | { | 66 | { |
@@ -75,11 +76,12 @@ static u8 is_command_allowed_in_ps(u16 cmd) | |||
75 | } | 76 | } |
76 | 77 | ||
77 | /** | 78 | /** |
78 | * @brief Updates the hardware details like MAC address and regulatory region | 79 | * lbs_update_hw_spec - Updates the hardware details like MAC address |
80 | * and regulatory region | ||
79 | * | 81 | * |
80 | * @param priv A pointer to struct lbs_private structure | 82 | * @priv: A pointer to &struct lbs_private structure |
81 | * | 83 | * |
82 | * @return 0 on success, error on failure | 84 | * returns: 0 on success, error on failure |
83 | */ | 85 | */ |
84 | int lbs_update_hw_spec(struct lbs_private *priv) | 86 | int lbs_update_hw_spec(struct lbs_private *priv) |
85 | { | 87 | { |
@@ -108,7 +110,7 @@ int lbs_update_hw_spec(struct lbs_private *priv) | |||
108 | * CF card firmware 5.0.16p0: cap 0x00000303 | 110 | * CF card firmware 5.0.16p0: cap 0x00000303 |
109 | * USB dongle firmware 5.110.17p2: cap 0x00000303 | 111 | * USB dongle firmware 5.110.17p2: cap 0x00000303 |
110 | */ | 112 | */ |
111 | lbs_pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n", | 113 | netdev_info(priv->dev, "%pM, fw %u.%u.%up%u, cap 0x%08x\n", |
112 | cmd.permanentaddr, | 114 | cmd.permanentaddr, |
113 | priv->fwrelease >> 24 & 0xff, | 115 | priv->fwrelease >> 24 & 0xff, |
114 | priv->fwrelease >> 16 & 0xff, | 116 | priv->fwrelease >> 16 & 0xff, |
@@ -139,15 +141,20 @@ int lbs_update_hw_spec(struct lbs_private *priv) | |||
139 | /* if it's unidentified region code, use the default (USA) */ | 141 | /* if it's unidentified region code, use the default (USA) */ |
140 | if (i >= MRVDRV_MAX_REGION_CODE) { | 142 | if (i >= MRVDRV_MAX_REGION_CODE) { |
141 | priv->regioncode = 0x10; | 143 | priv->regioncode = 0x10; |
142 | lbs_pr_info("unidentified region code; using the default (USA)\n"); | 144 | netdev_info(priv->dev, |
145 | "unidentified region code; using the default (USA)\n"); | ||
143 | } | 146 | } |
144 | 147 | ||
145 | if (priv->current_addr[0] == 0xff) | 148 | if (priv->current_addr[0] == 0xff) |
146 | memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); | 149 | memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); |
147 | 150 | ||
148 | memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN); | 151 | if (!priv->copied_hwaddr) { |
149 | if (priv->mesh_dev) | 152 | memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN); |
150 | memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN); | 153 | if (priv->mesh_dev) |
154 | memcpy(priv->mesh_dev->dev_addr, | ||
155 | priv->current_addr, ETH_ALEN); | ||
156 | priv->copied_hwaddr = 1; | ||
157 | } | ||
151 | 158 | ||
152 | out: | 159 | out: |
153 | lbs_deb_leave(LBS_DEB_CMD); | 160 | lbs_deb_leave(LBS_DEB_CMD); |
@@ -177,6 +184,14 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria, | |||
177 | struct cmd_ds_host_sleep cmd_config; | 184 | struct cmd_ds_host_sleep cmd_config; |
178 | int ret; | 185 | int ret; |
179 | 186 | ||
187 | /* | ||
188 | * Certain firmware versions do not support EHS_REMOVE_WAKEUP command | ||
189 | * and the card will return a failure. Since we need to be | ||
190 | * able to reset the mask, in those cases we set a 0 mask instead. | ||
191 | */ | ||
192 | if (criteria == EHS_REMOVE_WAKEUP && !priv->ehs_remove_supported) | ||
193 | criteria = 0; | ||
194 | |||
180 | cmd_config.hdr.size = cpu_to_le16(sizeof(cmd_config)); | 195 | cmd_config.hdr.size = cpu_to_le16(sizeof(cmd_config)); |
181 | cmd_config.criteria = cpu_to_le32(criteria); | 196 | cmd_config.criteria = cpu_to_le32(criteria); |
182 | cmd_config.gpio = priv->wol_gpio; | 197 | cmd_config.gpio = priv->wol_gpio; |
@@ -197,7 +212,7 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria, | |||
197 | (uint8_t *)&cmd_config.wol_conf, | 212 | (uint8_t *)&cmd_config.wol_conf, |
198 | sizeof(struct wol_config)); | 213 | sizeof(struct wol_config)); |
199 | } else { | 214 | } else { |
200 | lbs_pr_info("HOST_SLEEP_CFG failed %d\n", ret); | 215 | netdev_info(priv->dev, "HOST_SLEEP_CFG failed %d\n", ret); |
201 | } | 216 | } |
202 | 217 | ||
203 | return ret; | 218 | return ret; |
@@ -205,14 +220,14 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria, | |||
205 | EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg); | 220 | EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg); |
206 | 221 | ||
207 | /** | 222 | /** |
208 | * @brief Sets the Power Save mode | 223 | * lbs_set_ps_mode - Sets the Power Save mode |
209 | * | 224 | * |
210 | * @param priv A pointer to struct lbs_private structure | 225 | * @priv: A pointer to &struct lbs_private structure |
211 | * @param cmd_action The Power Save operation (PS_MODE_ACTION_ENTER_PS or | 226 | * @cmd_action: The Power Save operation (PS_MODE_ACTION_ENTER_PS or |
212 | * PS_MODE_ACTION_EXIT_PS) | 227 | * PS_MODE_ACTION_EXIT_PS) |
213 | * @param block Whether to block on a response or not | 228 | * @block: Whether to block on a response or not |
214 | * | 229 | * |
215 | * @return 0 on success, error on failure | 230 | * returns: 0 on success, error on failure |
216 | */ | 231 | */ |
217 | int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block) | 232 | int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block) |
218 | { | 233 | { |
@@ -300,7 +315,7 @@ static int lbs_wait_for_ds_awake(struct lbs_private *priv) | |||
300 | if (priv->is_deep_sleep) { | 315 | if (priv->is_deep_sleep) { |
301 | if (!wait_event_interruptible_timeout(priv->ds_awake_q, | 316 | if (!wait_event_interruptible_timeout(priv->ds_awake_q, |
302 | !priv->is_deep_sleep, (10 * HZ))) { | 317 | !priv->is_deep_sleep, (10 * HZ))) { |
303 | lbs_pr_err("ds_awake_q: timer expired\n"); | 318 | netdev_err(priv->dev, "ds_awake_q: timer expired\n"); |
304 | ret = -1; | 319 | ret = -1; |
305 | } | 320 | } |
306 | } | 321 | } |
@@ -325,7 +340,7 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep) | |||
325 | netif_carrier_off(priv->dev); | 340 | netif_carrier_off(priv->dev); |
326 | } | 341 | } |
327 | } else { | 342 | } else { |
328 | lbs_pr_err("deep sleep: already enabled\n"); | 343 | netdev_err(priv->dev, "deep sleep: already enabled\n"); |
329 | } | 344 | } |
330 | } else { | 345 | } else { |
331 | if (priv->is_deep_sleep) { | 346 | if (priv->is_deep_sleep) { |
@@ -335,8 +350,8 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep) | |||
335 | if (!ret) { | 350 | if (!ret) { |
336 | ret = lbs_wait_for_ds_awake(priv); | 351 | ret = lbs_wait_for_ds_awake(priv); |
337 | if (ret) | 352 | if (ret) |
338 | lbs_pr_err("deep sleep: wakeup" | 353 | netdev_err(priv->dev, |
339 | "failed\n"); | 354 | "deep sleep: wakeup failed\n"); |
340 | } | 355 | } |
341 | } | 356 | } |
342 | } | 357 | } |
@@ -370,8 +385,9 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep) | |||
370 | ret = lbs_host_sleep_cfg(priv, priv->wol_criteria, | 385 | ret = lbs_host_sleep_cfg(priv, priv->wol_criteria, |
371 | (struct wol_config *)NULL); | 386 | (struct wol_config *)NULL); |
372 | if (ret) { | 387 | if (ret) { |
373 | lbs_pr_info("Host sleep configuration failed: " | 388 | netdev_info(priv->dev, |
374 | "%d\n", ret); | 389 | "Host sleep configuration failed: %d\n", |
390 | ret); | ||
375 | return ret; | 391 | return ret; |
376 | } | 392 | } |
377 | if (priv->psstate == PS_STATE_FULL_POWER) { | 393 | if (priv->psstate == PS_STATE_FULL_POWER) { |
@@ -381,19 +397,21 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep) | |||
381 | sizeof(cmd), | 397 | sizeof(cmd), |
382 | lbs_ret_host_sleep_activate, 0); | 398 | lbs_ret_host_sleep_activate, 0); |
383 | if (ret) | 399 | if (ret) |
384 | lbs_pr_info("HOST_SLEEP_ACTIVATE " | 400 | netdev_info(priv->dev, |
385 | "failed: %d\n", ret); | 401 | "HOST_SLEEP_ACTIVATE failed: %d\n", |
402 | ret); | ||
386 | } | 403 | } |
387 | 404 | ||
388 | if (!wait_event_interruptible_timeout( | 405 | if (!wait_event_interruptible_timeout( |
389 | priv->host_sleep_q, | 406 | priv->host_sleep_q, |
390 | priv->is_host_sleep_activated, | 407 | priv->is_host_sleep_activated, |
391 | (10 * HZ))) { | 408 | (10 * HZ))) { |
392 | lbs_pr_err("host_sleep_q: timer expired\n"); | 409 | netdev_err(priv->dev, |
410 | "host_sleep_q: timer expired\n"); | ||
393 | ret = -1; | 411 | ret = -1; |
394 | } | 412 | } |
395 | } else { | 413 | } else { |
396 | lbs_pr_err("host sleep: already enabled\n"); | 414 | netdev_err(priv->dev, "host sleep: already enabled\n"); |
397 | } | 415 | } |
398 | } else { | 416 | } else { |
399 | if (priv->is_host_sleep_activated) | 417 | if (priv->is_host_sleep_activated) |
@@ -405,13 +423,13 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep) | |||
405 | } | 423 | } |
406 | 424 | ||
407 | /** | 425 | /** |
408 | * @brief Set an SNMP MIB value | 426 | * lbs_set_snmp_mib - Set an SNMP MIB value |
409 | * | 427 | * |
410 | * @param priv A pointer to struct lbs_private structure | 428 | * @priv: A pointer to &struct lbs_private structure |
411 | * @param oid The OID to set in the firmware | 429 | * @oid: The OID to set in the firmware |
412 | * @param val Value to set the OID to | 430 | * @val: Value to set the OID to |
413 | * | 431 | * |
414 | * @return 0 on success, error on failure | 432 | * returns: 0 on success, error on failure |
415 | */ | 433 | */ |
416 | int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val) | 434 | int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val) |
417 | { | 435 | { |
@@ -455,13 +473,13 @@ out: | |||
455 | } | 473 | } |
456 | 474 | ||
457 | /** | 475 | /** |
458 | * @brief Get an SNMP MIB value | 476 | * lbs_get_snmp_mib - Get an SNMP MIB value |
459 | * | 477 | * |
460 | * @param priv A pointer to struct lbs_private structure | 478 | * @priv: A pointer to &struct lbs_private structure |
461 | * @param oid The OID to retrieve from the firmware | 479 | * @oid: The OID to retrieve from the firmware |
462 | * @param out_val Location for the returned value | 480 | * @out_val: Location for the returned value |
463 | * | 481 | * |
464 | * @return 0 on success, error on failure | 482 | * returns: 0 on success, error on failure |
465 | */ | 483 | */ |
466 | int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val) | 484 | int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val) |
467 | { | 485 | { |
@@ -498,14 +516,14 @@ out: | |||
498 | } | 516 | } |
499 | 517 | ||
500 | /** | 518 | /** |
501 | * @brief Get the min, max, and current TX power | 519 | * lbs_get_tx_power - Get the min, max, and current TX power |
502 | * | 520 | * |
503 | * @param priv A pointer to struct lbs_private structure | 521 | * @priv: A pointer to &struct lbs_private structure |
504 | * @param curlevel Current power level in dBm | 522 | * @curlevel: Current power level in dBm |
505 | * @param minlevel Minimum supported power level in dBm (optional) | 523 | * @minlevel: Minimum supported power level in dBm (optional) |
506 | * @param maxlevel Maximum supported power level in dBm (optional) | 524 | * @maxlevel: Maximum supported power level in dBm (optional) |
507 | * | 525 | * |
508 | * @return 0 on success, error on failure | 526 | * returns: 0 on success, error on failure |
509 | */ | 527 | */ |
510 | int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, | 528 | int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, |
511 | s16 *maxlevel) | 529 | s16 *maxlevel) |
@@ -533,12 +551,12 @@ int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, | |||
533 | } | 551 | } |
534 | 552 | ||
535 | /** | 553 | /** |
536 | * @brief Set the TX power | 554 | * lbs_set_tx_power - Set the TX power |
537 | * | 555 | * |
538 | * @param priv A pointer to struct lbs_private structure | 556 | * @priv: A pointer to &struct lbs_private structure |
539 | * @param dbm The desired power level in dBm | 557 | * @dbm: The desired power level in dBm |
540 | * | 558 | * |
541 | * @return 0 on success, error on failure | 559 | * returns: 0 on success, error on failure |
542 | */ | 560 | */ |
543 | int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) | 561 | int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) |
544 | { | 562 | { |
@@ -561,12 +579,13 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) | |||
561 | } | 579 | } |
562 | 580 | ||
563 | /** | 581 | /** |
564 | * @brief Enable or disable monitor mode (only implemented on OLPC usb8388 FW) | 582 | * lbs_set_monitor_mode - Enable or disable monitor mode |
583 | * (only implemented on OLPC usb8388 FW) | ||
565 | * | 584 | * |
566 | * @param priv A pointer to struct lbs_private structure | 585 | * @priv: A pointer to &struct lbs_private structure |
567 | * @param enable 1 to enable monitor mode, 0 to disable | 586 | * @enable: 1 to enable monitor mode, 0 to disable |
568 | * | 587 | * |
569 | * @return 0 on success, error on failure | 588 | * returns: 0 on success, error on failure |
570 | */ | 589 | */ |
571 | int lbs_set_monitor_mode(struct lbs_private *priv, int enable) | 590 | int lbs_set_monitor_mode(struct lbs_private *priv, int enable) |
572 | { | 591 | { |
@@ -592,11 +611,11 @@ int lbs_set_monitor_mode(struct lbs_private *priv, int enable) | |||
592 | } | 611 | } |
593 | 612 | ||
594 | /** | 613 | /** |
595 | * @brief Get the radio channel | 614 | * lbs_get_channel - Get the radio channel |
596 | * | 615 | * |
597 | * @param priv A pointer to struct lbs_private structure | 616 | * @priv: A pointer to &struct lbs_private structure |
598 | * | 617 | * |
599 | * @return The channel on success, error on failure | 618 | * returns: The channel on success, error on failure |
600 | */ | 619 | */ |
601 | static int lbs_get_channel(struct lbs_private *priv) | 620 | static int lbs_get_channel(struct lbs_private *priv) |
602 | { | 621 | { |
@@ -638,12 +657,12 @@ int lbs_update_channel(struct lbs_private *priv) | |||
638 | } | 657 | } |
639 | 658 | ||
640 | /** | 659 | /** |
641 | * @brief Set the radio channel | 660 | * lbs_set_channel - Set the radio channel |
642 | * | 661 | * |
643 | * @param priv A pointer to struct lbs_private structure | 662 | * @priv: A pointer to &struct lbs_private structure |
644 | * @param channel The desired channel, or 0 to clear a locked channel | 663 | * @channel: The desired channel, or 0 to clear a locked channel |
645 | * | 664 | * |
646 | * @return 0 on success, error on failure | 665 | * returns: 0 on success, error on failure |
647 | */ | 666 | */ |
648 | int lbs_set_channel(struct lbs_private *priv, u8 channel) | 667 | int lbs_set_channel(struct lbs_private *priv, u8 channel) |
649 | { | 668 | { |
@@ -674,12 +693,13 @@ out: | |||
674 | } | 693 | } |
675 | 694 | ||
676 | /** | 695 | /** |
677 | * @brief Get current RSSI and noise floor | 696 | * lbs_get_rssi - Get current RSSI and noise floor |
678 | * | 697 | * |
679 | * @param priv A pointer to struct lbs_private structure | 698 | * @priv: A pointer to &struct lbs_private structure |
680 | * @param rssi On successful return, signal level in mBm | 699 | * @rssi: On successful return, signal level in mBm |
700 | * @nf: On successful return, Noise floor | ||
681 | * | 701 | * |
682 | * @return The channel on success, error on failure | 702 | * returns: The channel on success, error on failure |
683 | */ | 703 | */ |
684 | int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf) | 704 | int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf) |
685 | { | 705 | { |
@@ -707,13 +727,14 @@ int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf) | |||
707 | } | 727 | } |
708 | 728 | ||
709 | /** | 729 | /** |
710 | * @brief Send regulatory and 802.11d domain information to the firmware | 730 | * lbs_set_11d_domain_info - Send regulatory and 802.11d domain information |
731 | * to the firmware | ||
711 | * | 732 | * |
712 | * @param priv pointer to struct lbs_private | 733 | * @priv: pointer to &struct lbs_private |
713 | * @param request cfg80211 regulatory request structure | 734 | * @request: cfg80211 regulatory request structure |
714 | * @param bands the device's supported bands and channels | 735 | * @bands: the device's supported bands and channels |
715 | * | 736 | * |
716 | * @return 0 on success, error code on failure | 737 | * returns: 0 on success, error code on failure |
717 | */ | 738 | */ |
718 | int lbs_set_11d_domain_info(struct lbs_private *priv, | 739 | int lbs_set_11d_domain_info(struct lbs_private *priv, |
719 | struct regulatory_request *request, | 740 | struct regulatory_request *request, |
@@ -830,15 +851,15 @@ int lbs_set_11d_domain_info(struct lbs_private *priv, | |||
830 | } | 851 | } |
831 | 852 | ||
832 | /** | 853 | /** |
833 | * @brief Read a MAC, Baseband, or RF register | 854 | * lbs_get_reg - Read a MAC, Baseband, or RF register |
834 | * | 855 | * |
835 | * @param priv pointer to struct lbs_private | 856 | * @priv: pointer to &struct lbs_private |
836 | * @param cmd register command, one of CMD_MAC_REG_ACCESS, | 857 | * @reg: register command, one of CMD_MAC_REG_ACCESS, |
837 | * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS | 858 | * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS |
838 | * @param offset byte offset of the register to get | 859 | * @offset: byte offset of the register to get |
839 | * @param value on success, the value of the register at 'offset' | 860 | * @value: on success, the value of the register at 'offset' |
840 | * | 861 | * |
841 | * @return 0 on success, error code on failure | 862 | * returns: 0 on success, error code on failure |
842 | */ | 863 | */ |
843 | int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value) | 864 | int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value) |
844 | { | 865 | { |
@@ -874,15 +895,15 @@ out: | |||
874 | } | 895 | } |
875 | 896 | ||
876 | /** | 897 | /** |
877 | * @brief Write a MAC, Baseband, or RF register | 898 | * lbs_set_reg - Write a MAC, Baseband, or RF register |
878 | * | 899 | * |
879 | * @param priv pointer to struct lbs_private | 900 | * @priv: pointer to &struct lbs_private |
880 | * @param cmd register command, one of CMD_MAC_REG_ACCESS, | 901 | * @reg: register command, one of CMD_MAC_REG_ACCESS, |
881 | * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS | 902 | * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS |
882 | * @param offset byte offset of the register to set | 903 | * @offset: byte offset of the register to set |
883 | * @param value the value to write to the register at 'offset' | 904 | * @value: the value to write to the register at 'offset' |
884 | * | 905 | * |
885 | * @return 0 on success, error code on failure | 906 | * returns: 0 on success, error code on failure |
886 | */ | 907 | */ |
887 | int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value) | 908 | int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value) |
888 | { | 909 | { |
@@ -973,6 +994,8 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
973 | cmd = cmdnode->cmdbuf; | 994 | cmd = cmdnode->cmdbuf; |
974 | 995 | ||
975 | spin_lock_irqsave(&priv->driver_lock, flags); | 996 | spin_lock_irqsave(&priv->driver_lock, flags); |
997 | priv->seqnum++; | ||
998 | cmd->seqnum = cpu_to_le16(priv->seqnum); | ||
976 | priv->cur_cmd = cmdnode; | 999 | priv->cur_cmd = cmdnode; |
977 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1000 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
978 | 1001 | ||
@@ -990,7 +1013,8 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
990 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); | 1013 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); |
991 | 1014 | ||
992 | if (ret) { | 1015 | if (ret) { |
993 | lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); | 1016 | netdev_info(priv->dev, "DNLD_CMD: hw_host_to_card failed: %d\n", |
1017 | ret); | ||
994 | /* Let the timer kick in and retry, and potentially reset | 1018 | /* Let the timer kick in and retry, and potentially reset |
995 | the whole thing if the condition persists */ | 1019 | the whole thing if the condition persists */ |
996 | timeo = HZ/4; | 1020 | timeo = HZ/4; |
@@ -1011,7 +1035,7 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
1011 | lbs_deb_leave(LBS_DEB_HOST); | 1035 | lbs_deb_leave(LBS_DEB_HOST); |
1012 | } | 1036 | } |
1013 | 1037 | ||
1014 | /** | 1038 | /* |
1015 | * This function inserts command node to cmdfreeq | 1039 | * This function inserts command node to cmdfreeq |
1016 | * after cleans it. Requires priv->driver_lock held. | 1040 | * after cleans it. Requires priv->driver_lock held. |
1017 | */ | 1041 | */ |
@@ -1113,11 +1137,12 @@ void lbs_set_mac_control(struct lbs_private *priv) | |||
1113 | } | 1137 | } |
1114 | 1138 | ||
1115 | /** | 1139 | /** |
1116 | * @brief This function allocates the command buffer and link | 1140 | * lbs_allocate_cmd_buffer - allocates the command buffer and links |
1117 | * it to command free queue. | 1141 | * it to command free queue |
1118 | * | 1142 | * |
1119 | * @param priv A pointer to struct lbs_private structure | 1143 | * @priv: A pointer to &struct lbs_private structure |
1120 | * @return 0 or -1 | 1144 | * |
1145 | * returns: 0 for success or -1 on error | ||
1121 | */ | 1146 | */ |
1122 | int lbs_allocate_cmd_buffer(struct lbs_private *priv) | 1147 | int lbs_allocate_cmd_buffer(struct lbs_private *priv) |
1123 | { | 1148 | { |
@@ -1159,10 +1184,11 @@ done: | |||
1159 | } | 1184 | } |
1160 | 1185 | ||
1161 | /** | 1186 | /** |
1162 | * @brief This function frees the command buffer. | 1187 | * lbs_free_cmd_buffer - free the command buffer |
1188 | * | ||
1189 | * @priv: A pointer to &struct lbs_private structure | ||
1163 | * | 1190 | * |
1164 | * @param priv A pointer to struct lbs_private structure | 1191 | * returns: 0 for success |
1165 | * @return 0 or -1 | ||
1166 | */ | 1192 | */ |
1167 | int lbs_free_cmd_buffer(struct lbs_private *priv) | 1193 | int lbs_free_cmd_buffer(struct lbs_private *priv) |
1168 | { | 1194 | { |
@@ -1199,11 +1225,13 @@ done: | |||
1199 | } | 1225 | } |
1200 | 1226 | ||
1201 | /** | 1227 | /** |
1202 | * @brief This function gets a free command node if available in | 1228 | * lbs_get_free_cmd_node - gets a free command node if available in |
1203 | * command free queue. | 1229 | * command free queue |
1204 | * | 1230 | * |
1205 | * @param priv A pointer to struct lbs_private structure | 1231 | * @priv: A pointer to &struct lbs_private structure |
1206 | * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL | 1232 | * |
1233 | * returns: A pointer to &cmd_ctrl_node structure on success | ||
1234 | * or %NULL on error | ||
1207 | */ | 1235 | */ |
1208 | static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv) | 1236 | static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv) |
1209 | { | 1237 | { |
@@ -1233,12 +1261,12 @@ static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv) | |||
1233 | } | 1261 | } |
1234 | 1262 | ||
1235 | /** | 1263 | /** |
1236 | * @brief This function executes next command in command | 1264 | * lbs_execute_next_command - execute next command in command |
1237 | * pending queue. It will put firmware back to PS mode | 1265 | * pending queue. Will put firmware back to PS mode if applicable. |
1238 | * if applicable. | 1266 | * |
1267 | * @priv: A pointer to &struct lbs_private structure | ||
1239 | * | 1268 | * |
1240 | * @param priv A pointer to struct lbs_private structure | 1269 | * returns: 0 on success or -1 on error |
1241 | * @return 0 or -1 | ||
1242 | */ | 1270 | */ |
1243 | int lbs_execute_next_command(struct lbs_private *priv) | 1271 | int lbs_execute_next_command(struct lbs_private *priv) |
1244 | { | 1272 | { |
@@ -1255,7 +1283,8 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1255 | spin_lock_irqsave(&priv->driver_lock, flags); | 1283 | spin_lock_irqsave(&priv->driver_lock, flags); |
1256 | 1284 | ||
1257 | if (priv->cur_cmd) { | 1285 | if (priv->cur_cmd) { |
1258 | lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n"); | 1286 | netdev_alert(priv->dev, |
1287 | "EXEC_NEXT_CMD: already processing command!\n"); | ||
1259 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1288 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
1260 | ret = -1; | 1289 | ret = -1; |
1261 | goto done; | 1290 | goto done; |
@@ -1327,8 +1356,8 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1327 | cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { | 1356 | cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { |
1328 | lbs_deb_host( | 1357 | lbs_deb_host( |
1329 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); | 1358 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); |
1330 | list_del(&cmdnode->list); | ||
1331 | spin_lock_irqsave(&priv->driver_lock, flags); | 1359 | spin_lock_irqsave(&priv->driver_lock, flags); |
1360 | list_del(&cmdnode->list); | ||
1332 | lbs_complete_command(priv, cmdnode, 0); | 1361 | lbs_complete_command(priv, cmdnode, 0); |
1333 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1362 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
1334 | 1363 | ||
@@ -1340,8 +1369,8 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1340 | (priv->psstate == PS_STATE_PRE_SLEEP)) { | 1369 | (priv->psstate == PS_STATE_PRE_SLEEP)) { |
1341 | lbs_deb_host( | 1370 | lbs_deb_host( |
1342 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); | 1371 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); |
1343 | list_del(&cmdnode->list); | ||
1344 | spin_lock_irqsave(&priv->driver_lock, flags); | 1372 | spin_lock_irqsave(&priv->driver_lock, flags); |
1373 | list_del(&cmdnode->list); | ||
1345 | lbs_complete_command(priv, cmdnode, 0); | 1374 | lbs_complete_command(priv, cmdnode, 0); |
1346 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 1375 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
1347 | priv->needtowakeup = 1; | 1376 | priv->needtowakeup = 1; |
@@ -1354,7 +1383,9 @@ int lbs_execute_next_command(struct lbs_private *priv) | |||
1354 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); | 1383 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); |
1355 | } | 1384 | } |
1356 | } | 1385 | } |
1386 | spin_lock_irqsave(&priv->driver_lock, flags); | ||
1357 | list_del(&cmdnode->list); | 1387 | list_del(&cmdnode->list); |
1388 | spin_unlock_irqrestore(&priv->driver_lock, flags); | ||
1358 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", | 1389 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", |
1359 | le16_to_cpu(cmd->command)); | 1390 | le16_to_cpu(cmd->command)); |
1360 | lbs_submit_command(priv, cmdnode); | 1391 | lbs_submit_command(priv, cmdnode); |
@@ -1417,7 +1448,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv) | |||
1417 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep, | 1448 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep, |
1418 | sizeof(confirm_sleep)); | 1449 | sizeof(confirm_sleep)); |
1419 | if (ret) { | 1450 | if (ret) { |
1420 | lbs_pr_alert("confirm_sleep failed\n"); | 1451 | netdev_alert(priv->dev, "confirm_sleep failed\n"); |
1421 | goto out; | 1452 | goto out; |
1422 | } | 1453 | } |
1423 | 1454 | ||
@@ -1442,12 +1473,12 @@ out: | |||
1442 | } | 1473 | } |
1443 | 1474 | ||
1444 | /** | 1475 | /** |
1445 | * @brief This function checks condition and prepares to | 1476 | * lbs_ps_confirm_sleep - checks condition and prepares to |
1446 | * send sleep confirm command to firmware if ok. | 1477 | * send sleep confirm command to firmware if ok |
1447 | * | 1478 | * |
1448 | * @param priv A pointer to struct lbs_private structure | 1479 | * @priv: A pointer to &struct lbs_private structure |
1449 | * @param psmode Power Saving mode | 1480 | * |
1450 | * @return n/a | 1481 | * returns: n/a |
1451 | */ | 1482 | */ |
1452 | void lbs_ps_confirm_sleep(struct lbs_private *priv) | 1483 | void lbs_ps_confirm_sleep(struct lbs_private *priv) |
1453 | { | 1484 | { |
@@ -1487,16 +1518,16 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv) | |||
1487 | 1518 | ||
1488 | 1519 | ||
1489 | /** | 1520 | /** |
1490 | * @brief Configures the transmission power control functionality. | 1521 | * lbs_set_tpc_cfg - Configures the transmission power control functionality |
1491 | * | 1522 | * |
1492 | * @param priv A pointer to struct lbs_private structure | 1523 | * @priv: A pointer to &struct lbs_private structure |
1493 | * @param enable Transmission power control enable | 1524 | * @enable: Transmission power control enable |
1494 | * @param p0 Power level when link quality is good (dBm). | 1525 | * @p0: Power level when link quality is good (dBm). |
1495 | * @param p1 Power level when link quality is fair (dBm). | 1526 | * @p1: Power level when link quality is fair (dBm). |
1496 | * @param p2 Power level when link quality is poor (dBm). | 1527 | * @p2: Power level when link quality is poor (dBm). |
1497 | * @param usesnr Use Signal to Noise Ratio in TPC | 1528 | * @usesnr: Use Signal to Noise Ratio in TPC |
1498 | * | 1529 | * |
1499 | * @return 0 on success | 1530 | * returns: 0 on success |
1500 | */ | 1531 | */ |
1501 | int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1, | 1532 | int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1, |
1502 | int8_t p2, int usesnr) | 1533 | int8_t p2, int usesnr) |
@@ -1519,15 +1550,15 @@ int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1, | |||
1519 | } | 1550 | } |
1520 | 1551 | ||
1521 | /** | 1552 | /** |
1522 | * @brief Configures the power adaptation settings. | 1553 | * lbs_set_power_adapt_cfg - Configures the power adaptation settings |
1523 | * | 1554 | * |
1524 | * @param priv A pointer to struct lbs_private structure | 1555 | * @priv: A pointer to &struct lbs_private structure |
1525 | * @param enable Power adaptation enable | 1556 | * @enable: Power adaptation enable |
1526 | * @param p0 Power level for 1, 2, 5.5 and 11 Mbps (dBm). | 1557 | * @p0: Power level for 1, 2, 5.5 and 11 Mbps (dBm). |
1527 | * @param p1 Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm). | 1558 | * @p1: Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm). |
1528 | * @param p2 Power level for 48 and 54 Mbps (dBm). | 1559 | * @p2: Power level for 48 and 54 Mbps (dBm). |
1529 | * | 1560 | * |
1530 | * @return 0 on Success | 1561 | * returns: 0 on Success |
1531 | */ | 1562 | */ |
1532 | 1563 | ||
1533 | int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0, | 1564 | int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0, |
@@ -1592,11 +1623,9 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, | |||
1592 | /* Copy the incoming command to the buffer */ | 1623 | /* Copy the incoming command to the buffer */ |
1593 | memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); | 1624 | memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); |
1594 | 1625 | ||
1595 | /* Set sequence number, clean result, move to buffer */ | 1626 | /* Set command, clean result, move to buffer */ |
1596 | priv->seqnum++; | ||
1597 | cmdnode->cmdbuf->command = cpu_to_le16(command); | 1627 | cmdnode->cmdbuf->command = cpu_to_le16(command); |
1598 | cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); | 1628 | cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); |
1599 | cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); | ||
1600 | cmdnode->cmdbuf->result = 0; | 1629 | cmdnode->cmdbuf->result = 0; |
1601 | 1630 | ||
1602 | lbs_deb_host("PREP_CMD: command 0x%04x\n", command); | 1631 | lbs_deb_host("PREP_CMD: command 0x%04x\n", command); |
@@ -1643,7 +1672,7 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, | |||
1643 | spin_lock_irqsave(&priv->driver_lock, flags); | 1672 | spin_lock_irqsave(&priv->driver_lock, flags); |
1644 | ret = cmdnode->result; | 1673 | ret = cmdnode->result; |
1645 | if (ret) | 1674 | if (ret) |
1646 | lbs_pr_info("PREP_CMD: command 0x%04x failed: %d\n", | 1675 | netdev_info(priv->dev, "PREP_CMD: command 0x%04x failed: %d\n", |
1647 | command, ret); | 1676 | command, ret); |
1648 | 1677 | ||
1649 | __lbs_cleanup_and_insert_cmd(priv, cmdnode); | 1678 | __lbs_cleanup_and_insert_cmd(priv, cmdnode); |