Skip to content

Commit c3e43dc

Browse files
committed
drivers/usbhid-ups.c, NEWS.adoc: apply disable_fix_report_desc, interruptsize and interruptonly before comm_driver->open_dev() [networkupstools#1512, networkupstools#1575]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent bfc08bb commit c3e43dc

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

NEWS.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ https://github.com/networkupstools/nut/milestone/11
7777
use of `struct timeval={-1,-1}` as a trigger to `select(..., NULL)`,
7878
as logged in one part of code and not handled in the other, for the
7979
indefinite wait [#1922, #2392, #2686, #2670]
80+
* The `disable_fix_report_desc` option introduced for `usbhid-ups` driver
81+
since NUT v2.8.1 was not applied for early dialog with the device while
82+
its report descriptors were being discovered. [#1575, #1512]
8083
8184
- development iterations of NUT should now identify with not only the semantic
8285
version of a preceding release, but with git-derived information about the

drivers/usbhid-ups.c

+23-19
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030

3131
#define DRIVER_NAME "Generic HID driver"
32-
#define DRIVER_VERSION "0.59"
32+
#define DRIVER_VERSION "0.60"
3333

3434
#define HU_VAR_WAITBEFORERECONNECT "waitbeforereconnect"
3535

@@ -1399,6 +1399,27 @@ void upsdrv_initups(void)
13991399
subdriver_matcher->next = regex_matcher;
14001400
#endif /* SHUT_MODE / USB */
14011401

1402+
/* First activate the few tweaks which can impact device detection */
1403+
1404+
/* Activate Powercom tweaks */
1405+
if (testvar("interruptonly")) {
1406+
interrupt_only = 1;
1407+
}
1408+
1409+
val = getval("interruptsize");
1410+
if (val) {
1411+
int ipv = atoi(val);
1412+
if (ipv > 0) {
1413+
interrupt_size = (unsigned int)ipv;
1414+
} else {
1415+
fatalx(EXIT_FAILURE, "Error: invalid interruptsize: %d", ipv);
1416+
}
1417+
}
1418+
1419+
if (testvar("disable_fix_report_desc")) {
1420+
disable_fix_report_desc = 1;
1421+
}
1422+
14021423
/* Search for the first supported UPS matching the
14031424
regular expression (USB) or device_path (SHUT) */
14041425
ret = comm_driver->open_dev(&udev, &curDevice, subdriver_matcher, &callback);
@@ -1411,10 +1432,7 @@ void upsdrv_initups(void)
14111432
hd->Vendor ? hd->Vendor : "unknown",
14121433
hd->Product ? hd->Product : "unknown");
14131434

1414-
/* Activate Powercom tweaks */
1415-
if (testvar("interruptonly")) {
1416-
interrupt_only = 1;
1417-
}
1435+
/* Later activate the relatively cosmetic tweaks */
14181436

14191437
/* Activate Cyberpower/APC tweaks */
14201438
if (testvar("onlinedischarge") || testvar("onlinedischarge_onbattery")) {
@@ -1544,20 +1562,6 @@ void upsdrv_initups(void)
15441562
lbrb_log_delay_without_calibrating = 1;
15451563
}
15461564

1547-
if (testvar("disable_fix_report_desc")) {
1548-
disable_fix_report_desc = 1;
1549-
}
1550-
1551-
val = getval("interruptsize");
1552-
if (val) {
1553-
int ipv = atoi(val);
1554-
if (ipv > 0) {
1555-
interrupt_size = (unsigned int)ipv;
1556-
} else {
1557-
fatalx(EXIT_FAILURE, "Error: invalid interruptsize: %d", ipv);
1558-
}
1559-
}
1560-
15611565
if (hid_ups_walk(HU_WALKMODE_INIT) == FALSE) {
15621566
fatalx(EXIT_FAILURE, "Can't initialize data from HID UPS");
15631567
}

0 commit comments

Comments
 (0)