staging: ks7010: factor out some functions from hostif_init
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Mon, 26 Mar 2018 16:52:52 +0000 (18:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Mar 2018 11:53:09 +0000 (13:53 +0200)
This commit factors out some init functions from hostif_init
to improve readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_hostif.c

index e0ddf3f0327e07ae297c967e850962a482cc437f..a02b73e4e81ff7942c505a50e067644b7bc02d50 100644 (file)
@@ -2357,50 +2357,79 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
        tasklet_schedule(&priv->sme_task);
 }
 
-int hostif_init(struct ks_wlan_private *priv)
+static inline void hostif_aplist_init(struct ks_wlan_private *priv)
 {
-       int i;
-
+       size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t);
        priv->aplist.size = 0;
-       for (i = 0; i < LOCAL_APLIST_MAX; i++)
-               memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t));
+       memset(&priv->aplist.ap[0], 0, size);
+}
+
+static inline void hostif_status_init(struct ks_wlan_private *priv)
+{
        priv->infra_status = 0;
        priv->current_rate = 4;
        priv->connect_status = DISCONNECT_STATUS;
+}
 
-       spin_lock_init(&priv->multicast_spin);
+static inline void hostif_sme_init(struct ks_wlan_private *priv)
+{
+       priv->sme_i.sme_status = SME_IDLE;
+       priv->sme_i.qhead = 0;
+       priv->sme_i.qtail = 0;
+       spin_lock_init(&priv->sme_i.sme_spin);
+       priv->sme_i.sme_flag = 0;
+       tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv);
+}
 
-       spin_lock_init(&priv->dev_read_lock);
-       init_waitqueue_head(&priv->devread_wait);
-       priv->dev_count = 0;
-       atomic_set(&priv->event_count, 0);
-       atomic_set(&priv->rec_count, 0);
+static inline void hostif_wpa_init(struct ks_wlan_private *priv)
+{
+       memset(&priv->wpa, 0, sizeof(priv->wpa));
+       priv->wpa.rsn_enabled = 0;
+       priv->wpa.mic_failure.failure = 0;
+       priv->wpa.mic_failure.last_failure_time = 0;
+       priv->wpa.mic_failure.stop = 0;
+}
 
-       /* for power save */
+static inline void hostif_power_save_init(struct ks_wlan_private *priv)
+{
        atomic_set(&priv->psstatus.status, PS_NONE);
        atomic_set(&priv->psstatus.confirm_wait, 0);
        atomic_set(&priv->psstatus.snooze_guard, 0);
        init_completion(&priv->psstatus.wakeup_wait);
        INIT_WORK(&priv->wakeup_work, ks_wlan_hw_wakeup_task);
+}
+
+static inline void hostif_pmklist_init(struct ks_wlan_private *priv)
+{
+       int i;
 
-       /* WPA */
-       memset(&priv->wpa, 0, sizeof(priv->wpa));
-       priv->wpa.rsn_enabled = 0;
-       priv->wpa.mic_failure.failure = 0;
-       priv->wpa.mic_failure.last_failure_time = 0;
-       priv->wpa.mic_failure.stop = 0;
        memset(&priv->pmklist, 0, sizeof(priv->pmklist));
        INIT_LIST_HEAD(&priv->pmklist.head);
        for (i = 0; i < PMK_LIST_MAX; i++)
                INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
+}
 
-       priv->sme_i.sme_status = SME_IDLE;
-       priv->sme_i.qhead = 0;
-       priv->sme_i.qtail = 0;
-       spin_lock_init(&priv->sme_i.sme_spin);
-       priv->sme_i.sme_flag = 0;
+static inline void hostif_counters_init(struct ks_wlan_private *priv)
+{
+       priv->dev_count = 0;
+       atomic_set(&priv->event_count, 0);
+       atomic_set(&priv->rec_count, 0);
+}
 
-       tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv);
+int hostif_init(struct ks_wlan_private *priv)
+{
+       hostif_aplist_init(priv);
+       hostif_status_init(priv);
+
+       spin_lock_init(&priv->multicast_spin);
+       spin_lock_init(&priv->dev_read_lock);
+       init_waitqueue_head(&priv->devread_wait);
+
+       hostif_counters_init(priv);
+       hostif_power_save_init(priv);
+       hostif_wpa_init(priv);
+       hostif_pmklist_init(priv);
+       hostif_sme_init(priv);
 
        return 0;
 }