trivial: Move the UNREACHABLE inhibit to common code

This commit is contained in:
Richard Hughes 2022-03-15 11:15:18 +00:00
parent 75ba49ebf0
commit b4e88bae49
3 changed files with 6 additions and 5 deletions

View File

@ -2955,6 +2955,8 @@ fu_device_remove_flag(FuDevice *self, FwupdDeviceFlags flag)
/* allow it to be updatable again */
if (flag & FWUPD_DEVICE_FLAG_NEEDS_ACTIVATION)
fu_device_uninhibit(self, "needs-activation");
if (flag & FWUPD_DEVICE_FLAG_UNREACHABLE)
fu_device_uninhibit(self, "unreachable");
}
/**
@ -2996,6 +2998,10 @@ fu_device_add_flag(FuDevice *self, FwupdDeviceFlags flag)
/* don't let devices be updated until activated */
if (flag & FWUPD_DEVICE_FLAG_NEEDS_ACTIVATION)
fu_device_inhibit(self, "needs-activation", "Pending activation");
/* do not let devices be updated until back in range */
if (flag & FWUPD_DEVICE_FLAG_UNREACHABLE)
fu_device_inhibit(self, "unreachable", "Device is unreachable");
}
typedef struct {

View File

@ -188,7 +188,6 @@ fu_logitech_hidpp_device_ping(FuLogitechHidPpDevice *self, GError **error)
}
if (g_error_matches(error_local, G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE)) {
fu_device_add_flag(FU_DEVICE(self), FWUPD_DEVICE_FLAG_UNREACHABLE);
fu_device_inhibit(FU_DEVICE(self), "unreachable", "device is unreachable");
return TRUE;
}
g_propagate_error(error, g_steal_pointer(&error_local));
@ -197,12 +196,10 @@ fu_logitech_hidpp_device_ping(FuLogitechHidPpDevice *self, GError **error)
/* device no longer asleep */
fu_device_remove_flag(FU_DEVICE(self), FWUPD_DEVICE_FLAG_UNREACHABLE);
fu_device_uninhibit(FU_DEVICE(self), "unreachable");
children = fu_device_get_children(FU_DEVICE(self));
for (guint i = 0; i < children->len; i++) {
FuDevice *radio = g_ptr_array_index(children, i);
fu_device_remove_flag(radio, FWUPD_DEVICE_FLAG_UNREACHABLE);
fu_device_uninhibit(radio, "unreachable");
}
/* if the device index is unset, grab it from the reply */

View File

@ -139,12 +139,10 @@ fu_logitech_hidpp_runtime_bolt_update_paired_device(FuLogitechHidPpRuntimeBolt *
GPtrArray *children = NULL;
/* any successful 'ping' will clear this */
fu_device_add_flag(FU_DEVICE(child), FWUPD_DEVICE_FLAG_UNREACHABLE);
fu_device_inhibit(FU_DEVICE(child), "unreachable", "device is unreachable");
children = fu_device_get_children(FU_DEVICE(child));
for (guint i = 0; i < children->len; i++) {
FuDevice *radio = g_ptr_array_index(children, i);
fu_device_add_flag(radio, FWUPD_DEVICE_FLAG_UNREACHABLE);
fu_device_inhibit(radio, "unreachable", "device is unreachable");
}
}
} else if (reachable) {