diff options
author | Dan Williams <dcbw@redhat.com> | 2008-08-19 15:15:35 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-08-29 16:24:06 -0400 |
commit | 87c8c72d532f96257162f978d5945dcf7f0df19e (patch) | |
tree | 71f270c1844e74ba41a6fe347e53f035db923e7d /drivers/net/wireless/libertas/cmd.c | |
parent | 095f695cbb07281682462da0618fffabb499d0be (diff) |
libertas: convert CMD_802_11_RF_TX_POWER to a direct command
And while we're at it, grab min/max TX power from the firmware and use
that to validate incoming TX power requests from WEXT.
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index af5fd709887f..c0db988926bf 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -614,47 +614,67 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv, | |||
614 | return 0; | 614 | return 0; |
615 | } | 615 | } |
616 | 616 | ||
617 | static int lbs_cmd_802_11_rf_tx_power(struct cmd_ds_command *cmd, | 617 | /** |
618 | u16 cmd_action, void *pdata_buf) | 618 | * @brief Get the min, max, and current TX power |
619 | * | ||
620 | * @param priv A pointer to struct lbs_private structure | ||
621 | * @param curlevel Current power level in dBm | ||
622 | * @param minlevel Minimum supported power level in dBm (optional) | ||
623 | * @param maxlevel Maximum supported power level in dBm (optional) | ||
624 | * | ||
625 | * @return 0 on success, error on failure | ||
626 | */ | ||
627 | int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, | ||
628 | s16 *maxlevel) | ||
619 | { | 629 | { |
620 | 630 | struct cmd_ds_802_11_rf_tx_power cmd; | |
621 | struct cmd_ds_802_11_rf_tx_power *prtp = &cmd->params.txp; | 631 | int ret; |
622 | 632 | ||
623 | lbs_deb_enter(LBS_DEB_CMD); | 633 | lbs_deb_enter(LBS_DEB_CMD); |
624 | 634 | ||
625 | cmd->size = | 635 | memset(&cmd, 0, sizeof(cmd)); |
626 | cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN); | 636 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
627 | cmd->command = cpu_to_le16(CMD_802_11_RF_TX_POWER); | 637 | cmd.action = cpu_to_le16(CMD_ACT_GET); |
628 | prtp->action = cpu_to_le16(cmd_action); | 638 | |
639 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd); | ||
640 | if (ret == 0) { | ||
641 | *curlevel = le16_to_cpu(cmd.curlevel); | ||
642 | if (minlevel) | ||
643 | *minlevel = le16_to_cpu(cmd.minlevel); | ||
644 | if (maxlevel) | ||
645 | *maxlevel = le16_to_cpu(cmd.maxlevel); | ||
646 | } | ||
629 | 647 | ||
630 | lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n", | 648 | lbs_deb_leave(LBS_DEB_CMD); |
631 | le16_to_cpu(cmd->size), le16_to_cpu(cmd->command), | 649 | return ret; |
632 | le16_to_cpu(prtp->action)); | 650 | } |
633 | 651 | ||
634 | switch (cmd_action) { | 652 | /** |
635 | case CMD_ACT_TX_POWER_OPT_GET: | 653 | * @brief Set the TX power |
636 | prtp->action = cpu_to_le16(CMD_ACT_GET); | 654 | * |
637 | prtp->currentlevel = 0; | 655 | * @param priv A pointer to struct lbs_private structure |
638 | break; | 656 | * @param dbm The desired power level in dBm |
657 | * | ||
658 | * @return 0 on success, error on failure | ||
659 | */ | ||
660 | int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) | ||
661 | { | ||
662 | struct cmd_ds_802_11_rf_tx_power cmd; | ||
663 | int ret; | ||
639 | 664 | ||
640 | case CMD_ACT_TX_POWER_OPT_SET_HIGH: | 665 | lbs_deb_enter(LBS_DEB_CMD); |
641 | prtp->action = cpu_to_le16(CMD_ACT_SET); | ||
642 | prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_HIGH); | ||
643 | break; | ||
644 | 666 | ||
645 | case CMD_ACT_TX_POWER_OPT_SET_MID: | 667 | memset(&cmd, 0, sizeof(cmd)); |
646 | prtp->action = cpu_to_le16(CMD_ACT_SET); | 668 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
647 | prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_MID); | 669 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
648 | break; | 670 | cmd.curlevel = cpu_to_le16(dbm); |
649 | 671 | ||
650 | case CMD_ACT_TX_POWER_OPT_SET_LOW: | 672 | lbs_deb_cmd("SET_RF_TX_POWER: %d dBm\n", dbm); |
651 | prtp->action = cpu_to_le16(CMD_ACT_SET); | 673 | |
652 | prtp->currentlevel = cpu_to_le16(*((u16 *) pdata_buf)); | 674 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd); |
653 | break; | ||
654 | } | ||
655 | 675 | ||
656 | lbs_deb_leave(LBS_DEB_CMD); | 676 | lbs_deb_leave(LBS_DEB_CMD); |
657 | return 0; | 677 | return ret; |
658 | } | 678 | } |
659 | 679 | ||
660 | static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd, | 680 | static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd, |
@@ -1420,11 +1440,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1420 | ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf); | 1440 | ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf); |
1421 | break; | 1441 | break; |
1422 | 1442 | ||
1423 | case CMD_802_11_RF_TX_POWER: | ||
1424 | ret = lbs_cmd_802_11_rf_tx_power(cmdptr, | ||
1425 | cmd_action, pdata_buf); | ||
1426 | break; | ||
1427 | |||
1428 | case CMD_802_11_MONITOR_MODE: | 1443 | case CMD_802_11_MONITOR_MODE: |
1429 | ret = lbs_cmd_802_11_monitor_mode(cmdptr, | 1444 | ret = lbs_cmd_802_11_monitor_mode(cmdptr, |
1430 | cmd_action, pdata_buf); | 1445 | cmd_action, pdata_buf); |