From 567baed2c44820c3c0dced62d4997ffa71217ec6 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 22 Sep 2018 18:48:25 +0200 Subject: [PATCH] station: Create interface simliarly to AP, AdHoc interfaces Instead of creating the Station interface in device.c create it directly on the netdev watch event the same way that the AP and AdHoc interfaces are created and freed. This fixes some minor incosistencies, for example station_free was previously called twice, once from device.c and once from the netdev watch. device.c would previously keep the pointer returned by station_create() but that pointer was not actually useful so remove it. Autotests still seem to pass. --- src/device.c | 21 +-------------------- src/station.c | 3 +++ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/device.c b/src/device.c index 4613f84a..f7bd1fa2 100644 --- a/src/device.c +++ b/src/device.c @@ -283,11 +283,6 @@ static void set_mode_cb(struct netdev *netdev, int result, void *user_data) l_dbus_property_changed(cb_data->dbus, netdev_get_path(cb_data->device->netdev), IWD_DEVICE_INTERFACE, "Mode"); - - /* TODO: Special case, remove when Device/Station split is made */ - l_dbus_property_changed(cb_data->dbus, - netdev_get_path(cb_data->device->netdev), - IWD_DEVICE_INTERFACE, "State"); } static struct l_dbus_message *device_property_set_mode(struct l_dbus *dbus, @@ -368,21 +363,11 @@ static void device_netdev_notify(struct netdev *netdev, switch (event) { case NETDEV_WATCH_EVENT_UP: device->powered = true; + l_dbus_property_changed(dbus, netdev_get_path(device->netdev), IWD_DEVICE_INTERFACE, "Powered"); - - /* TODO: Remove when Device/Station split is done */ - if (netdev_get_iftype(device->netdev) != NETDEV_IFTYPE_STATION) - return; - - device->station = station_create(device->wiphy, device->netdev); break; case NETDEV_WATCH_EVENT_DOWN: - if (device->station) { - station_free(device->station); - device->station = NULL; - } - device->powered = false; l_dbus_property_changed(dbus, netdev_get_path(device->netdev), @@ -433,10 +418,6 @@ struct device *device_create(struct wiphy *wiphy, struct netdev *netdev) device->powered = netdev_get_is_up(netdev); - if (device->powered && - netdev_get_iftype(netdev) == NETDEV_IFTYPE_STATION) - device->station = station_create(device->wiphy, device->netdev); - return device; } diff --git a/src/station.c b/src/station.c index 4a3a29f9..d2d0025c 100644 --- a/src/station.c +++ b/src/station.c @@ -2330,6 +2330,9 @@ static void station_netdev_watch(struct netdev *netdev, switch (event) { case NETDEV_WATCH_EVENT_UP: case NETDEV_WATCH_EVENT_NEW: + if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_STATION && + netdev_get_is_up(netdev)) + station_create(netdev_get_wiphy(netdev), netdev); break; case NETDEV_WATCH_EVENT_DOWN: case NETDEV_WATCH_EVENT_DEL: