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

Guard notation simplifies code.

Also fix the touchscreen not being marked as suspended when noone has
opened/is using it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+8 -12
+8 -12
drivers/input/touchscreen/cyttsp_core.c
··· 494 494 static int cyttsp_suspend(struct device *dev) 495 495 { 496 496 struct cyttsp *ts = dev_get_drvdata(dev); 497 - int retval = 0; 497 + int error; 498 498 499 - mutex_lock(&ts->input->mutex); 499 + guard(mutex)(&ts->input->mutex); 500 500 501 501 if (input_device_enabled(ts->input)) { 502 - retval = cyttsp_disable(ts); 503 - if (retval == 0) 504 - ts->suspended = true; 502 + error = cyttsp_disable(ts); 503 + if (error) 504 + return error; 505 505 } 506 506 507 - mutex_unlock(&ts->input->mutex); 508 - 509 - return retval; 507 + ts->suspended = true; 508 + return 0; 510 509 } 511 510 512 511 static int cyttsp_resume(struct device *dev) 513 512 { 514 513 struct cyttsp *ts = dev_get_drvdata(dev); 515 514 516 - mutex_lock(&ts->input->mutex); 515 + guard(mutex)(&ts->input->mutex); 517 516 518 517 if (input_device_enabled(ts->input)) 519 518 cyttsp_enable(ts); 520 519 521 520 ts->suspended = false; 522 - 523 - mutex_unlock(&ts->input->mutex); 524 - 525 521 return 0; 526 522 } 527 523