wl1271: implement cmd_disconnect
[linux-2.6.git] / drivers / net / wireless / wl12xx / wl1271_cmd.c
index ac93efd53f2a469c819031b11e2254bbd324f859..d09ad12119770c2ade2703a87c993cd60081836a 100644 (file)
@@ -191,7 +191,6 @@ int wl1271_cmd_join(struct wl1271 *wl)
                        do_cal = false;
        }
 
-
        join = kzalloc(sizeof(*join), GFP_KERNEL);
        if (!join) {
                ret = -ENOMEM;
@@ -825,3 +824,34 @@ out:
 
        return ret;
 }
+
+int wl1271_cmd_disconnect(struct wl1271 *wl)
+{
+       struct wl1271_cmd_disconnect *cmd;
+       int ret = 0;
+
+       wl1271_debug(DEBUG_CMD, "cmd disconnect");
+
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       cmd->rx_config_options = wl->rx_config;
+       cmd->rx_filter_options = wl->rx_filter;
+       /* disconnect reason is not used in immediate disconnections */
+       cmd->type = DISCONNECT_IMMEDIATE;
+
+       ret = wl1271_cmd_send(wl, CMD_DISCONNECT, cmd, sizeof(*cmd));
+       if (ret < 0) {
+               wl1271_error("failed to send disconnect command");
+               goto out_free;
+       }
+
+out_free:
+       kfree(cmd);
+
+out:
+       return ret;
+}