staging:iio: fix removal path to allow correct freeing.

Fix a dumb lack of consideration of the effect of combining
the iio_device_unregister and iio_free_device calls into
one.  There is no valid place to free some of the sysfs
array elements.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Jonathan Cameron 2011-10-14 14:46:58 +01:00 committed by Greg Kroah-Hartman
parent cdea0bec8d
commit d2fffd6c2f
60 changed files with 146 additions and 109 deletions

View file

@ -532,10 +532,11 @@ static int adis16201_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
adis16201_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16201_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -487,10 +487,11 @@ static int adis16203_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
adis16203_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16203_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -560,10 +560,11 @@ static int adis16204_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
adis16204_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16204_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -536,10 +536,11 @@ static int adis16209_remove(struct spi_device *spi)
flush_scheduled_work();
iio_device_unregister(indio_dev);
adis16209_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16209_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -624,7 +624,7 @@ static const struct iio_info adis16220_info = {
static int __devinit adis16220_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adis16220_state *st;
struct iio_dev *indio_dev;
@ -652,11 +652,10 @@ static int __devinit adis16220_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;
regdone = 1;
ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin);
if (ret)
goto error_free_dev;
goto error_unregister_dev;
ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin);
if (ret)
@ -678,11 +677,10 @@ error_rm_adc1_bin:
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
error_rm_accel_bin:
sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
error_unregister_dev:
iio_device_unregister(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
@ -697,6 +695,7 @@ static int adis16220_remove(struct spi_device *spi)
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -589,10 +589,11 @@ static int adis16240_remove(struct spi_device *spi)
flush_scheduled_work();
iio_device_unregister(indio_dev);
adis16240_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16240_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -262,6 +262,7 @@ error_ret:
static int __devexit kxsd9_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -736,7 +736,7 @@ error_uninitialize_buffer:
error_unreg_buffer_funcs:
lis3l02dq_unconfigure_buffer(indio_dev);
error_free_dev:
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
@ -774,6 +774,8 @@ static int lis3l02dq_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct lis3l02dq_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
ret = lis3l02dq_disable_all_events(indio_dev);
if (ret)
goto err_ret;
@ -789,8 +791,7 @@ static int lis3l02dq_remove(struct spi_device *spi)
iio_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_buffer(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
err_ret:
return ret;
}

View file

@ -1122,7 +1122,7 @@ static const struct iio_info sca3000_info_with_temp = {
static int __devinit sca3000_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct sca3000_state *st;
struct iio_dev *indio_dev;
@ -1154,7 +1154,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret < 0)
goto error_free_dev;
regdone = 1;
ret = iio_buffer_register(indio_dev,
sca3000_channels,
ARRAY_SIZE(sca3000_channels));
@ -1188,11 +1188,9 @@ error_free_irq:
error_unregister_ring:
iio_buffer_unregister(indio_dev);
error_unregister_dev:
iio_device_unregister(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
@ -1227,9 +1225,10 @@ static int sca3000_remove(struct spi_device *spi)
return ret;
if (spi->irq)
free_irq(spi->irq, indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
sca3000_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -628,13 +628,14 @@ static int __devexit ad7150_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
if (client->irq)
free_irq(client->irq, indio_dev);
if (client->dev.platform_data)
free_irq(*(unsigned int *)client->dev.platform_data, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -519,6 +519,7 @@ static int __devexit ad7152_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -1032,7 +1032,7 @@ static int __devinit ad7192_probe(struct spi_device *spi)
struct ad7192_platform_data *pdata = spi->dev.platform_data;
struct ad7192_state *st;
struct iio_dev *indio_dev;
int ret, i , voltage_uv = 0, regdone = 0;
int ret, i , voltage_uv = 0;
if (!pdata) {
dev_err(&spi->dev, "no platform data?\n");
@ -1090,14 +1090,9 @@ static int __devinit ad7192_probe(struct spi_device *spi)
if (ret)
goto error_disable_reg;
ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring;
regdone = 1;
ret = ad7192_probe_trigger(indio_dev);
if (ret)
goto error_unreg_ring;
goto error_ring_cleanup;
ret = iio_buffer_register(indio_dev,
indio_dev->channels,
@ -1107,15 +1102,18 @@ static int __devinit ad7192_probe(struct spi_device *spi)
ret = ad7192_setup(st);
if (ret)
goto error_uninitialize_ring;
goto error_unreg_ring;
ret = iio_device_register(indio_dev);
if (ret < 0)
goto error_unreg_ring;
return 0;
error_uninitialize_ring:
error_unreg_ring:
iio_buffer_unregister(indio_dev);
error_remove_trigger:
ad7192_remove_trigger(indio_dev);
error_unreg_ring:
error_ring_cleanup:
ad7192_ring_cleanup(indio_dev);
error_disable_reg:
if (!IS_ERR(st->reg))
@ -1124,10 +1122,7 @@ error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
return ret;
}
@ -1137,6 +1132,7 @@ static int ad7192_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7192_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7192_remove_trigger(indio_dev);
ad7192_ring_cleanup(indio_dev);
@ -1146,8 +1142,6 @@ static int ad7192_remove(struct spi_device *spi)
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
return 0;
}

View file

@ -831,7 +831,7 @@ static int __devinit ad7280_probe(struct spi_device *spi)
{
const struct ad7280_platform_data *pdata = spi->dev.platform_data;
struct ad7280_state *st;
int ret, regdone = 0;
int ret;
const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
const unsigned short nAVG[4] = {1, 2, 4, 8};
struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
@ -903,21 +903,20 @@ static int __devinit ad7280_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret)
goto error_free_attr;
regdone = 1;
if (spi->irq > 0) {
ret = ad7280_write(st, AD7280A_DEVADDR_MASTER,
AD7280A_ALERT, 1,
AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN);
if (ret)
goto error_free_attr;
goto error_unregister;
ret = ad7280_write(st, AD7280A_DEVADDR(st->slave_num),
AD7280A_ALERT, 0,
AD7280A_ALERT_GEN_STATIC_HIGH |
(pdata->chain_last_alert_ignore & 0xF));
if (ret)
goto error_free_attr;
goto error_unregister;
ret = request_threaded_irq(spi->irq,
NULL,
@ -927,10 +926,12 @@ static int __devinit ad7280_probe(struct spi_device *spi)
indio_dev->name,
indio_dev);
if (ret)
goto error_free_attr;
goto error_unregister;
}
return 0;
error_unregister:
iio_device_unregister(indio_dev);
error_free_attr:
kfree(st->iio_attr);
@ -939,10 +940,7 @@ error_free_channels:
kfree(st->channels);
error_free_device:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
return ret;
}
@ -954,13 +952,14 @@ static int __devexit ad7280_remove(struct spi_device *spi)
if (spi->irq > 0)
free_irq(spi->irq, indio_dev);
iio_device_unregister(indio_dev);
ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1,
AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb);
kfree(st->channels);
kfree(st->iio_attr);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -670,6 +670,8 @@ static int __devexit ad7291_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ad7291_chip_info *chip = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (client->irq)
free_irq(client->irq, indio_dev);
@ -678,7 +680,7 @@ static int __devexit ad7291_remove(struct i2c_client *client)
regulator_put(chip->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -249,14 +249,14 @@ static int __devexit ad7298_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7298_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7298_ring_cleanup(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -211,13 +211,14 @@ static int ad7476_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7476_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7476_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -545,6 +545,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq)
{
struct ad7606_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7606_ring_cleanup(indio_dev);
@ -555,7 +556,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq)
}
ad7606_free_gpios(st);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -766,6 +766,7 @@ static int __devexit ad7746_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -255,13 +255,14 @@ static int ad7780_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7780_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
free_irq(spi->irq, st);
gpio_free(st->pdata->gpio_pdrst);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -1013,6 +1013,7 @@ static int ad7793_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7793_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7793_remove_trigger(indio_dev);
ad7793_ring_cleanup(indio_dev);
@ -1022,7 +1023,7 @@ static int ad7793_remove(struct spi_device *spi)
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -435,13 +435,14 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev)
struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
dev_set_drvdata(&spi_dev->dev, NULL);
if (spi_dev->irq)
free_irq(spi_dev->irq, indio_dev);
gpio_free(chip->busy_pin);
gpio_free(chip->convert_pin);
gpio_free(chip->rdwr_pin);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -230,13 +230,14 @@ static int ad7887_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7887_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
ad7887_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -892,6 +892,7 @@ static __devexit int ad799x_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ad799x_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (client->irq > 0)
free_irq(client->irq, indio_dev);
@ -901,7 +902,7 @@ static __devexit int ad799x_remove(struct i2c_client *client)
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -856,12 +856,13 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev)
struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev);
unsigned long *adt7310_platform_data = spi_dev->dev.platform_data;
iio_device_unregister(indio_dev);
dev_set_drvdata(&spi_dev->dev, NULL);
if (adt7310_platform_data[0])
free_irq(adt7310_platform_data[0], indio_dev);
if (spi_dev->irq)
free_irq(spi_dev->irq, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -819,11 +819,12 @@ static int __devexit adt7410_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
unsigned long *adt7410_platform_data = client->dev.platform_data;
iio_device_unregister(indio_dev);
if (adt7410_platform_data[0])
free_irq(adt7410_platform_data[0], indio_dev);
if (client->irq)
free_irq(client->irq, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -1347,6 +1347,7 @@ static int max1363_remove(struct i2c_client *client)
struct max1363_state *st = iio_priv(indio_dev);
struct regulator *reg = st->reg;
iio_device_unregister(indio_dev);
if (client->irq)
free_irq(st->client->irq, indio_dev);
iio_buffer_unregister(indio_dev);
@ -1356,7 +1357,7 @@ static int max1363_remove(struct i2c_client *client)
regulator_disable(reg);
regulator_put(reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -2219,9 +2219,10 @@ int __devexit adt7316_remove(struct device *dev)
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (chip->bus.irq)
free_irq(chip->bus.irq, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -424,13 +424,14 @@ static int ad5446_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad5446_state *st = iio_priv(indio_dev);
struct regulator *reg = st->reg;
iio_device_unregister(indio_dev);
if (!IS_ERR(reg)) {
regulator_disable(reg);
regulator_put(reg);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_free_device(indio_dev);
return 0;
}

View file

@ -349,6 +349,7 @@ static int __devexit ad5504_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad5504_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (spi->irq)
free_irq(spi->irq, indio_dev);
@ -356,8 +357,7 @@ static int __devexit ad5504_remove(struct spi_device *spi)
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -288,11 +288,12 @@ static int __devexit ad5624r_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad5624r_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -420,12 +420,12 @@ static int __devexit ad5686_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad5686_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -370,6 +370,7 @@ static int __devexit ad5791_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad5791_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(st->reg_vdd)) {
regulator_disable(st->reg_vdd);
regulator_put(st->reg_vdd);
@ -379,9 +380,7 @@ static int __devexit ad5791_remove(struct spi_device *spi)
regulator_disable(st->reg_vss);
regulator_put(st->reg_vss);
}
iio_device_unregister(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -130,6 +130,7 @@ error_ret:
static int __devexit ad5930_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -328,13 +328,14 @@ static int __devexit ad9832_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad9832_state *st = iio_priv(indio_dev);
struct regulator *reg = st->reg;
iio_device_unregister(indio_dev);
if (!IS_ERR(reg)) {
regulator_disable(reg);
regulator_put(reg);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_free_device(indio_dev);
return 0;
}

View file

@ -417,13 +417,13 @@ static int __devexit ad9834_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad9834_state *st = iio_priv(indio_dev);
struct regulator *reg = st->reg;
iio_device_unregister(indio_dev);
if (!IS_ERR(reg)) {
regulator_disable(reg);
regulator_put(reg);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_free_device(indio_dev);
return 0;
}

View file

@ -116,6 +116,7 @@ error_ret:
static int __devexit ad9850_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -267,6 +267,7 @@ error_ret:
static int __devexit ad9852_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -400,6 +400,7 @@ error_ret:
static int __devexit ad9910_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -211,6 +211,7 @@ error_ret:
static int __devexit ad9951_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -183,6 +183,7 @@ error_ret:
static int adis16060_r_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -176,6 +176,7 @@ error_ret:
static int adis16080_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -155,6 +155,7 @@ error_ret:
static int adis16130_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -672,6 +672,8 @@ static int adis16260_remove(struct spi_device *spi)
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
ret = adis16260_stop_device(indio_dev);
if (ret)
goto err_ret;
@ -681,7 +683,7 @@ static int adis16260_remove(struct spi_device *spi)
adis16260_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16260_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
err_ret:
return ret;

View file

@ -324,7 +324,7 @@ static const struct iio_info adxrs450_info = {
static int __devinit adxrs450_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adxrs450_state *st;
struct iio_dev *indio_dev;
@ -350,20 +350,16 @@ static int __devinit adxrs450_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;
regdone = 1;
/* Get the device into a sane initial state */
ret = adxrs450_initial_setup(indio_dev);
if (ret)
goto error_initial;
return 0;
error_initial:
iio_device_unregister(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
@ -372,6 +368,7 @@ error_ret:
static int adxrs450_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -768,13 +768,14 @@ static __devexit int ad5933_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ad5933_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
iio_sw_rb_free(indio_dev->buffer);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -1088,6 +1088,7 @@ static int adis16400_remove(struct spi_device *spi)
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
ret = adis16400_stop_device(indio_dev);
if (ret)
goto err_ret;
@ -1095,7 +1096,7 @@ static int adis16400_remove(struct spi_device *spi)
adis16400_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16400_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;

View file

@ -971,7 +971,6 @@ static int iio_device_register_eventset(struct iio_dev *indio_dev)
l)
indio_dev->event_interface->group.attrs[attrn++] =
&p->dev_attr.attr;
indio_dev->groups[indio_dev->groupcounter++] =
&indio_dev->event_interface->group;
@ -1002,8 +1001,6 @@ static void iio_dev_release(struct device *device)
iio_device_unregister_trigger_consumer(indio_dev);
iio_device_unregister_eventset(indio_dev);
iio_device_unregister_sysfs(indio_dev);
ida_simple_remove(&iio_ida, indio_dev->id);
kfree(indio_dev);
}
static struct device_type iio_dev_type = {

View file

@ -581,6 +581,7 @@ static int __devexit isl29018_remove(struct i2c_client *client)
dev_dbg(&client->dev, "%s()\n", __func__);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -789,6 +789,8 @@ static int tsl2563_remove(struct i2c_client *client)
{
struct tsl2563_chip *chip = i2c_get_clientdata(client);
struct iio_dev *indio_dev = iio_priv_to_dev(chip);
iio_device_unregister(indio_dev);
if (!chip->int_enabled)
cancel_delayed_work(&chip->poweroff_work);
/* Ensure that interrupts are disabled - then flush any bottom halves */
@ -799,7 +801,8 @@ static int tsl2563_remove(struct i2c_client *client)
tsl2563_set_power(chip, 0);
if (client->irq)
free_irq(client->irq, indio_dev);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -909,6 +909,7 @@ static int taos_resume(struct i2c_client *client)
static int __devexit taos_remove(struct i2c_client *client)
{
iio_device_unregister(i2c_get_clientdata(client));
iio_free_device(i2c_get_clientdata(client));
return 0;
}

View file

@ -546,12 +546,13 @@ static int ak8975_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ak8975_data *data = iio_priv(indio_dev);
int eoc_gpio = data->eoc_gpio;
iio_device_unregister(indio_dev);
if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
if (gpio_is_valid(data->eoc_gpio))
gpio_free(data->eoc_gpio);
iio_free_device(indio_dev);
return 0;
}

View file

@ -579,9 +579,11 @@ exit:
static int hmc5843_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
/* sleep mode to save power */
hmc5843_configure(client, MODE_SLEEP);
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -558,12 +558,13 @@ static int ade7753_remove(struct spi_device *spi)
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
ret = ade7753_stop_device(&(indio_dev->dev));
if (ret)
goto err_ret;
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
err_ret:
return ret;
}

View file

@ -580,11 +580,12 @@ static int ade7754_remove(struct spi_device *spi)
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
ret = ade7754_stop_device(&(indio_dev->dev));
if (ret)
goto err_ret;
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
err_ret:
return ret;

View file

@ -822,6 +822,7 @@ static int ade7758_remove(struct spi_device *spi)
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
iio_device_unregister(indio_dev);
ret = ade7758_stop_device(&indio_dev->dev);
if (ret)
goto err_ret;
@ -831,9 +832,9 @@ static int ade7758_remove(struct spi_device *spi)
ade7758_unconfigure_ring(indio_dev);
kfree(st->tx);
kfree(st->rx);
iio_device_unregister(indio_dev);
return 0;
iio_free_device(indio_dev);
err_ret:
return ret;
}

View file

@ -502,11 +502,12 @@ static int ade7759_remove(struct spi_device *spi)
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
ret = ade7759_stop_device(&(indio_dev->dev));
if (ret)
goto err_ret;
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
err_ret:
return ret;

View file

@ -590,6 +590,7 @@ EXPORT_SYMBOL(ade7854_probe);
int ade7854_remove(struct iio_dev *indio_dev)
{
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
return 0;
}

View file

@ -150,6 +150,7 @@ error_ret:
static int __devexit ad2s1200_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}

View file

@ -737,10 +737,10 @@ error_ret:
static int __devexit ad2s1210_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad2s1210_state *st = iio_priv(indio_dev);
ad2s1210_free_gpios(st);
iio_device_unregister(indio_dev);
ad2s1210_free_gpios(iio_priv(indio_dev));
iio_free_device(indio_dev);
return 0;
}

View file

@ -100,6 +100,7 @@ error_ret:
static int __devexit ad2s90_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
iio_free_device(spi_get_drvdata(spi));
return 0;
}