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: proximity: rfd77402: convert probe to device-managed functions

This change converts the probe hook to register the IIO device with
devm_iio_device_register() and register a hook with
devm_add_action_or_reset() to put the device in powerdown when the driver
gets unloaded.

Since the PM suspend/resume functions need only a reference to the
i2c_client object (which can be obtained from the base device object), the
i2c_set_clientdata() call can be removed.

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

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
148da125 09d5135b

+8 -19
+8 -19
drivers/iio/proximity/rfd77402.c
··· 252 252 RFD77402_STATUS_STANDBY); 253 253 } 254 254 255 + static void rfd77402_disable(void *client) 256 + { 257 + rfd77402_powerdown(client); 258 + } 259 + 255 260 static int rfd77402_probe(struct i2c_client *client, 256 261 const struct i2c_device_id *id) 257 262 { ··· 275 270 return -ENOMEM; 276 271 277 272 data = iio_priv(indio_dev); 278 - i2c_set_clientdata(client, indio_dev); 279 273 data->client = client; 280 274 mutex_init(&data->lock); 281 275 ··· 288 284 if (ret < 0) 289 285 return ret; 290 286 291 - ret = iio_device_register(indio_dev); 287 + ret = devm_add_action_or_reset(&client->dev, rfd77402_disable, client); 292 288 if (ret) 293 - goto err_powerdown; 289 + return ret; 294 290 295 - return 0; 296 - 297 - err_powerdown: 298 - rfd77402_powerdown(client); 299 - return ret; 300 - } 301 - 302 - static int rfd77402_remove(struct i2c_client *client) 303 - { 304 - struct iio_dev *indio_dev = i2c_get_clientdata(client); 305 - 306 - iio_device_unregister(indio_dev); 307 - rfd77402_powerdown(client); 308 - 309 - return 0; 291 + return devm_iio_device_register(&client->dev, indio_dev); 310 292 } 311 293 312 294 #ifdef CONFIG_PM_SLEEP ··· 321 331 .pm = &rfd77402_pm_ops, 322 332 }, 323 333 .probe = rfd77402_probe, 324 - .remove = rfd77402_remove, 325 334 .id_table = rfd77402_id, 326 335 }; 327 336