Merge branch 'for-5.9/upstream-fixes' into for-linus
[linux-2.6-microblaze.git] / drivers / hid / i2c-hid / i2c-hid-core.c
index 294c84e..ac115cb 100644 (file)
@@ -323,7 +323,7 @@ static int i2c_hid_get_report(struct i2c_client *client, u8 reportType,
  * @reportType: 0x03 for HID_FEATURE_REPORT ; 0x02 for HID_OUTPUT_REPORT
  * @reportID: the report ID
  * @buf: the actual data to transfer, without the report ID
- * @len: size of buf
+ * @data_len: size of buf
  * @use_data: true: use SET_REPORT HID command, false: send plain OUTPUT report
  */
 static int i2c_hid_set_or_send_report(struct i2c_client *client, u8 reportType,
@@ -420,6 +420,19 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
                dev_err(&client->dev, "failed to change power setting.\n");
 
 set_pwr_exit:
+
+       /*
+        * The HID over I2C specification states that if a DEVICE needs time
+        * after the PWR_ON request, it should utilise CLOCK stretching.
+        * However, it has been observered that the Windows driver provides a
+        * 1ms sleep between the PWR_ON and RESET requests.
+        * According to Goodix Windows even waits 60 ms after (other?)
+        * PWR_ON requests. Testing has confirmed that several devices
+        * will not work properly without a delay after a PWR_ON request.
+        */
+       if (!ret && power_state == I2C_HID_PWR_ON)
+               msleep(60);
+
        return ret;
 }
 
@@ -441,15 +454,6 @@ static int i2c_hid_hwreset(struct i2c_client *client)
        if (ret)
                goto out_unlock;
 
-       /*
-        * The HID over I2C specification states that if a DEVICE needs time
-        * after the PWR_ON request, it should utilise CLOCK stretching.
-        * However, it has been observered that the Windows driver provides a
-        * 1ms sleep between the PWR_ON and RESET requests and that some devices
-        * rely on this.
-        */
-       usleep_range(1000, 5000);
-
        i2c_hid_dbg(ihid, "resetting...\n");
 
        ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
@@ -1264,6 +1268,7 @@ static struct i2c_driver i2c_hid_driver = {
        .driver = {
                .name   = "i2c_hid",
                .pm     = &i2c_hid_pm,
+               .probe_type = PROBE_PREFER_ASYNCHRONOUS,
                .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
                .of_match_table = of_match_ptr(i2c_hid_of_match),
        },