Merge branch 'for-4.19/i2c-hid' into for-linus
authorJiri Kosina <jkosina@suse.cz>
Mon, 20 Aug 2018 16:07:01 +0000 (18:07 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 20 Aug 2018 16:07:01 +0000 (18:07 +0200)
Low voltage support for i2c-hid

1  2 
drivers/hid/i2c-hid/i2c-hid.c

index eae0cb3ddec668e8d2f82b1d571bb826b0fb1dd5,4f532d9238fb6626d58a4ff5c057825199141dd6..2ce194a84868e0fe5e133e241a0de368dfe3becf
@@@ -484,7 -484,7 +484,7 @@@ static void i2c_hid_get_input(struct i2
                return;
        }
  
 -      if ((ret_size > size) || (ret_size <= 2)) {
 +      if ((ret_size > size) || (ret_size < 2)) {
                dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
                        __func__, size, ret_size);
                return;
@@@ -1002,18 -1002,18 +1002,18 @@@ static int i2c_hid_probe(struct i2c_cli
                return client->irq;
        }
  
-       ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL);
+       ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL);
        if (!ihid)
                return -ENOMEM;
  
        if (client->dev.of_node) {
                ret = i2c_hid_of_probe(client, &ihid->pdata);
                if (ret)
-                       goto err;
+                       return ret;
        } else if (!platform_data) {
                ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
                if (ret)
-                       goto err;
+                       return ret;
        } else {
                ihid->pdata = *platform_data;
        }
        /* Parse platform agnostic common properties from ACPI / device tree */
        i2c_hid_fwnode_probe(client, &ihid->pdata);
  
-       ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd");
-       if (IS_ERR(ihid->pdata.supply)) {
-               ret = PTR_ERR(ihid->pdata.supply);
-               if (ret != -EPROBE_DEFER)
-                       dev_err(&client->dev, "Failed to get regulator: %d\n",
-                               ret);
-               goto err;
-       }
+       ihid->pdata.supplies[0].supply = "vdd";
+       ihid->pdata.supplies[1].supply = "vddl";
+       ret = devm_regulator_bulk_get(&client->dev,
+                                     ARRAY_SIZE(ihid->pdata.supplies),
+                                     ihid->pdata.supplies);
+       if (ret)
+               return ret;
+       ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies),
+                                   ihid->pdata.supplies);
+       if (ret < 0)
+               return ret;
  
-       ret = regulator_enable(ihid->pdata.supply);
-       if (ret < 0) {
-               dev_err(&client->dev, "Failed to enable regulator: %d\n",
-                       ret);
-               goto err;
-       }
        if (ihid->pdata.post_power_delay_ms)
                msleep(ihid->pdata.post_power_delay_ms);
  
@@@ -1122,11 -1121,9 +1121,9 @@@ err_pm
        pm_runtime_disable(&client->dev);
  
  err_regulator:
-       regulator_disable(ihid->pdata.supply);
- err:
+       regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
+                              ihid->pdata.supplies);
        i2c_hid_free_buffers(ihid);
-       kfree(ihid);
        return ret;
  }
  
@@@ -1148,9 -1145,8 +1145,8 @@@ static int i2c_hid_remove(struct i2c_cl
        if (ihid->bufsize)
                i2c_hid_free_buffers(ihid);
  
-       regulator_disable(ihid->pdata.supply);
-       kfree(ihid);
+       regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
+                              ihid->pdata.supplies);
  
        return 0;
  }
@@@ -1201,9 -1197,8 +1197,8 @@@ static int i2c_hid_suspend(struct devic
                        hid_warn(hid, "Failed to enable irq wake: %d\n",
                                wake_status);
        } else {
-               ret = regulator_disable(ihid->pdata.supply);
-               if (ret < 0)
-                       hid_warn(hid, "Failed to disable supply: %d\n", ret);
+               regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
+                                      ihid->pdata.supplies);
        }
  
        return 0;
@@@ -1218,9 -1213,11 +1213,11 @@@ static int i2c_hid_resume(struct devic
        int wake_status;
  
        if (!device_may_wakeup(&client->dev)) {
-               ret = regulator_enable(ihid->pdata.supply);
-               if (ret < 0)
-                       hid_warn(hid, "Failed to enable supply: %d\n", ret);
+               ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies),
+                                           ihid->pdata.supplies);
+               if (ret)
+                       hid_warn(hid, "Failed to enable supplies: %d\n", ret);
                if (ihid->pdata.post_power_delay_ms)
                        msleep(ihid->pdata.post_power_delay_ms);
        } else if (ihid->irq_wake_enabled) {