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: wacom_w8001 - use "guard" notation when acquiring mutex

Switch the driver to use guard notation when acquiring mutex to
have it released automatically.

Link: https://lore.kernel.org/r/Zmkyvkr9AFyywy1V@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+10 -12
+10 -12
drivers/input/touchscreen/wacom_w8001.c
··· 380 380 struct w8001 *w8001 = input_get_drvdata(dev); 381 381 int err; 382 382 383 - err = mutex_lock_interruptible(&w8001->mutex); 384 - if (err) 385 - return err; 383 + scoped_guard(mutex_intr, &w8001->mutex) { 384 + if (w8001->open_count == 0) { 385 + err = w8001_command(w8001, W8001_CMD_START, false); 386 + if (err) 387 + return err; 388 + } 386 389 387 - if (w8001->open_count++ == 0) { 388 - err = w8001_command(w8001, W8001_CMD_START, false); 389 - if (err) 390 - w8001->open_count--; 390 + w8001->open_count++; 391 + return 0; 391 392 } 392 393 393 - mutex_unlock(&w8001->mutex); 394 - return err; 394 + return -EINTR; 395 395 } 396 396 397 397 static void w8001_close(struct input_dev *dev) 398 398 { 399 399 struct w8001 *w8001 = input_get_drvdata(dev); 400 400 401 - mutex_lock(&w8001->mutex); 401 + guard(mutex)(&w8001->mutex); 402 402 403 403 if (--w8001->open_count == 0) 404 404 w8001_command(w8001, W8001_CMD_STOP, false); 405 - 406 - mutex_unlock(&w8001->mutex); 407 405 } 408 406 409 407 static int w8001_detect(struct w8001 *w8001)