Skip to content

Commit 6b658c3

Browse files
commodoJonathan Cameron
authored andcommitted
iio: st_sensors: remove all driver remove functions
At this point all ST driver remove functions do iio_device_unregister(). This change removes them from them and replaces all iio_device_register() with devm_iio_device_register(). This can be done in a single change relatively easy, since all these remove functions are define in st_sensors.h. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20210823112204.243255-5-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 5363c6c commit 6b658c3

17 files changed

Lines changed: 9 additions & 139 deletions

‎drivers/iio/accel/st_accel_core.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
13351335
{
13361336
struct st_sensor_data *adata = iio_priv(indio_dev);
13371337
struct st_sensors_platform_data *pdata = dev_get_platdata(adata->dev);
1338+
struct device *parent = indio_dev->dev.parent;
13381339
int err;
13391340

13401341
indio_dev->modes = INDIO_DIRECT_MODE;
@@ -1380,16 +1381,10 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
13801381
return err;
13811382
}
13821383

1383-
return iio_device_register(indio_dev);
1384+
return devm_iio_device_register(parent, indio_dev);
13841385
}
13851386
EXPORT_SYMBOL(st_accel_common_probe);
13861387

1387-
void st_accel_common_remove(struct iio_dev *indio_dev)
1388-
{
1389-
iio_device_unregister(indio_dev);
1390-
}
1391-
EXPORT_SYMBOL(st_accel_common_remove);
1392-
13931388
MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
13941389
MODULE_DESCRIPTION("STMicroelectronics accelerometers driver");
13951390
MODULE_LICENSE("GPL v2");

‎drivers/iio/accel/st_accel_i2c.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,13 @@ static int st_accel_i2c_probe(struct i2c_client *client)
180180
return st_accel_common_probe(indio_dev);
181181
}
182182

183-
static int st_accel_i2c_remove(struct i2c_client *client)
184-
{
185-
struct iio_dev *indio_dev = i2c_get_clientdata(client);
186-
187-
st_accel_common_remove(indio_dev);
188-
189-
return 0;
190-
}
191-
192183
static struct i2c_driver st_accel_driver = {
193184
.driver = {
194185
.name = "st-accel-i2c",
195186
.of_match_table = st_accel_of_match,
196187
.acpi_match_table = ACPI_PTR(st_accel_acpi_match),
197188
},
198189
.probe_new = st_accel_i2c_probe,
199-
.remove = st_accel_i2c_remove,
200190
.id_table = st_accel_id_table,
201191
};
202192
module_i2c_driver(st_accel_driver);

‎drivers/iio/accel/st_accel_spi.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,6 @@ static int st_accel_spi_probe(struct spi_device *spi)
130130
return st_accel_common_probe(indio_dev);
131131
}
132132

133-
static int st_accel_spi_remove(struct spi_device *spi)
134-
{
135-
struct iio_dev *indio_dev = spi_get_drvdata(spi);
136-
137-
st_accel_common_remove(indio_dev);
138-
139-
return 0;
140-
}
141-
142133
static const struct spi_device_id st_accel_id_table[] = {
143134
{ LIS3DH_ACCEL_DEV_NAME },
144135
{ LSM330D_ACCEL_DEV_NAME },
@@ -166,7 +157,6 @@ static struct spi_driver st_accel_driver = {
166157
.of_match_table = st_accel_of_match,
167158
},
168159
.probe = st_accel_spi_probe,
169-
.remove = st_accel_spi_remove,
170160
.id_table = st_accel_id_table,
171161
};
172162
module_spi_driver(st_accel_driver);

‎drivers/iio/gyro/st_gyro_core.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
478478
{
479479
struct st_sensor_data *gdata = iio_priv(indio_dev);
480480
struct st_sensors_platform_data *pdata;
481+
struct device *parent = indio_dev->dev.parent;
481482
int err;
482483

483484
indio_dev->modes = INDIO_DIRECT_MODE;
@@ -515,16 +516,10 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
515516
return err;
516517
}
517518

518-
return iio_device_register(indio_dev);
519+
return devm_iio_device_register(parent, indio_dev);
519520
}
520521
EXPORT_SYMBOL(st_gyro_common_probe);
521522

522-
void st_gyro_common_remove(struct iio_dev *indio_dev)
523-
{
524-
iio_device_unregister(indio_dev);
525-
}
526-
EXPORT_SYMBOL(st_gyro_common_remove);
527-
528523
MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
529524
MODULE_DESCRIPTION("STMicroelectronics gyroscopes driver");
530525
MODULE_LICENSE("GPL v2");

‎drivers/iio/gyro/st_gyro_i2c.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,6 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
9393
return st_gyro_common_probe(indio_dev);
9494
}
9595

96-
static int st_gyro_i2c_remove(struct i2c_client *client)
97-
{
98-
struct iio_dev *indio_dev = i2c_get_clientdata(client);
99-
100-
st_gyro_common_remove(indio_dev);
101-
102-
return 0;
103-
}
104-
10596
static const struct i2c_device_id st_gyro_id_table[] = {
10697
{ L3G4200D_GYRO_DEV_NAME },
10798
{ LSM330D_GYRO_DEV_NAME },
@@ -122,7 +113,6 @@ static struct i2c_driver st_gyro_driver = {
122113
.of_match_table = st_gyro_of_match,
123114
},
124115
.probe = st_gyro_i2c_probe,
125-
.remove = st_gyro_i2c_remove,
126116
.id_table = st_gyro_id_table,
127117
};
128118
module_i2c_driver(st_gyro_driver);

‎drivers/iio/gyro/st_gyro_spi.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ static int st_gyro_spi_probe(struct spi_device *spi)
9797
return st_gyro_common_probe(indio_dev);
9898
}
9999

100-
static int st_gyro_spi_remove(struct spi_device *spi)
101-
{
102-
struct iio_dev *indio_dev = spi_get_drvdata(spi);
103-
104-
st_gyro_common_remove(indio_dev);
105-
106-
return 0;
107-
}
108-
109100
static const struct spi_device_id st_gyro_id_table[] = {
110101
{ L3G4200D_GYRO_DEV_NAME },
111102
{ LSM330D_GYRO_DEV_NAME },
@@ -126,7 +117,6 @@ static struct spi_driver st_gyro_driver = {
126117
.of_match_table = st_gyro_of_match,
127118
},
128119
.probe = st_gyro_spi_probe,
129-
.remove = st_gyro_spi_remove,
130120
.id_table = st_gyro_id_table,
131121
};
132122
module_spi_driver(st_gyro_driver);

‎drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ struct st_lsm9ds0 {
1818
};
1919

2020
int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap);
21-
int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0);
2221

2322
#endif /* ST_LSM9DS0_H */

‎drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,10 @@ int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
142142
return ret;
143143

144144
/* Setup magnetometer device */
145-
ret = st_lsm9ds0_probe_magn(lsm9ds0, regmap);
146-
if (ret)
147-
st_accel_common_remove(lsm9ds0->accel);
148-
149-
return ret;
145+
return st_lsm9ds0_probe_magn(lsm9ds0, regmap);
150146
}
151147
EXPORT_SYMBOL_GPL(st_lsm9ds0_probe);
152148

153-
int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0)
154-
{
155-
st_magn_common_remove(lsm9ds0->magn);
156-
st_accel_common_remove(lsm9ds0->accel);
157-
158-
return 0;
159-
}
160-
EXPORT_SYMBOL_GPL(st_lsm9ds0_remove);
161-
162149
MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
163150
MODULE_DESCRIPTION("STMicroelectronics LSM9DS0 IMU core driver");
164151
MODULE_LICENSE("GPL v2");

‎drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,12 @@ static int st_lsm9ds0_i2c_probe(struct i2c_client *client)
6464
return st_lsm9ds0_probe(lsm9ds0, regmap);
6565
}
6666

67-
static int st_lsm9ds0_i2c_remove(struct i2c_client *client)
68-
{
69-
return st_lsm9ds0_remove(i2c_get_clientdata(client));
70-
}
71-
7267
static struct i2c_driver st_lsm9ds0_driver = {
7368
.driver = {
7469
.name = "st-lsm9ds0-i2c",
7570
.of_match_table = st_lsm9ds0_of_match,
7671
},
7772
.probe_new = st_lsm9ds0_i2c_probe,
78-
.remove = st_lsm9ds0_i2c_remove,
7973
.id_table = st_lsm9ds0_id_table,
8074
};
8175
module_i2c_driver(st_lsm9ds0_driver);

‎drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,12 @@ static int st_lsm9ds0_spi_probe(struct spi_device *spi)
6363
return st_lsm9ds0_probe(lsm9ds0, regmap);
6464
}
6565

66-
static int st_lsm9ds0_spi_remove(struct spi_device *spi)
67-
{
68-
return st_lsm9ds0_remove(spi_get_drvdata(spi));
69-
}
70-
7166
static struct spi_driver st_lsm9ds0_driver = {
7267
.driver = {
7368
.name = "st-lsm9ds0-spi",
7469
.of_match_table = st_lsm9ds0_of_match,
7570
},
7671
.probe = st_lsm9ds0_spi_probe,
77-
.remove = st_lsm9ds0_spi_remove,
7872
.id_table = st_lsm9ds0_id_table,
7973
};
8074
module_spi_driver(st_lsm9ds0_driver);

0 commit comments

Comments
 (0)