[PATCH v3 4/9] HID: i2c-hid-of: skip post-power-on delay if powered on sufficiently long

From: Chen-Yu Tsai

Date: Tue Jul 21 2026 - 03:59:51 EST


On some devices the HID device is powered from an always-on power rail,
or the power rail has been left on by either POR defaults or the
bootloader. By the time the driver probes, the device most certainly
has finished initializing. There is no need for the delay.

In such designs, the system integrators tend to work around the delay
to avoid the boot time penalty by simply omitting it from the device
tree. This is undesired, as the device tree is not fully describing
the hardware.

Switch to the new regulator_bulk_enable_and_wait() function that makes
sure a certain amount of time has passed since the regulator supplies
were actually enabled.

Signed-off-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
---
Changes since v2:
- Switched to new regulator_bulk_enable_and_wait() API
---
drivers/hid/i2c-hid/i2c-hid-of.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c
index 59393d71ddb9..fdaad451e710 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of.c
@@ -29,6 +29,7 @@
#include <linux/of.h>
#include <linux/pm.h>
#include <linux/regulator/consumer.h>
+#include <linux/time.h>

#include "i2c-hid.h"

@@ -48,16 +49,14 @@ static int i2c_hid_of_power_up(struct i2chid_ops *ops)
struct device *dev = &ihid_of->client->dev;
int ret;

- ret = regulator_bulk_enable(ARRAY_SIZE(ihid_of->supplies),
- ihid_of->supplies);
+ ret = regulator_bulk_enable_and_wait(ARRAY_SIZE(ihid_of->supplies),
+ ihid_of->supplies,
+ ihid_of->post_power_delay_ms * USEC_PER_MSEC);
if (ret) {
dev_warn(dev, "Failed to enable supplies: %d\n", ret);
return ret;
}

- if (ihid_of->post_power_delay_ms)
- msleep(ihid_of->post_power_delay_ms);
-
gpiod_set_value_cansleep(ihid_of->reset_gpio, 0);
if (ihid_of->post_reset_delay_ms)
msleep(ihid_of->post_reset_delay_ms);
--
2.55.0.229.g6434b31f56-goog