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.
This commit is contained in:
Andrew Zaborowski 2018-09-22 18:48:25 +02:00 committed by Denis Kenzior
parent daf248e1ba
commit 567baed2c4
2 changed files with 4 additions and 20 deletions

View File

@ -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;
}

View File

@ -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: