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: rohm_bu21023 - switch to using cleanup functions

Start using __free() and guard() primitives to simplify the code
and error handling.

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

+19 -21
+19 -21
drivers/input/touchscreen/rohm_bu21023.c
··· 643 643 const char *firmware_name) 644 644 { 645 645 struct device *dev = &client->dev; 646 - const struct firmware *fw; 647 646 s32 status; 648 647 unsigned int offset, len, xfer_len; 649 648 unsigned int retry = 0; 650 649 int error, error2; 651 650 651 + const struct firmware *fw __free(firmware) = NULL; 652 652 error = request_firmware(&fw, firmware_name, dev); 653 653 if (error) { 654 654 dev_err(dev, "unable to retrieve firmware %s: %d\n", ··· 722 722 out: 723 723 error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); 724 724 725 - release_firmware(fw); 726 - 727 725 return error ? error : error2; 728 726 } 729 727 ··· 730 732 { 731 733 int error; 732 734 733 - error = mutex_lock_interruptible(&ts->input->mutex); 734 - if (error) 735 - return error; 735 + scoped_cond_guard(mutex_intr, return -EINTR, &ts->input->mutex) { 736 + if (on) 737 + ts->setup2 |= setting_bit; 738 + else 739 + ts->setup2 &= ~setting_bit; 736 740 737 - if (on) 738 - ts->setup2 |= setting_bit; 739 - else 740 - ts->setup2 &= ~setting_bit; 741 + if (ts->initialized) { 742 + error = i2c_smbus_write_byte_data(ts->client, 743 + COMMON_SETUP2, 744 + ts->setup2); 745 + if (error) 746 + return error; 747 + } 748 + } 741 749 742 - if (ts->initialized) 743 - error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, 744 - ts->setup2); 745 - 746 - mutex_unlock(&ts->input->mutex); 747 - 748 - return error; 750 + return 0; 749 751 } 750 752 751 753 static ssize_t swap_xy_show(struct device *dev, struct device_attribute *attr, ··· 840 842 struct device *dev = &client->dev; 841 843 int error; 842 844 843 - disable_irq(client->irq); 845 + guard(disable_irq)(&client->irq); 844 846 845 847 /* 846 848 * Wait 200usec for reset ··· 1015 1017 /* controller CPU power on */ 1016 1018 error = i2c_smbus_write_byte_data(client, SYSTEM, 1017 1019 ANALOG_POWER_ON | CPU_POWER_ON); 1020 + if (error) 1021 + return error; 1018 1022 1019 - enable_irq(client->irq); 1020 - 1021 - return error; 1023 + return 0; 1022 1024 } 1023 1025 1024 1026 static int rohm_ts_power_off(struct i2c_client *client)