From 7f66493dafee614acd1b7d56e75c34c4c6221b5f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 27 Aug 2022 20:25:22 +0200 Subject: [PATCH] drivers/usbhid-ups.c: hid_ups_walk(): for HU_WALKMODE_FULL_UPDATE with "pollonly" mode, re-read HU_FLAG_SEMI_STATIC and HU_FLAG_STATIC entries to detect "Driver stale" situations [#1624] --- drivers/usbhid-ups.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index b3b714afa0..86e22affd5 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -1422,11 +1422,23 @@ static bool_t hid_ups_walk(walkmode_t mode) case HU_WALKMODE_FULL_UPDATE: /* These don't need polling after initinfo() */ - if (item->hidflags & (HU_FLAG_ABSENT | HU_TYPE_CMD | HU_FLAG_STATIC)) + if (item->hidflags & (HU_FLAG_ABSENT | HU_TYPE_CMD)) continue; - /* These need to be polled after user changes (setvar / instcmd) */ - if ( (item->hidflags & HU_FLAG_SEMI_STATIC) && (data_has_changed == FALSE) ) + /* These don't need polling after initinfo() normally + * However in "pollonly" mode we use these to detect "Data stale" + * condition (e.g. cable disconnected) by failing the reads: + */ + if ((item->hidflags & HU_FLAG_STATIC) && use_interrupt_pipe) + continue; + + /* These need to be polled after user changes (setvar / instcmd) + * or to detect "Data stale" in "pollonly" mode + */ + if ( (item->hidflags & HU_FLAG_SEMI_STATIC) + && (data_has_changed == FALSE) + && use_interrupt_pipe + ) continue; break; @@ -1530,7 +1542,7 @@ static bool_t hid_ups_walk(walkmode_t mode) if (ups_infoval_set(item, value) != 1) continue; - if (mode == HU_WALKMODE_INIT) { + if (mode == HU_WALKMODE_INIT || (!use_interrupt_pipe)) { info_lkp_t *info_lkp; dstate_setflags(item->info_type, item->info_flags);