mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 13:59:24 +01:00
device: Restore device Powered state
After wiphy comes out of the rfkill state and is again powered, restore the device state to Powered if needed.
This commit is contained in:
parent
0dd8114970
commit
9e1ba84f26
29
src/device.c
29
src/device.c
@ -45,9 +45,11 @@ struct device {
|
|||||||
struct wiphy *wiphy;
|
struct wiphy *wiphy;
|
||||||
struct netdev *netdev;
|
struct netdev *netdev;
|
||||||
|
|
||||||
bool powered : 1;
|
bool powered : 1; /* Current IFUP state */
|
||||||
|
bool dbus_powered : 1; /* Last IFUP state wanted via D-Bus */
|
||||||
|
|
||||||
uint32_t ap_roam_watch;
|
uint32_t ap_roam_watch;
|
||||||
|
uint32_t wiphy_rfkill_watch;
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t netdev_watch;
|
static uint32_t netdev_watch;
|
||||||
@ -150,6 +152,8 @@ static struct l_dbus_message *device_property_set_powered(struct l_dbus *dbus,
|
|||||||
if (!l_dbus_message_iter_get_variant(new_value, "b", &powered))
|
if (!l_dbus_message_iter_get_variant(new_value, "b", &powered))
|
||||||
return dbus_error_invalid_args(message);
|
return dbus_error_invalid_args(message);
|
||||||
|
|
||||||
|
device->dbus_powered = powered;
|
||||||
|
|
||||||
if (powered == device->powered) {
|
if (powered == device->powered) {
|
||||||
complete(dbus, message, NULL);
|
complete(dbus, message, NULL);
|
||||||
|
|
||||||
@ -380,6 +384,23 @@ static void device_netdev_notify(struct netdev *netdev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void device_wiphy_state_changed_event(struct wiphy *wiphy,
|
||||||
|
enum wiphy_state_watch_event event,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct device *device = user_data;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case WIPHY_STATE_WATCH_EVENT_RFKILLED:
|
||||||
|
break;
|
||||||
|
case WIPHY_STATE_WATCH_EVENT_POWERED:
|
||||||
|
if (device->dbus_powered)
|
||||||
|
netdev_set_powered(device->netdev, true,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct device *device_create(struct wiphy *wiphy, struct netdev *netdev)
|
struct device *device_create(struct wiphy *wiphy, struct netdev *netdev)
|
||||||
{
|
{
|
||||||
struct device *device;
|
struct device *device;
|
||||||
@ -412,6 +433,11 @@ struct device *device_create(struct wiphy *wiphy, struct netdev *netdev)
|
|||||||
|
|
||||||
device->powered = netdev_get_is_up(netdev);
|
device->powered = netdev_get_is_up(netdev);
|
||||||
|
|
||||||
|
device->dbus_powered = true;
|
||||||
|
device->wiphy_rfkill_watch =
|
||||||
|
wiphy_state_watch_add(wiphy, device_wiphy_state_changed_event,
|
||||||
|
device, NULL);
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,6 +452,7 @@ void device_remove(struct device *device)
|
|||||||
scan_ifindex_remove(device->index);
|
scan_ifindex_remove(device->index);
|
||||||
|
|
||||||
netdev_frame_watch_remove(device->netdev, device->ap_roam_watch);
|
netdev_frame_watch_remove(device->netdev, device->ap_roam_watch);
|
||||||
|
wiphy_state_watch_remove(device->wiphy, device->wiphy_rfkill_watch);
|
||||||
|
|
||||||
l_free(device);
|
l_free(device);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user