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.

iio: light: veml6070: add action for i2c_unregister_device

Simplify the code by adding an action to call i2c_unregister_device(),
which removes the need for a 'fail' label, gotos to it, and an explicit
call in veml6070_remove().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240929-veml6070-cleanup-v1-1-a9350341a646@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Javier Carrasco and committed by
Jonathan Cameron
7501bff8 0f87813b

+11 -9
+11 -9
drivers/iio/light/veml6070.c
··· 135 135 .read_raw = veml6070_read_raw, 136 136 }; 137 137 138 + static void veml6070_i2c_unreg(void *p) 139 + { 140 + struct veml6070_data *data = p; 141 + 142 + i2c_unregister_device(data->client2); 143 + } 144 + 138 145 static int veml6070_probe(struct i2c_client *client) 139 146 { 140 147 struct veml6070_data *data; ··· 173 166 VEML6070_COMMAND_SD; 174 167 ret = i2c_smbus_write_byte(data->client1, data->config); 175 168 if (ret < 0) 176 - goto fail; 169 + return ret; 177 170 178 - ret = iio_device_register(indio_dev); 171 + ret = devm_add_action_or_reset(&client->dev, veml6070_i2c_unreg, data); 179 172 if (ret < 0) 180 - goto fail; 173 + return ret; 181 174 182 - return ret; 183 - 184 - fail: 185 - i2c_unregister_device(data->client2); 186 - return ret; 175 + return iio_device_register(indio_dev); 187 176 } 188 177 189 178 static void veml6070_remove(struct i2c_client *client) ··· 188 185 struct veml6070_data *data = iio_priv(indio_dev); 189 186 190 187 iio_device_unregister(indio_dev); 191 - i2c_unregister_device(data->client2); 192 188 } 193 189 194 190 static const struct i2c_device_id veml6070_id[] = {