From 1b799d2d847e7d87c06ff899417345f06df19221 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 24 Aug 2015 12:11:38 +1000 Subject: [PATCH] hidpp10: only run the pairing information commands if the first one succeeds Still try to run the other commands though, they're not receiver-related and may work on a device that's not on a unifying receiver. Signed-off-by: Peter Hutterer --- src/hidpp10.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index aed307f0..09aef618 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -241,21 +241,19 @@ hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev int res; res = hidpp10_request_command(device, &pairing_information); - if (res) - return -1; + if (res == 0) { + dev->report_interval = pairing_information.msg.string[2]; + dev->wpid = (pairing_information.msg.string[3] << 8) | + pairing_information.msg.string[4]; + dev->device_type = pairing_information.msg.string[7]; - dev->report_interval = pairing_information.msg.string[2]; - dev->wpid = (pairing_information.msg.string[3] << 8) | - pairing_information.msg.string[4]; - dev->device_type = pairing_information.msg.string[7]; - - res = hidpp10_request_command(device, &device_name); - if (res) - return -1; - - name_size = device_name.msg.string[1]; - memcpy(dev->name, &device_name.msg.string[2], sizeof(device_name.msg.string)); - dev->name[min(name_size, sizeof(dev->name) - 1)] = '\0'; + res = hidpp10_request_command(device, &device_name); + if (res) + return -1; + name_size = device_name.msg.string[1]; + memcpy(dev->name, &device_name.msg.string[2], sizeof(device_name.msg.string)); + dev->name[min(name_size, sizeof(dev->name) - 1)] = '\0'; + } /* * This may fail on some devices