wl1251: implement disconnect command properly
authorGrazvydas Ignotas <notasas@gmail.com>
Fri, 13 Feb 2015 23:31:28 +0000 (01:31 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 20 Feb 2015 22:05:29 +0000 (00:05 +0200)
Currently the driver uses a disconnect command with 4 data bytes
by reusing wl1251_cmd_template_set(), however the data length is
supposed to be 8 bytes. This doesn't seem to causing any bad effects,
but it's better to send correct commands.

Tested on pandora board to confirm that idle mode is still working
after this patch with no change in current draw.

drivers/net/wireless/wl1251/cmd.c
drivers/net/wireless/wl1251/cmd.h
drivers/net/wireless/wl1251/ps.c

index c1b3abd..8215104 100644 (file)
@@ -326,6 +326,28 @@ out:
        return ret;
 }
 
        return ret;
 }
 
+int wl1251_cmd_disconnect(struct wl1251 *wl)
+{
+       struct wl1251_cmd_disconnect *cmd;
+       int ret;
+
+       wl1251_debug(DEBUG_CMD, "cmd disconnect");
+
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd)
+               return -ENOMEM;
+
+       cmd->rx_config_options = wl->rx_config;
+       cmd->rx_filter_options = 0;
+
+       ret = wl1251_cmd_send(wl, CMD_DISCONNECT, cmd, sizeof(*cmd));
+       if (ret < 0)
+               wl1251_error("cmd disconnect failed: %d", ret);
+
+       kfree(cmd);
+       return ret;
+}
+
 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode)
 {
        struct wl1251_cmd_ps_params *ps_params = NULL;
 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode)
 {
        struct wl1251_cmd_ps_params *ps_params = NULL;
index d824ff9..3df8179 100644 (file)
@@ -39,6 +39,7 @@ int wl1251_cmd_data_path_rx(struct wl1251 *wl, u8 channel, bool enable);
 int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable);
 int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
                    u16 beacon_interval, u8 dtim_interval);
 int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable);
 int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
                    u16 beacon_interval, u8 dtim_interval);
+int wl1251_cmd_disconnect(struct wl1251 *wl);
 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
 int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
                           size_t len);
 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
 int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
                           size_t len);
@@ -282,6 +283,13 @@ struct cmd_join {
        u8 reserved;
 } __packed;
 
        u8 reserved;
 } __packed;
 
+struct wl1251_cmd_disconnect {
+       struct wl1251_cmd_header header;
+
+       u32 rx_config_options;
+       u32 rx_filter_options;
+} __packed;
+
 struct cmd_enabledisable_path {
        struct wl1251_cmd_header header;
 
 struct cmd_enabledisable_path {
        struct wl1251_cmd_header header;
 
index 0dbdd24..a52ff7a 100644 (file)
@@ -140,7 +140,7 @@ int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_station_mode mode)
                if (ret < 0)
                        return ret;
 
                if (ret < 0)
                        return ret;
 
-               ret = wl1251_cmd_template_set(wl, CMD_DISCONNECT, NULL, 0);
+               ret = wl1251_cmd_disconnect(wl);
                if (ret < 0)
                        return ret;
                break;
                if (ret < 0)
                        return ret;
                break;