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: da280: 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/20210628141709.80534-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
3d9efa9b 074e1ddb

+9 -17
+9 -17
drivers/iio/accel/da280.c
··· 100 100 return (enum da280_chipset) id->driver_data; 101 101 } 102 102 103 + static void da280_disable(void *client) 104 + { 105 + da280_enable(client, false); 106 + } 107 + 103 108 static int da280_probe(struct i2c_client *client, 104 109 const struct i2c_device_id *id) 105 110 { ··· 123 118 124 119 data = iio_priv(indio_dev); 125 120 data->client = client; 126 - i2c_set_clientdata(client, indio_dev); 127 121 128 122 indio_dev->info = &da280_info; 129 123 indio_dev->modes = INDIO_DIRECT_MODE; ··· 146 142 if (ret < 0) 147 143 return ret; 148 144 149 - ret = iio_device_register(indio_dev); 150 - if (ret < 0) { 151 - dev_err(&client->dev, "device_register failed\n"); 152 - da280_enable(client, false); 153 - } 145 + ret = devm_add_action_or_reset(&client->dev, da280_disable, client); 146 + if (ret) 147 + return ret; 154 148 155 - return ret; 156 - } 157 - 158 - static int da280_remove(struct i2c_client *client) 159 - { 160 - struct iio_dev *indio_dev = i2c_get_clientdata(client); 161 - 162 - iio_device_unregister(indio_dev); 163 - 164 - return da280_enable(client, false); 149 + return devm_iio_device_register(&client->dev, indio_dev); 165 150 } 166 151 167 152 #ifdef CONFIG_PM_SLEEP ··· 187 194 .pm = &da280_pm_ops, 188 195 }, 189 196 .probe = da280_probe, 190 - .remove = da280_remove, 191 197 .id_table = da280_i2c_id, 192 198 }; 193 199