Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: drv260x - handle calibration timeout

If something goes wrong during calibration (for instance, if the
'enable' GPIO was not properly defined), the GO bit may not be cleared
after some time, causing the driver to get stuck.

To prevent this, add a timeout check to the waiting loop and return an
error if it times out.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Link: https://patch.msgid.link/20260215141435.727872-6-jekhor@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Yauhen Kharuzhy and committed by
Dmitry Torokhov
710a1a8c 029edcfc

+13
+13
drivers/input/misc/drv260x.c
··· 166 166 #define DRV260X_AUTOCAL_TIME_500MS (2 << 4) 167 167 #define DRV260X_AUTOCAL_TIME_1000MS (3 << 4) 168 168 169 + /* 170 + * Timeout for waiting for the GO status bit, in seconds. Should be reasonably 171 + * large to wait for a auto-calibration cycle completion. 172 + */ 173 + #define DRV260X_GO_TIMEOUT_S 5 174 + 169 175 /** 170 176 * struct drv260x_data - 171 177 * @input_dev: Pointer to the input device ··· 315 309 { 316 310 int error; 317 311 unsigned int cal_buf; 312 + unsigned long timeout; 318 313 319 314 error = regmap_write(haptics->regmap, 320 315 DRV260X_RATED_VOLT, haptics->rated_voltage); ··· 405 398 return error; 406 399 } 407 400 401 + timeout = jiffies + DRV260X_GO_TIMEOUT_S * HZ; 408 402 do { 409 403 usleep_range(15000, 15500); 410 404 error = regmap_read(haptics->regmap, DRV260X_GO, &cal_buf); ··· 414 406 "Failed to read GO register: %d\n", 415 407 error); 416 408 return error; 409 + } 410 + if (time_after(jiffies, timeout)) { 411 + dev_err(&haptics->client->dev, 412 + "Calibration timeout. The device cannot be used.\n"); 413 + return -ETIMEDOUT; 417 414 } 418 415 } while (cal_buf == DRV260X_GO_BIT); 419 416