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: accel: dmard10: convert probe to device-managed functions

This is another simple conversion to device-managed functions, requiring
the use of devm_iio_device_register() and moving the disabling of the
device on a devm_add_action_or_reset() hook.

The i2c_set_clientdata() can be removed, as the PM functions can work with
just the device object, to obtain the i2c_client object.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210630121509.653717-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
689f584b 148da125

+10 -17
+10 -17
drivers/iio/accel/dmard10.c
··· 170 170 .read_raw = dmard10_read_raw, 171 171 }; 172 172 173 + static void dmard10_shutdown_cleanup(void *client) 174 + { 175 + dmard10_shutdown(client); 176 + } 177 + 173 178 static int dmard10_probe(struct i2c_client *client, 174 179 const struct i2c_device_id *id) 175 180 { ··· 199 194 200 195 data = iio_priv(indio_dev); 201 196 data->client = client; 202 - i2c_set_clientdata(client, indio_dev); 203 197 204 198 indio_dev->info = &dmard10_info; 205 199 indio_dev->name = "dmard10"; ··· 210 206 if (ret < 0) 211 207 return ret; 212 208 213 - ret = iio_device_register(indio_dev); 214 - if (ret < 0) { 215 - dev_err(&client->dev, "device_register failed\n"); 216 - dmard10_shutdown(client); 217 - } 209 + ret = devm_add_action_or_reset(&client->dev, dmard10_shutdown_cleanup, 210 + client); 211 + if (ret) 212 + return ret; 218 213 219 - return ret; 220 - } 221 - 222 - static int dmard10_remove(struct i2c_client *client) 223 - { 224 - struct iio_dev *indio_dev = i2c_get_clientdata(client); 225 - 226 - iio_device_unregister(indio_dev); 227 - 228 - return dmard10_shutdown(client); 214 + return devm_iio_device_register(&client->dev, indio_dev); 229 215 } 230 216 231 217 #ifdef CONFIG_PM_SLEEP ··· 244 250 .pm = &dmard10_pm_ops, 245 251 }, 246 252 .probe = dmard10_probe, 247 - .remove = dmard10_remove, 248 253 .id_table = dmard10_i2c_id, 249 254 }; 250 255