From 6ae91e2f6737438ad50d095bd2095d008a89aa38 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 5 Jan 2011 15:39:07 -0600 Subject: [PATCH] wimax: if the device is connected at startup, force it to disconnect Otherwise it doesn't auto-scan and we get no network list. As a later optimization, we could detect this, call iwmx_sdk_get_connected_network() to get the current NSP, match that up with a connection, and "assume" the connection like we do for Ethernet devices. --- src/wimax/nm-device-wimax.c | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/wimax/nm-device-wimax.c b/src/wimax/nm-device-wimax.c index bbb14718f2..870759e333 100644 --- a/src/wimax/nm-device-wimax.c +++ b/src/wimax/nm-device-wimax.c @@ -587,12 +587,33 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_POSTPONE; } +static void +force_disconnect (struct wmxsdk *sdk) +{ + WIMAX_API_DEVICE_STATUS status; + int ret; + + g_return_if_fail (sdk != NULL); + + status = iwmxsdk_status_get (sdk); + if ((int) status < 0) { + nm_log_err (LOGD_WIMAX, "Failed to read WiMAX device status: %d", status); + return; + } + + if ( status == WIMAX_API_DEVICE_STATUS_Connecting + || status == WIMAX_API_DEVICE_STATUS_Data_Connected) { + ret = iwmx_sdk_disconnect (sdk); + if (ret < 0 && ret != -EINPROGRESS) { + nm_log_err (LOGD_WIMAX, "Failed to disconnect WiMAX device: %d", ret); + } + } +} + static void real_deactivate_quickly (NMDevice *device) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); - WIMAX_API_DEVICE_STATUS status; - int ret; clear_activation_timeout (NM_DEVICE_WIMAX (device)); clear_link_timeout (NM_DEVICE_WIMAX (device)); @@ -603,18 +624,7 @@ real_deactivate_quickly (NMDevice *device) /* Read explicit status here just to make sure we have the most * up-to-date status and to ensure we disconnect if needed. */ - status = iwmxsdk_status_get (priv->sdk); - if ((int) status < 0) { - nm_log_err (LOGD_WIMAX, "Failed to read WiMAX device status: %d", status); - } else { - if ( status == WIMAX_API_DEVICE_STATUS_Connecting - || status == WIMAX_API_DEVICE_STATUS_Data_Connected) { - ret = iwmx_sdk_disconnect (priv->sdk); - if (ret < 0 && ret != -EINPROGRESS) { - nm_log_err (LOGD_WIMAX, "Failed to disconnect WiMAX device: %d", ret); - } - } - } + force_disconnect (priv->sdk); } } @@ -662,10 +672,14 @@ wmx_state_change_cb (struct wmxsdk *wmxsdk, return; } break; - case WIMAX_API_DEVICE_STATUS_Ready: - case WIMAX_API_DEVICE_STATUS_Scanning: case WIMAX_API_DEVICE_STATUS_Connecting: case WIMAX_API_DEVICE_STATUS_Data_Connected: + /* If for some reason we're initially connected, force a disconnect here */ + if (state < NM_DEVICE_STATE_DISCONNECTED) + force_disconnect (wmxsdk); + /* Fall through */ + case WIMAX_API_DEVICE_STATUS_Ready: + case WIMAX_API_DEVICE_STATUS_Scanning: if (priv->wimaxd_enabled == FALSE) { priv->wimaxd_enabled = TRUE; if (update_availability (self, old_available))