Skip to content

Commit aa69d69

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: i2c-hid: Switch i2c_hid_parse() to goto style error handling
Switch i2c_hid_parse() to goto style error handling. This is a preparation patch for removing the need for I2C_HID_QUIRK_NO_IRQ_AFTER_RESET by making i2c-hid behave more like Windows. Note this changes the descriptor read error path to propagate the actual i2c_hid_read_register() error code (which is always negative) instead of hardcoding a -EIO return. Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 96d3098 commit aa69d69

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,23 +773,21 @@ static int i2c_hid_parse(struct hid_device *hid)
773773
rdesc, rsize);
774774
if (ret) {
775775
hid_err(hid, "reading report descriptor failed\n");
776-
kfree(rdesc);
777-
return -EIO;
776+
goto out;
778777
}
779778
}
780779

781780
i2c_hid_dbg(ihid, "Report Descriptor: %*ph\n", rsize, rdesc);
782781

783782
ret = hid_parse_report(hid, rdesc, rsize);
783+
if (ret)
784+
dbg_hid("parsing report descriptor failed\n");
785+
786+
out:
784787
if (!use_override)
785788
kfree(rdesc);
786789

787-
if (ret) {
788-
dbg_hid("parsing report descriptor failed\n");
789-
return ret;
790-
}
791-
792-
return 0;
790+
return ret;
793791
}
794792

795793
static int i2c_hid_start(struct hid_device *hid)

0 commit comments

Comments
 (0)