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: auo-pixcir-ts - use guard notation when acquiring mutexes

This makes the code more compact and error handling more robust.

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

+22 -21
+22 -21
drivers/input/touchscreen/auo-pixcir-ts.c
··· 415 415 struct i2c_client *client = to_i2c_client(dev); 416 416 struct auo_pixcir_ts *ts = i2c_get_clientdata(client); 417 417 struct input_dev *input = ts->input; 418 - int ret = 0; 418 + int error; 419 419 420 - mutex_lock(&input->mutex); 420 + guard(mutex)(&input->mutex); 421 421 422 422 /* when configured as wakeup source, device should always wake system 423 423 * therefore start device if necessary ··· 425 425 if (device_may_wakeup(&client->dev)) { 426 426 /* need to start device if not open, to be wakeup source */ 427 427 if (!input_device_enabled(input)) { 428 - ret = auo_pixcir_start(ts); 429 - if (ret) 430 - goto unlock; 428 + error = auo_pixcir_start(ts); 429 + if (error) 430 + return error; 431 431 } 432 432 433 433 enable_irq_wake(client->irq); 434 - ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP); 434 + error = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP); 435 + if (error) 436 + return error; 437 + 435 438 } else if (input_device_enabled(input)) { 436 - ret = auo_pixcir_stop(ts); 439 + error = auo_pixcir_stop(ts); 440 + if (error) 441 + return error; 437 442 } 438 443 439 - unlock: 440 - mutex_unlock(&input->mutex); 441 - 442 - return ret; 444 + return 0; 443 445 } 444 446 445 447 static int auo_pixcir_resume(struct device *dev) ··· 449 447 struct i2c_client *client = to_i2c_client(dev); 450 448 struct auo_pixcir_ts *ts = i2c_get_clientdata(client); 451 449 struct input_dev *input = ts->input; 452 - int ret = 0; 450 + int error; 453 451 454 - mutex_lock(&input->mutex); 452 + guard(mutex)(&input->mutex); 455 453 456 454 if (device_may_wakeup(&client->dev)) { 457 455 disable_irq_wake(client->irq); 458 456 459 457 /* need to stop device if it was not open on suspend */ 460 458 if (!input_device_enabled(input)) { 461 - ret = auo_pixcir_stop(ts); 462 - if (ret) 463 - goto unlock; 459 + error = auo_pixcir_stop(ts); 460 + if (error) 461 + return error; 464 462 } 465 463 466 464 /* device wakes automatically from SLEEP */ 467 465 } else if (input_device_enabled(input)) { 468 - ret = auo_pixcir_start(ts); 466 + error = auo_pixcir_start(ts); 467 + if (error) 468 + return error; 469 469 } 470 470 471 - unlock: 472 - mutex_unlock(&input->mutex); 473 - 474 - return ret; 471 + return 0; 475 472 } 476 473 477 474 static DEFINE_SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,