@@ -354,14 +354,19 @@ static int i2c_hid_hwreset(struct i2c_client *client)
struct i2c_hid *ihid = i2c_get_clientdata(client);
int ret;
+ disable_irq(ihid->irq);
+
i2c_hid_dbg(ihid, "%s\n", __func__);
ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
- if (ret)
+ if (ret) {
+ enable_irq(ihid->irq);
return ret;
+ }
i2c_hid_dbg(ihid, "resetting...\n");
+ enable_irq(ihid->irq);
ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
if (ret) {
dev_err(&client->dev, "failed to reset device.\n");
@@ -390,16 +395,14 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
return;
}
- ret_size = ihid->inbuf[0] | ihid->inbuf[1] << 8;
-
- if (!ret_size) {
- /* host or device initiated RESET completed */
- if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags))
- wake_up(&ihid->wait);
+ /* host or device initiated RESET completed */
+ if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)) {
+ wake_up(&ihid->wait);
return;
}
- if (ret_size > size) {
+ ret_size = ihid->inbuf[0] | ihid->inbuf[1] << 8;
+ if (ret_size > size || !ret_size) {
dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
__func__, size, ret_size);
return;