wlcore: fix interrogate command length
authorIgal Chernobelsky <igalc@ti.com>
Mon, 9 Sep 2013 09:24:35 +0000 (12:24 +0300)
committerLuciano Coelho <luciano.coelho@intel.com>
Wed, 23 Oct 2013 06:47:40 +0000 (09:47 +0300)
Change interrogate command prototype to have command size
and returned buffer length.
This fixes the issue when command parameters are needed to
be passed to FW in addition to acx header as in the case with
get RSSI command, where role_id has to be passed.

Signed-off-by: Igal Chernobelsky <igalc@ti.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
drivers/net/wireless/ti/wlcore/acx.c
drivers/net/wireless/ti/wlcore/cmd.c
drivers/net/wireless/ti/wlcore/cmd.h
drivers/net/wireless/ti/wlcore/testmode.c

index 7a970cd..ec83675 100644 (file)
@@ -162,7 +162,8 @@ int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
 
        wl1271_debug(DEBUG_ACX, "acx mem map");
 
-       ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
+       ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map,
+                                    sizeof(struct acx_header), len);
        if (ret < 0)
                return ret;
 
@@ -722,6 +723,7 @@ int wl1271_acx_statistics(struct wl1271 *wl, void *stats)
        wl1271_debug(DEBUG_ACX, "acx statistics");
 
        ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
+                                    sizeof(struct acx_header),
                                     wl->stats.fw_stats_len);
        if (ret < 0) {
                wl1271_warning("acx statistics failed: %d", ret);
@@ -1470,8 +1472,8 @@ int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif,
 
        tsf_info->role_id = wlvif->role_id;
 
-       ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
-                                    tsf_info, sizeof(*tsf_info));
+       ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, tsf_info,
+                               sizeof(struct acx_header), sizeof(*tsf_info));
        if (ret < 0) {
                wl1271_warning("acx tsf info interrogate failed");
                goto out;
@@ -1752,7 +1754,7 @@ int wlcore_acx_average_rssi(struct wl1271 *wl, struct wl12xx_vif *wlvif,
 
        acx->role_id = wlvif->role_id;
        ret = wl1271_cmd_interrogate(wl, ACX_ROAMING_STATISTICS_TBL,
-                                    acx, sizeof(*acx));
+                                    acx, sizeof(*acx), sizeof(*acx));
        if (ret < 0) {
                wl1271_warning("acx roaming statistics failed: %d", ret);
                ret = -ENOMEM;
index 9e5416f..e65cdfc 100644 (file)
@@ -845,7 +845,8 @@ EXPORT_SYMBOL_GPL(wl1271_cmd_test);
  * @buf: buffer for the response, including all headers, must work with dma
  * @len: length of buf
  */
-int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len)
+int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf,
+                          size_t cmd_len, size_t res_len)
 {
        struct acx_header *acx = buf;
        int ret;
@@ -854,10 +855,10 @@ int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len)
 
        acx->id = cpu_to_le16(id);
 
-       /* payload length, does not include any headers */
-       acx->len = cpu_to_le16(len - sizeof(*acx));
+       /* response payload length, does not include any headers */
+       acx->len = cpu_to_le16(res_len - sizeof(*acx));
 
-       ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx), len);
+       ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, cmd_len, res_len);
        if (ret < 0)
                wl1271_error("INTERROGATE command failed");
 
index fd34123..323d4a8 100644 (file)
@@ -45,7 +45,8 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
                     enum ieee80211_band band, int channel);
 int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif);
 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
-int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
+int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf,
+                          size_t cmd_len, size_t res_len);
 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
 int wlcore_cmd_configure_failsafe(struct wl1271 *wl, u16 id, void *buf,
                                  size_t len, unsigned long valid_rets);
index a3b7d95..ddad58f 100644 (file)
@@ -179,7 +179,8 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
                goto out_sleep;
        }
 
-       ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd));
+       ret = wl1271_cmd_interrogate(wl, ie_id, cmd,
+                                    sizeof(struct acx_header), sizeof(*cmd));
        if (ret < 0) {
                wl1271_warning("testmode cmd interrogate failed: %d", ret);
                goto out_free;