aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmdresp.c198
1 files changed, 87 insertions, 111 deletions
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index 0d8618a8443f..3f13ff0cd262 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -420,38 +420,34 @@ static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
420 420
421 switch (action) { 421 switch (action) {
422 case HostCmd_ACT_GEN_GET: 422 case HostCmd_ACT_GEN_GET:
423 { 423 pg_tlv_hdr = (struct mwifiex_types_power_group *)
424 pg_tlv_hdr = 424 ((u8 *) txp_cfg +
425 (struct mwifiex_types_power_group *) ((u8 *) 425 sizeof(struct host_cmd_ds_txpwr_cfg));
426 txp_cfg + 426
427 sizeof 427 pg = (struct mwifiex_power_group *)
428 (struct 428 ((u8 *) pg_tlv_hdr +
429 host_cmd_ds_txpwr_cfg)); 429 sizeof(struct mwifiex_types_power_group));
430 pg = (struct mwifiex_power_group *) ((u8 *) 430
431 pg_tlv_hdr + 431 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
432 sizeof(struct 432 mwifiex_get_power_level(priv, txp_cfg);
433 mwifiex_types_power_group)); 433
434 if (adapter->hw_status == 434 priv->tx_power_level = (u16) pg->power_min;
435 MWIFIEX_HW_STATUS_INITIALIZING) 435 break;
436 mwifiex_get_power_level(priv, txp_cfg); 436
437 priv->tx_power_level = (u16) pg->power_min;
438 break;
439 }
440 case HostCmd_ACT_GEN_SET: 437 case HostCmd_ACT_GEN_SET:
441 if (le32_to_cpu(txp_cfg->mode)) { 438 if (!le32_to_cpu(txp_cfg->mode))
442 pg_tlv_hdr = 439 break;
443 (struct mwifiex_types_power_group *) ((u8 *) 440
444 txp_cfg + 441 pg_tlv_hdr = (struct mwifiex_types_power_group *)
445 sizeof 442 ((u8 *) txp_cfg +
446 (struct 443 sizeof(struct host_cmd_ds_txpwr_cfg));
447 host_cmd_ds_txpwr_cfg)); 444
448 pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr 445 pg = (struct mwifiex_power_group *)
449 + 446 ((u8 *) pg_tlv_hdr +
450 sizeof(struct 447 sizeof(struct mwifiex_types_power_group));
451 mwifiex_types_power_group)); 448
452 if (pg->power_max == pg->power_min) 449 if (pg->power_max == pg->power_min)
453 priv->tx_power_level = (u16) pg->power_min; 450 priv->tx_power_level = (u16) pg->power_min;
454 }
455 break; 451 break;
456 default: 452 default:
457 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n", 453 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n",
@@ -679,90 +675,70 @@ static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
679{ 675{
680 struct mwifiex_ds_reg_rw *reg_rw; 676 struct mwifiex_ds_reg_rw *reg_rw;
681 struct mwifiex_ds_read_eeprom *eeprom; 677 struct mwifiex_ds_read_eeprom *eeprom;
678 union reg {
679 struct host_cmd_ds_mac_reg_access *mac;
680 struct host_cmd_ds_bbp_reg_access *bbp;
681 struct host_cmd_ds_rf_reg_access *rf;
682 struct host_cmd_ds_pmic_reg_access *pmic;
683 struct host_cmd_ds_802_11_eeprom_access *eeprom;
684 } r;
685
686 if (!data_buf)
687 return 0;
682 688
683 if (data_buf) { 689 reg_rw = data_buf;
684 reg_rw = data_buf; 690 eeprom = data_buf;
685 eeprom = data_buf; 691 switch (type) {
686 switch (type) { 692 case HostCmd_CMD_MAC_REG_ACCESS:
687 case HostCmd_CMD_MAC_REG_ACCESS: 693 r.mac = (struct host_cmd_ds_mac_reg_access *)
688 { 694 &resp->params.mac_reg;
689 struct host_cmd_ds_mac_reg_access *reg; 695 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset));
690 reg = (struct host_cmd_ds_mac_reg_access *) 696 reg_rw->value = r.mac->value;
691 &resp->params.mac_reg; 697 break;
692 reg_rw->offset = cpu_to_le32( 698 case HostCmd_CMD_BBP_REG_ACCESS:
693 (u32) le16_to_cpu(reg->offset)); 699 r.bbp = (struct host_cmd_ds_bbp_reg_access *)
694 reg_rw->value = reg->value; 700 &resp->params.bbp_reg;
695 break; 701 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset));
696 } 702 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
697 case HostCmd_CMD_BBP_REG_ACCESS: 703 break;
698 {
699 struct host_cmd_ds_bbp_reg_access *reg;
700 reg = (struct host_cmd_ds_bbp_reg_access *)
701 &resp->params.bbp_reg;
702 reg_rw->offset = cpu_to_le32(
703 (u32) le16_to_cpu(reg->offset));
704 reg_rw->value = cpu_to_le32((u32) reg->value);
705 break;
706 }
707 704
708 case HostCmd_CMD_RF_REG_ACCESS: 705 case HostCmd_CMD_RF_REG_ACCESS:
709 { 706 r.rf = (struct host_cmd_ds_rf_reg_access *)
710 struct host_cmd_ds_rf_reg_access *reg; 707 &resp->params.rf_reg;
711 reg = (struct host_cmd_ds_rf_reg_access *) 708 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
712 &resp->params.rf_reg; 709 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
713 reg_rw->offset = cpu_to_le32( 710 break;
714 (u32) le16_to_cpu(reg->offset)); 711 case HostCmd_CMD_PMIC_REG_ACCESS:
715 reg_rw->value = cpu_to_le32((u32) reg->value); 712 r.pmic = (struct host_cmd_ds_pmic_reg_access *)
716 break; 713 &resp->params.pmic_reg;
717 } 714 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset));
718 case HostCmd_CMD_PMIC_REG_ACCESS: 715 reg_rw->value = cpu_to_le32((u32) r.pmic->value);
719 { 716 break;
720 struct host_cmd_ds_pmic_reg_access *reg; 717 case HostCmd_CMD_CAU_REG_ACCESS:
721 reg = (struct host_cmd_ds_pmic_reg_access *) 718 r.rf = (struct host_cmd_ds_rf_reg_access *)
722 &resp->params.pmic_reg; 719 &resp->params.rf_reg;
723 reg_rw->offset = cpu_to_le32( 720 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
724 (u32) le16_to_cpu(reg->offset)); 721 reg_rw->value = cpu_to_le32((u32) r.rf->value);
725 reg_rw->value = cpu_to_le32((u32) reg->value); 722 break;
726 break; 723 case HostCmd_CMD_802_11_EEPROM_ACCESS:
727 } 724 r.eeprom = (struct host_cmd_ds_802_11_eeprom_access *)
728 case HostCmd_CMD_CAU_REG_ACCESS: 725 &resp->params.eeprom;
729 { 726 pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count);
730 struct host_cmd_ds_rf_reg_access *reg; 727 if (le16_to_cpu(eeprom->byte_count) <
731 reg = (struct host_cmd_ds_rf_reg_access *) 728 le16_to_cpu(r.eeprom->byte_count)) {
732 &resp->params.rf_reg; 729 eeprom->byte_count = cpu_to_le16(0);
733 reg_rw->offset = cpu_to_le32( 730 pr_debug("info: EEPROM read length is too big\n");
734 (u32) le16_to_cpu(reg->offset));
735 reg_rw->value = cpu_to_le32((u32) reg->value);
736 break;
737 }
738 case HostCmd_CMD_802_11_EEPROM_ACCESS:
739 {
740 struct host_cmd_ds_802_11_eeprom_access
741 *cmd_eeprom =
742 (struct host_cmd_ds_802_11_eeprom_access
743 *) &resp->params.eeprom;
744 pr_debug("info: EEPROM read len=%x\n",
745 cmd_eeprom->byte_count);
746 if (le16_to_cpu(eeprom->byte_count) <
747 le16_to_cpu(
748 cmd_eeprom->byte_count)) {
749 eeprom->byte_count = cpu_to_le16(0);
750 pr_debug("info: EEPROM read "
751 "length is too big\n");
752 return -1;
753 }
754 eeprom->offset = cmd_eeprom->offset;
755 eeprom->byte_count = cmd_eeprom->byte_count;
756 if (le16_to_cpu(eeprom->byte_count) > 0)
757 memcpy(&eeprom->value,
758 &cmd_eeprom->value,
759 le16_to_cpu(eeprom->byte_count));
760
761 break;
762 }
763 default:
764 return -1; 731 return -1;
765 } 732 }
733 eeprom->offset = r.eeprom->offset;
734 eeprom->byte_count = r.eeprom->byte_count;
735 if (le16_to_cpu(eeprom->byte_count) > 0)
736 memcpy(&eeprom->value, &r.eeprom->value,
737 le16_to_cpu(r.eeprom->byte_count));
738
739 break;
740 default:
741 return -1;
766 } 742 }
767 return 0; 743 return 0;
768} 744}