From 7c34a37e73104b8b529247fe7edb8ca7855dbd6d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 19 Sep 2012 13:42:40 -0500 Subject: [PATCH] wifi: mode changes must happen when device is down With both WEXT and nl80211; this wasn't an issue before because devices can still scan in adhoc mode. But we do need to ensure that the device is in Infrastructure mode when we deactivate a Hotspot. --- src/nm-device-wifi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index d229e8e070..8ea0ffb10f 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -980,10 +980,16 @@ deactivate (NMDevice *dev) /* Ensure we're in infrastructure mode after deactivation; some devices * (usually older ones) don't scan well in adhoc mode. */ - wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA); - priv->mode = NM_802_11_MODE_INFRA; - if (priv->mode != old_mode) + if (wifi_utils_get_mode (priv->wifi_data) != NM_802_11_MODE_INFRA) { + nm_device_hw_take_down (NM_DEVICE (self), TRUE); + wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA); + nm_device_hw_bring_up (NM_DEVICE (self), TRUE, NULL); + } + + if (priv->mode != NM_802_11_MODE_INFRA) { + priv->mode = NM_802_11_MODE_INFRA; g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_MODE); + } /* Ensure we trigger a scan after deactivating a Hotspot */ if (old_mode == NM_802_11_MODE_AP) {