Move driver deinitialization away from hostapd.c
authorJouni Malinen <j@w1.fi>
Fri, 25 Dec 2009 16:32:44 +0000 (18:32 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 25 Dec 2009 16:32:44 +0000 (18:32 +0200)
This matches with the earlier change of moving driver initialization
and allows more control on how the driver context is managed.

hostapd/driver_i.h
hostapd/hostapd.c
hostapd/main.c
wpa_supplicant/ap.c

index 64e8c90..aa280f7 100644 (file)
 #include "drivers/driver.h"
 #include "ap/config.h"
 
-static inline void
-hostapd_driver_deinit(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL || hapd->driver->hapd_deinit == NULL)
-               return;
-       hapd->driver->hapd_deinit(hapd->drv_priv);
-}
-
 static inline int
 hostapd_set_ieee8021x(struct hostapd_data *hapd, struct wpa_bss_params *params)
 {
index fd8eb6d..588b02b 100644 (file)
@@ -819,8 +819,6 @@ void hostapd_interface_deinit(struct hostapd_iface *iface)
                hostapd_free_stas(hapd);
                hostapd_flush_old_stations(hapd);
                hostapd_cleanup(hapd);
-               if (j == iface->num_bss - 1 && hapd->driver)
-                       hostapd_driver_deinit(hapd);
        }
        for (j = 0; j < iface->num_bss; j++)
                os_free(iface->bss[j]);
index 0b9a2d5..79e2969 100644 (file)
@@ -291,7 +291,13 @@ hostapd_interface_init(struct hapd_interfaces *interfaces,
 
        if (hostapd_driver_init(iface) ||
            hostapd_setup_interface(iface)) {
+               const struct wpa_driver_ops *driver;
+               void *drv_priv;
+               driver = iface->bss[0]->driver;
+               drv_priv = iface->bss[0]->drv_priv;
                hostapd_interface_deinit(iface);
+               if (driver && driver->hapd_deinit)
+                       driver->hapd_deinit(drv_priv);
                return NULL;
        }
 
@@ -532,8 +538,16 @@ int main(int argc, char *argv[])
 
  out:
        /* Deinitialize all interfaces */
-       for (i = 0; i < interfaces.count; i++)
-               hostapd_interface_deinit(interfaces.iface[i]);
+       for (i = 0; i < interfaces.count; i++) {
+               struct hostapd_iface *iface = interfaces.iface[i];
+               const struct wpa_driver_ops *driver;
+               void *drv_priv;
+               driver = iface->bss[0]->driver;
+               drv_priv = iface->bss[0]->drv_priv;
+               hostapd_interface_deinit(iface);
+               if (driver && driver->hapd_deinit)
+                       driver->hapd_deinit(drv_priv);
+       }
        os_free(interfaces.iface);
 
        hostapd_global_deinit(pid_file);
index 2fc875c..ac7e5db 100644 (file)
@@ -519,11 +519,18 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 
 void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
 {
+       const struct wpa_driver_ops *driver;
+       void *drv_priv;
+
        if (wpa_s->ap_iface == NULL)
                return;
 
+       driver = wpa_s->ap_iface->bss[0]->driver;
+       drv_priv = wpa_s->ap_iface->bss[0]->drv_priv;
        hostapd_interface_deinit(wpa_s->ap_iface);
        wpa_s->ap_iface = NULL;
+       if (driver && driver->hapd_deinit)
+               driver->hapd_deinit(drv_priv);
 }