Commit 657d6dc4 authored by Nikolai Kondrashov's avatar Nikolai Kondrashov Committed by Jiri Kosina

HID: huion: Fail on parameter retrieval errors

Fail Huion tablet interface enabling and probing, if parameter retrieval
fails. Move the main code path out of the else block accordingly.

This should prevent devices appearing in a half-working state due to
original report descriptor being used, simplifying diagnostics. This
also makes it easier to add cleanup in later commits, as error handling
is simplified.
Signed-off-by: default avatarNikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 172bfe09
...@@ -116,6 +116,10 @@ static int huion_tablet_enable(struct hid_device *hdev) ...@@ -116,6 +116,10 @@ static int huion_tablet_enable(struct hid_device *hdev)
struct usb_device *usb_dev = hid_to_usb_dev(hdev); struct usb_device *usb_dev = hid_to_usb_dev(hdev);
struct huion_drvdata *drvdata = hid_get_drvdata(hdev); struct huion_drvdata *drvdata = hid_get_drvdata(hdev);
__le16 buf[6]; __le16 buf[6];
s32 params[HUION_PH_ID_NUM];
s32 resolution;
__u8 *p;
s32 v;
/* /*
* Read string descriptor containing tablet parameters. The specific * Read string descriptor containing tablet parameters. The specific
...@@ -128,17 +132,16 @@ static int huion_tablet_enable(struct hid_device *hdev) ...@@ -128,17 +132,16 @@ static int huion_tablet_enable(struct hid_device *hdev)
(USB_DT_STRING << 8) + 0x64, (USB_DT_STRING << 8) + 0x64,
0x0409, buf, sizeof(buf), 0x0409, buf, sizeof(buf),
USB_CTRL_GET_TIMEOUT); USB_CTRL_GET_TIMEOUT);
if (rc == -EPIPE) if (rc == -EPIPE) {
hid_warn(hdev, "device parameters not found\n"); hid_err(hdev, "device parameters not found\n");
else if (rc < 0) return -ENODEV;
hid_warn(hdev, "failed to get device parameters: %d\n", rc); } else if (rc < 0) {
else if (rc != sizeof(buf)) hid_err(hdev, "failed to get device parameters: %d\n", rc);
hid_warn(hdev, "invalid device parameters\n"); return -ENODEV;
else { } else if (rc != sizeof(buf)) {
s32 params[HUION_PH_ID_NUM]; hid_err(hdev, "invalid device parameters\n");
s32 resolution; return -ENODEV;
__u8 *p; }
s32 v;
/* Extract device parameters */ /* Extract device parameters */
params[HUION_PH_ID_X_LM] = le16_to_cpu(buf[1]); params[HUION_PH_ID_X_LM] = le16_to_cpu(buf[1]);
...@@ -179,7 +182,6 @@ static int huion_tablet_enable(struct hid_device *hdev) ...@@ -179,7 +182,6 @@ static int huion_tablet_enable(struct hid_device *hdev)
p++; p++;
} }
} }
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment