Skip to contentSkip to conversation

iio:accel: call device unregister function if common_proble fails

PATCH New Denis CIOCCA 1 participant 4 messages Feb 14, 2014 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 iio:accel: call device unregister function if common_proble fails

If st_accel_common_probe function fails, the device must be unregistered. Used devm_iio_device_unregister function instead of iio_device_unregister also in the common remove function.

---
 drivers/iio/accel/st_accel_core.c | 2 +-
 drivers/iio/accel/st_accel_i2c.c  | 6 +++++-
 drivers/iio/accel/st_accel_spi.c  | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/iio/accel/st_accel_core.c +1 -1
index 38caedc..72d560f 100644
@@ -512,7 +512,7 @@ void st_accel_common_remove(struct iio_dev *indio_dev)
 {
 	struct st_sensor_data *adata = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
+	devm_iio_device_unregister(adata->dev, indio_dev);
 	if (adata->get_irq_data_ready(indio_dev) > 0)
 		st_sensors_deallocate_trigger(indio_dev);
 
drivers/iio/accel/st_accel_i2c.c +5 -1
index d7bedbd..a31473d 100644
@@ -36,9 +36,13 @@ static int st_accel_i2c_probe(struct i2c_client *client,
 
 	err = st_accel_common_probe(indio_dev, client->dev.platform_data);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&client->dev, indio_dev);
+	return err;
 }
 
 static int st_accel_i2c_remove(struct i2c_client *client)
drivers/iio/accel/st_accel_spi.c +5 -1
index 1956396..e687722 100644
@@ -35,9 +35,13 @@ static int st_accel_spi_probe(struct spi_device *spi)
 
 	err = st_accel_common_probe(indio_dev, spi->dev.platform_data);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&spi->dev, indio_dev);
+	return err;
 }
 
 static int st_accel_spi_remove(struct spi_device *spi)
Signature · 1 line
1.8.5.4
#1 lore raw

PATCH 2/4 iio:gyro: call device unregister function if common_proble fails

If st_gyro_common_probe function fails, the device must be unregistered. Used devm_iio_device_unregister function instead of iio_device_unregister also in the common remove function.

---
 drivers/iio/gyro/st_gyro_core.c | 2 +-
 drivers/iio/gyro/st_gyro_i2c.c  | 6 +++++-
 drivers/iio/gyro/st_gyro_spi.c  | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/iio/gyro/st_gyro_core.c +1 -1
index a8e174a..67f88ed 100644
@@ -360,7 +360,7 @@ void st_gyro_common_remove(struct iio_dev *indio_dev)
 {
 	struct st_sensor_data *gdata = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
+	devm_iio_device_unregister(gdata->dev, indio_dev);
 	if (gdata->get_irq_data_ready(indio_dev) > 0)
 		st_sensors_deallocate_trigger(indio_dev);
 
drivers/iio/gyro/st_gyro_i2c.c +5 -1
index 23c12f3..41def78 100644
@@ -37,9 +37,13 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
 	err = st_gyro_common_probe(indio_dev,
 				(struct st_sensors_platform_data *)&gyro_pdata);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&client->dev, indio_dev);
+	return err;
 }
 
 static int st_gyro_i2c_remove(struct i2c_client *client)
drivers/iio/gyro/st_gyro_spi.c +5 -1
index b4ad3be..9fc1a57 100644
@@ -36,9 +36,13 @@ static int st_gyro_spi_probe(struct spi_device *spi)
 	err = st_gyro_common_probe(indio_dev,
 				(struct st_sensors_platform_data *)&gyro_pdata);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&spi->dev, indio_dev);
+	return err;
 }
 
 static int st_gyro_spi_remove(struct spi_device *spi)
Signature · 1 line
1.8.5.4
#2 lore raw

PATCH 3/4 iio:magnetometer: call device unregister function if common_proble fails

In reply to Denis CIOCCA

If st_magn_common_probe function fails, the device must be unregistered. Used devm_iio_device_unregister function instead of iio_device_unregister also in the common remove function.

---
 drivers/iio/magnetometer/st_magn_core.c | 2 +-
 drivers/iio/magnetometer/st_magn_i2c.c  | 6 +++++-
 drivers/iio/magnetometer/st_magn_spi.c  | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/iio/magnetometer/st_magn_core.c +1 -1
index 52bbcfa..344b9cd 100644
@@ -403,7 +403,7 @@ void st_magn_common_remove(struct iio_dev *indio_dev)
 {
 	struct st_sensor_data *mdata = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
+	devm_iio_device_unregister(mdata->dev, indio_dev);
 	if (mdata->get_irq_data_ready(indio_dev) > 0)
 		st_sensors_deallocate_trigger(indio_dev);
 
drivers/iio/magnetometer/st_magn_i2c.c +5 -1
index 892e0fe..02c6da1 100644
@@ -36,9 +36,13 @@ static int st_magn_i2c_probe(struct i2c_client *client,
 
 	err = st_magn_common_probe(indio_dev, NULL);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&client->dev, indio_dev);
+	return err;
 }
 
 static int st_magn_i2c_remove(struct i2c_client *client)
drivers/iio/magnetometer/st_magn_spi.c +5 -1
index a6143ea..5c2f6fa 100644
@@ -35,9 +35,13 @@ static int st_magn_spi_probe(struct spi_device *spi)
 
 	err = st_magn_common_probe(indio_dev, NULL);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&spi->dev, indio_dev);
+	return err;
 }
 
 static int st_magn_spi_remove(struct spi_device *spi)
Signature · 1 line
1.8.5.4
#3 lore raw

PATCH 4/4 iio:pressure: call device unregister function if common_proble fails

In reply to Denis CIOCCA

If st_press_common_probe function fails, the device must be unregistered. Used devm_iio_device_unregister function instead of iio_device_unregister also in the common remove function.

---
 drivers/iio/pressure/st_pressure_core.c | 2 +-
 drivers/iio/pressure/st_pressure_i2c.c  | 6 +++++-
 drivers/iio/pressure/st_pressure_spi.c  | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/iio/pressure/st_pressure_core.c +1 -1
index 58083f9..99170dd 100644
@@ -419,7 +419,7 @@ void st_press_common_remove(struct iio_dev *indio_dev)
 
 	st_press_power_disable(indio_dev);
 
-	iio_device_unregister(indio_dev);
+	devm_iio_device_unregister(pdata->dev, indio_dev);
 	if (pdata->get_irq_data_ready(indio_dev) > 0)
 		st_sensors_deallocate_trigger(indio_dev);
 
drivers/iio/pressure/st_pressure_i2c.c +5 -1
index 51eab7f..9ccfc19 100644
@@ -36,9 +36,13 @@ static int st_press_i2c_probe(struct i2c_client *client,
 
 	err = st_press_common_probe(indio_dev, client->dev.platform_data);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&client->dev, indio_dev);
+	return err;
 }
 
 static int st_press_i2c_remove(struct i2c_client *client)
drivers/iio/pressure/st_pressure_spi.c +5 -1
index 27322af..3af81c0 100644
@@ -35,9 +35,13 @@ static int st_press_spi_probe(struct spi_device *spi)
 
 	err = st_press_common_probe(indio_dev, spi->dev.platform_data);
 	if (err < 0)
-		return err;
+		goto device_unregister;
 
 	return 0;
+
+device_unregister:
+	devm_iio_device_unregister(&spi->dev, indio_dev);
+	return err;
 }
 
 static int st_press_spi_remove(struct spi_device *spi)
Signature · 1 line
1.8.5.4