staging: wilc1000: handle station dump cfg ops from cfg80211 context
authorAjay Singh <ajay.kathat@microchip.com>
Sun, 2 Dec 2018 18:02:59 +0000 (18:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Dec 2018 08:49:45 +0000 (09:49 +0100)
Refactor code to handle dump_station() callback from cfg80211 context.
Instead of deferring issue of wid command now send it directly from cfg
context. Also making use of wilc_get_rssi() error status in case there
is a failure to post the wid command to the firmware.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/host_interface.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c

index 6b1c9e3733c43ed57cef0b8386a13457bd788641..1910f9a77996864d9bd35f8d617dfa47143d25dd 100644 (file)
@@ -1678,27 +1678,6 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
                wilc_disconnect(vif, 1);
 }
 
-static void handle_get_rssi(struct work_struct *work)
-{
-       struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
-       struct wilc_vif *vif = msg->vif;
-       int result;
-       struct wid wid;
-
-       wid.id = WID_RSSI;
-       wid.type = WID_CHAR;
-       wid.val = msg->body.data;
-       wid.size = sizeof(char);
-
-       result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
-                                     wilc_get_vif_idx(vif));
-       if (result)
-               netdev_err(vif->ndev, "Failed to get RSSI value\n");
-
-       complete(&msg->work_comp);
-       /* free 'msg' data in caller */
-}
-
 static void handle_get_statistics(struct work_struct *work)
 {
        struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2620,34 +2599,22 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
 
 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
 {
+       struct wid wid;
        int result;
-       struct host_if_msg *msg;
 
        if (!rssi_level) {
                netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__);
                return -EFAULT;
        }
 
-       msg = wilc_alloc_work(vif, handle_get_rssi, true);
-       if (IS_ERR(msg))
-               return PTR_ERR(msg);
-
-       msg->body.data = kzalloc(sizeof(s8), GFP_KERNEL);
-       if (!msg->body.data) {
-               kfree(msg);
-               return -ENOMEM;
-       }
-
-       result = wilc_enqueue_work(msg);
-       if (result) {
-               netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
-       } else {
-               wait_for_completion(&msg->work_comp);
-               *rssi_level = *msg->body.data;
-       }
-
-       kfree(msg->body.data);
-       kfree(msg);
+       wid.id = WID_RSSI;
+       wid.type = WID_CHAR;
+       wid.size = sizeof(char);
+       wid.val = rssi_level;
+       result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+                                     wilc_get_vif_idx(vif));
+       if (result)
+               netdev_err(vif->ndev, "Failed to get RSSI value\n");
 
        return result;
 }
index 18370eff7ecf97466c42ad566ee4e22c68cbdb92..4802ce9c54287f9cb24ab7755ba58c9e74b21ba1 100644 (file)
@@ -1659,13 +1659,16 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev,
 {
        struct wilc_priv *priv = wiphy_priv(wiphy);
        struct wilc_vif *vif = netdev_priv(priv->dev);
+       int ret;
 
        if (idx != 0)
                return -ENOENT;
 
        sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
 
-       wilc_get_rssi(vif, &sinfo->signal);
+       ret = wilc_get_rssi(vif, &sinfo->signal);
+       if (ret)
+               return ret;
 
        memcpy(mac, priv->associated_bss, ETH_ALEN);
        return 0;