Commit f2845b4f authored by Dmitry Torokhov's avatar Dmitry Torokhov

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.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent bf5cba8c
...@@ -643,12 +643,12 @@ static int rohm_ts_load_firmware(struct i2c_client *client, ...@@ -643,12 +643,12 @@ static int rohm_ts_load_firmware(struct i2c_client *client,
const char *firmware_name) const char *firmware_name)
{ {
struct device *dev = &client->dev; struct device *dev = &client->dev;
const struct firmware *fw;
s32 status; s32 status;
unsigned int offset, len, xfer_len; unsigned int offset, len, xfer_len;
unsigned int retry = 0; unsigned int retry = 0;
int error, error2; int error, error2;
const struct firmware *fw __free(firmware) = NULL;
error = request_firmware(&fw, firmware_name, dev); error = request_firmware(&fw, firmware_name, dev);
if (error) { if (error) {
dev_err(dev, "unable to retrieve firmware %s: %d\n", dev_err(dev, "unable to retrieve firmware %s: %d\n",
...@@ -722,8 +722,6 @@ static int rohm_ts_load_firmware(struct i2c_client *client, ...@@ -722,8 +722,6 @@ static int rohm_ts_load_firmware(struct i2c_client *client,
out: out:
error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL);
release_firmware(fw);
return error ? error : error2; return error ? error : error2;
} }
...@@ -732,22 +730,22 @@ static int rohm_ts_update_setting(struct rohm_ts_data *ts, ...@@ -732,22 +730,22 @@ static int rohm_ts_update_setting(struct rohm_ts_data *ts,
{ {
int error; int error;
error = mutex_lock_interruptible(&ts->input->mutex); scoped_cond_guard(mutex_intr, return -EINTR, &ts->input->mutex) {
if (error) if (on)
return error; ts->setup2 |= setting_bit;
else
if (on) ts->setup2 &= ~setting_bit;
ts->setup2 |= setting_bit;
else
ts->setup2 &= ~setting_bit;
if (ts->initialized) if (ts->initialized) {
error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, error = i2c_smbus_write_byte_data(ts->client,
ts->setup2); COMMON_SETUP2,
ts->setup2);
mutex_unlock(&ts->input->mutex); if (error)
return error;
}
}
return error; return 0;
} }
static ssize_t swap_xy_show(struct device *dev, struct device_attribute *attr, static ssize_t swap_xy_show(struct device *dev, struct device_attribute *attr,
...@@ -842,7 +840,7 @@ static int rohm_ts_device_init(struct i2c_client *client, u8 setup2) ...@@ -842,7 +840,7 @@ static int rohm_ts_device_init(struct i2c_client *client, u8 setup2)
struct device *dev = &client->dev; struct device *dev = &client->dev;
int error; int error;
disable_irq(client->irq); guard(disable_irq)(&client->irq);
/* /*
* Wait 200usec for reset * Wait 200usec for reset
...@@ -1017,10 +1015,10 @@ static int rohm_ts_device_init(struct i2c_client *client, u8 setup2) ...@@ -1017,10 +1015,10 @@ static int rohm_ts_device_init(struct i2c_client *client, u8 setup2)
/* controller CPU power on */ /* controller CPU power on */
error = i2c_smbus_write_byte_data(client, SYSTEM, error = i2c_smbus_write_byte_data(client, SYSTEM,
ANALOG_POWER_ON | CPU_POWER_ON); ANALOG_POWER_ON | CPU_POWER_ON);
if (error)
return error;
enable_irq(client->irq); return 0;
return error;
} }
static int rohm_ts_power_off(struct i2c_client *client) static int rohm_ts_power_off(struct i2c_client *client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment