staging: iio: ade7854: use devm_iio_device_register

Replace iio_device_register with the device managed version.
This change is safe because it does not change the order of
any device removal actions. Unregistering the device was the
only removal action. The newly emptied .remove functions are
deleted.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alison Schofield 2016-02-28 00:22:50 -08:00 committed by Greg Kroah-Hartman
parent 8f27f7323f
commit a04b4e5005
3 changed files with 2 additions and 31 deletions

View File

@ -227,11 +227,6 @@ static int ade7854_i2c_probe(struct i2c_client *client,
return ade7854_probe(indio_dev, &client->dev); return ade7854_probe(indio_dev, &client->dev);
} }
static int ade7854_i2c_remove(struct i2c_client *client)
{
return ade7854_remove(i2c_get_clientdata(client));
}
static const struct i2c_device_id ade7854_id[] = { static const struct i2c_device_id ade7854_id[] = {
{ "ade7854", 0 }, { "ade7854", 0 },
{ "ade7858", 0 }, { "ade7858", 0 },
@ -246,7 +241,6 @@ static struct i2c_driver ade7854_i2c_driver = {
.name = "ade7854", .name = "ade7854",
}, },
.probe = ade7854_i2c_probe, .probe = ade7854_i2c_probe,
.remove = ade7854_i2c_remove,
.id_table = ade7854_id, .id_table = ade7854_id,
}; };
module_i2c_driver(ade7854_i2c_driver); module_i2c_driver(ade7854_i2c_driver);

View File

@ -296,12 +296,6 @@ static int ade7854_spi_probe(struct spi_device *spi)
return ade7854_probe(indio_dev, &spi->dev); return ade7854_probe(indio_dev, &spi->dev);
} }
static int ade7854_spi_remove(struct spi_device *spi)
{
ade7854_remove(spi_get_drvdata(spi));
return 0;
}
static const struct spi_device_id ade7854_id[] = { static const struct spi_device_id ade7854_id[] = {
{ "ade7854", 0 }, { "ade7854", 0 },
{ "ade7858", 0 }, { "ade7858", 0 },
@ -316,7 +310,6 @@ static struct spi_driver ade7854_driver = {
.name = "ade7854", .name = "ade7854",
}, },
.probe = ade7854_spi_probe, .probe = ade7854_spi_probe,
.remove = ade7854_spi_remove,
.id_table = ade7854_id, .id_table = ade7854_id,
}; };
module_spi_driver(ade7854_driver); module_spi_driver(ade7854_driver);

View File

@ -548,31 +548,15 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev)
indio_dev->info = &ade7854_info; indio_dev->info = &ade7854_info;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
ret = iio_device_register(indio_dev); ret = devm_iio_device_register(dev, indio_dev);
if (ret) if (ret)
return ret; return ret;
/* Get the device into a sane initial state */ /* Get the device into a sane initial state */
ret = ade7854_initial_setup(indio_dev); return ade7854_initial_setup(indio_dev);
if (ret)
goto error_unreg_dev;
return 0;
error_unreg_dev:
iio_device_unregister(indio_dev);
return ret;
} }
EXPORT_SYMBOL(ade7854_probe); EXPORT_SYMBOL(ade7854_probe);
int ade7854_remove(struct iio_dev *indio_dev)
{
iio_device_unregister(indio_dev);
return 0;
}
EXPORT_SYMBOL(ade7854_remove);
MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
MODULE_DESCRIPTION("Analog Devices ADE7854/58/68/78 Polyphase Energy Meter"); MODULE_DESCRIPTION("Analog Devices ADE7854/58/68/78 Polyphase Energy Meter");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");