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

Guard notation simplifies code.

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

+18 -20
+18 -20
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 410 410 struct i2c_client *client = to_i2c_client(dev); 411 411 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client); 412 412 struct input_dev *input = ts->input; 413 - int ret = 0; 413 + int error; 414 414 415 - mutex_lock(&input->mutex); 415 + guard(mutex)(&input->mutex); 416 416 417 417 if (device_may_wakeup(&client->dev)) { 418 418 if (!input_device_enabled(input)) { 419 - ret = pixcir_start(ts); 420 - if (ret) { 419 + error = pixcir_start(ts); 420 + if (error) { 421 421 dev_err(dev, "Failed to start\n"); 422 - goto unlock; 422 + return error; 423 423 } 424 424 } 425 425 } else if (input_device_enabled(input)) { 426 - ret = pixcir_stop(ts); 426 + error = pixcir_stop(ts); 427 + if (error) 428 + return error; 427 429 } 428 430 429 - unlock: 430 - mutex_unlock(&input->mutex); 431 - 432 - return ret; 431 + return 0; 433 432 } 434 433 435 434 static int pixcir_i2c_ts_resume(struct device *dev) ··· 436 437 struct i2c_client *client = to_i2c_client(dev); 437 438 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client); 438 439 struct input_dev *input = ts->input; 439 - int ret = 0; 440 + int error; 440 441 441 - mutex_lock(&input->mutex); 442 + guard(mutex)(&input->mutex); 442 443 443 444 if (device_may_wakeup(&client->dev)) { 444 445 if (!input_device_enabled(input)) { 445 - ret = pixcir_stop(ts); 446 - if (ret) { 446 + error = pixcir_stop(ts); 447 + if (error) { 447 448 dev_err(dev, "Failed to stop\n"); 448 - goto unlock; 449 + return error; 449 450 } 450 451 } 451 452 } else if (input_device_enabled(input)) { 452 - ret = pixcir_start(ts); 453 + error = pixcir_start(ts); 454 + if (error) 455 + return error; 453 456 } 454 457 455 - unlock: 456 - mutex_unlock(&input->mutex); 457 - 458 - return ret; 458 + return 0; 459 459 } 460 460 461 461 static DEFINE_SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,