ath9k_htc: Add a WMI command to get the firmware version
authorSujith Manoharan <Sujith.Manoharan@atheros.com>
Wed, 13 Apr 2011 05:52:51 +0000 (11:22 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 13 Apr 2011 19:22:07 +0000 (15:22 -0400)
Also, update the wiphy information and use the correct
device pointer when registering. This would fix ethtool.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/htc.h
drivers/net/wireless/ath/ath9k/htc_drv_init.c
drivers/net/wireless/ath/ath9k/wmi.c
drivers/net/wireless/ath/ath9k/wmi.h

index ec47be94b74fa712b04c477ffddf16987ca76239..9544cd7fd440fb10929532556a991f014f413c85 100644 (file)
@@ -388,6 +388,9 @@ struct ath9k_htc_priv {
        struct htc_target *htc;
        struct wmi *wmi;
 
+       u16 fw_version_major;
+       u16 fw_version_minor;
+
        enum htc_endpoint_id wmi_cmd_ep;
        enum htc_endpoint_id beacon_ep;
        enum htc_endpoint_id cab_ep;
index 8303b34bdc904c3fc3cc7f7eaa6b01aef3269f57..6bbfca58deda9eea86a4707e025115641f4252ea 100644 (file)
@@ -782,6 +782,32 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
        SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
 }
 
+static int ath9k_init_firmware_version(struct ath9k_htc_priv *priv)
+{
+       struct ieee80211_hw *hw = priv->hw;
+       struct wmi_fw_version cmd_rsp;
+       int ret;
+
+       memset(&cmd_rsp, 0, sizeof(cmd_rsp));
+
+       WMI_CMD(WMI_GET_FW_VERSION);
+       if (ret)
+               return -EINVAL;
+
+       priv->fw_version_major = be16_to_cpu(cmd_rsp.major);
+       priv->fw_version_minor = be16_to_cpu(cmd_rsp.minor);
+
+       snprintf(hw->wiphy->fw_version, ETHTOOL_BUSINFO_LEN, "%d.%d",
+                priv->fw_version_major,
+                priv->fw_version_minor);
+
+       dev_info(priv->dev, "ath9k_htc: FW Version: %d.%d\n",
+                priv->fw_version_major,
+                priv->fw_version_minor);
+
+       return 0;
+}
+
 static int ath9k_init_device(struct ath9k_htc_priv *priv,
                             u16 devid, char *product, u32 drv_info)
 {
@@ -801,6 +827,10 @@ static int ath9k_init_device(struct ath9k_htc_priv *priv,
        common = ath9k_hw_common(ah);
        ath9k_set_hw_capab(priv, hw);
 
+       error = ath9k_init_firmware_version(priv);
+       if (error != 0)
+               goto err_fw;
+
        /* Initialize regulatory */
        error = ath_regd_init(&common->regulatory, priv->hw->wiphy,
                              ath9k_reg_notifier);
@@ -861,6 +891,8 @@ err_rx:
 err_tx:
        /* Nothing */
 err_regd:
+       /* Nothing */
+err_fw:
        ath9k_deinit_priv(priv);
 err_init:
        return error;
index d3d24904f62f89d46ff270914f7946b9f43bdf5e..267a98fcf5f2735252b338efa42ea190c0ef0d17 100644 (file)
@@ -23,6 +23,8 @@ static const char *wmi_cmd_to_name(enum wmi_cmd_id wmi_cmd)
                return "WMI_ECHO_CMDID";
        case WMI_ACCESS_MEMORY_CMDID:
                return "WMI_ACCESS_MEMORY_CMDID";
+       case WMI_GET_FW_VERSION:
+               return "WMI_GET_FW_VERSION";
        case WMI_DISABLE_INTR_CMDID:
                return "WMI_DISABLE_INTR_CMDID";
        case WMI_ENABLE_INTR_CMDID:
index 42084277522dc15441a9d5ff953e028bf172a8d9..6a36572b6fb8f9451e1138011a597d29a466c1b6 100644 (file)
@@ -31,11 +31,17 @@ struct wmi_cmd_hdr {
        __be16 seq_no;
 } __packed;
 
+struct wmi_fw_version {
+       __be16 major;
+       __be16 minor;
+
+} __packed;
 enum wmi_cmd_id {
        WMI_ECHO_CMDID = 0x0001,
        WMI_ACCESS_MEMORY_CMDID,
 
        /* Commands to Target */
+       WMI_GET_FW_VERSION,
        WMI_DISABLE_INTR_CMDID,
        WMI_ENABLE_INTR_CMDID,
        WMI_RX_LINK_CMDID,