3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-19 02:39:29 +01:00

device: Move common code to device_reset_connection_state

This commit is contained in:
Andrew Zaborowski 2016-12-23 05:38:08 -05:00 committed by Denis Kenzior
parent f73b751124
commit 7e81dcac6f

View File

@ -489,14 +489,14 @@ static void device_enter_state(struct device *device, enum device_state state)
device_state_watch_func_t, state); device_state_watch_func_t, state);
} }
static void device_disassociated(struct device *device) static void device_reset_connection_state(struct device *device)
{ {
struct network *network = device->connected_network; struct network *network = device->connected_network;
struct l_dbus *dbus = dbus_get_bus(); struct l_dbus *dbus = dbus_get_bus();
l_debug("%d", device->index); if (!network)
return;
if (network) {
if (device->state == DEVICE_STATE_CONNECTED) if (device->state == DEVICE_STATE_CONNECTED)
network_disconnected(network); network_disconnected(network);
@ -507,11 +507,16 @@ static void device_disassociated(struct device *device)
device->connected_mde = NULL; device->connected_mde = NULL;
l_dbus_property_changed(dbus, device_get_path(device), l_dbus_property_changed(dbus, device_get_path(device),
IWD_DEVICE_INTERFACE, IWD_DEVICE_INTERFACE, "ConnectedNetwork");
"ConnectedNetwork");
l_dbus_property_changed(dbus, network_get_path(network), l_dbus_property_changed(dbus, network_get_path(network),
IWD_NETWORK_INTERFACE, "Connected"); IWD_NETWORK_INTERFACE, "Connected");
} }
static void device_disassociated(struct device *device)
{
l_debug("%d", device->index);
device_reset_connection_state(device);
device_enter_state(device, DEVICE_STATE_DISCONNECTED); device_enter_state(device, DEVICE_STATE_DISCONNECTED);
@ -869,9 +874,6 @@ static void device_disconnect_cb(struct netdev *netdev, bool success,
int device_disconnect(struct device *device) int device_disconnect(struct device *device)
{ {
struct network *network = device->connected_network;
struct l_dbus *dbus = dbus_get_bus();
if (device->state == DEVICE_STATE_DISCONNECTING) if (device->state == DEVICE_STATE_DISCONNECTING)
return -EBUSY; return -EBUSY;
@ -886,19 +888,7 @@ int device_disconnect(struct device *device)
* connected so we may as well indicate now that we're no longer * connected so we may as well indicate now that we're no longer
* connected. * connected.
*/ */
if (device->state == DEVICE_STATE_CONNECTED) device_reset_connection_state(device);
network_disconnected(network);
device->connected_bss = NULL;
device->connected_network = NULL;
l_free(device->connected_mde);
device->connected_mde = NULL;
l_dbus_property_changed(dbus, device_get_path(device),
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
l_dbus_property_changed(dbus, network_get_path(network),
IWD_NETWORK_INTERFACE, "Connected");
device_enter_state(device, DEVICE_STATE_DISCONNECTING); device_enter_state(device, DEVICE_STATE_DISCONNECTING);
@ -1199,22 +1189,7 @@ static void device_netdev_notify(struct netdev *netdev,
dbus_pending_reply(&device->connect_pending, dbus_pending_reply(&device->connect_pending,
dbus_error_aborted(device->connect_pending)); dbus_error_aborted(device->connect_pending));
if (device->connected_network) { device_reset_connection_state(device);
struct network *network = device->connected_network;
device->connected_bss = NULL;
device->connected_network = NULL;
l_free(device->connected_mde);
device->connected_mde = NULL;
l_dbus_property_changed(dbus, device_get_path(device),
IWD_DEVICE_INTERFACE,
"ConnectedNetwork");
l_dbus_property_changed(dbus, network_get_path(network),
IWD_NETWORK_INTERFACE,
"Connected");
}
l_hashmap_foreach_remove(device->networks, l_hashmap_foreach_remove(device->networks,
device_remove_network, device); device_remove_network, device);