Commit e4269651 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: st_sensors: remove reference to parent device object on st_sensor_data

The idea behind it, is that all devm_ calls in ST sensors are bound to the
parent device object.

However, the reference to that object is kept on both the st_sensor_data
struct and the IIO object parent (indio_dev->dev.parent).

This change only adds a bit consistency and uses the reference stored on
indio_dev->dev.parent, to enforce the assumption that all ST sensors' devm_
calls are bound to the same reference as the one store on st_sensor_data.
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarAlexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210823112204.243255-6-aardelean@deviqon.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 6b658c31
...@@ -1210,7 +1210,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev) ...@@ -1210,7 +1210,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
}; };
adev = ACPI_COMPANION(adata->dev); adev = ACPI_COMPANION(indio_dev->dev.parent);
if (!adev) if (!adev)
return 0; return 0;
...@@ -1334,8 +1334,8 @@ EXPORT_SYMBOL(st_accel_get_settings); ...@@ -1334,8 +1334,8 @@ EXPORT_SYMBOL(st_accel_get_settings);
int st_accel_common_probe(struct iio_dev *indio_dev) int st_accel_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *adata = iio_priv(indio_dev); struct st_sensor_data *adata = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata = dev_get_platdata(adata->dev);
struct device *parent = indio_dev->dev.parent; struct device *parent = indio_dev->dev.parent;
struct st_sensors_platform_data *pdata = dev_get_platdata(parent);
int err; int err;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
...@@ -1355,7 +1355,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) ...@@ -1355,7 +1355,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
*/ */
err = apply_acpi_orientation(indio_dev); err = apply_acpi_orientation(indio_dev);
if (err) { if (err) {
err = iio_read_mount_matrix(adata->dev, &adata->mount_matrix); err = iio_read_mount_matrix(parent, &adata->mount_matrix);
if (err) if (err)
return err; return err;
} }
......
...@@ -57,7 +57,6 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev, ...@@ -57,7 +57,6 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev,
indio_dev->name = client->name; indio_dev->name = client->name;
sdata->dev = &client->dev;
sdata->irq = client->irq; sdata->irq = client->irq;
return 0; return 0;
......
...@@ -109,7 +109,6 @@ int st_sensors_spi_configure(struct iio_dev *indio_dev, ...@@ -109,7 +109,6 @@ int st_sensors_spi_configure(struct iio_dev *indio_dev,
indio_dev->name = spi->modalias; indio_dev->name = spi->modalias;
sdata->dev = &spi->dev;
sdata->irq = spi->irq; sdata->irq = spi->irq;
return 0; return 0;
......
...@@ -42,7 +42,8 @@ static bool st_sensors_new_samples_available(struct iio_dev *indio_dev, ...@@ -42,7 +42,8 @@ static bool st_sensors_new_samples_available(struct iio_dev *indio_dev,
sdata->sensor_settings->drdy_irq.stat_drdy.addr, sdata->sensor_settings->drdy_irq.stat_drdy.addr,
&status); &status);
if (ret < 0) { if (ret < 0) {
dev_err(sdata->dev, "error checking samples available\n"); dev_err(indio_dev->dev.parent,
"error checking samples available\n");
return false; return false;
} }
...@@ -87,7 +88,7 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p) ...@@ -87,7 +88,7 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p)
st_sensors_new_samples_available(indio_dev, sdata)) { st_sensors_new_samples_available(indio_dev, sdata)) {
iio_trigger_poll_chained(p); iio_trigger_poll_chained(p);
} else { } else {
dev_dbg(sdata->dev, "spurious IRQ\n"); dev_dbg(indio_dev->dev.parent, "spurious IRQ\n");
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -107,7 +108,8 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p) ...@@ -107,7 +108,8 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p)
*/ */
while (sdata->hw_irq_trigger && while (sdata->hw_irq_trigger &&
st_sensors_new_samples_available(indio_dev, sdata)) { st_sensors_new_samples_available(indio_dev, sdata)) {
dev_dbg(sdata->dev, "more samples came in during polling\n"); dev_dbg(indio_dev->dev.parent,
"more samples came in during polling\n");
sdata->hw_timestamp = iio_get_time_ns(indio_dev); sdata->hw_timestamp = iio_get_time_ns(indio_dev);
iio_trigger_poll_chained(p); iio_trigger_poll_chained(p);
} }
......
...@@ -492,7 +492,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) ...@@ -492,7 +492,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
indio_dev->channels = gdata->sensor_settings->ch; indio_dev->channels = gdata->sensor_settings->ch;
indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS; indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS;
err = iio_read_mount_matrix(gdata->dev, &gdata->mount_matrix); err = iio_read_mount_matrix(parent, &gdata->mount_matrix);
if (err) if (err)
return err; return err;
......
...@@ -90,7 +90,6 @@ static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *reg ...@@ -90,7 +90,6 @@ static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *reg
data = iio_priv(lsm9ds0->accel); data = iio_priv(lsm9ds0->accel);
data->sensor_settings = (struct st_sensor_settings *)settings; data->sensor_settings = (struct st_sensor_settings *)settings;
data->dev = dev;
data->irq = lsm9ds0->irq; data->irq = lsm9ds0->irq;
data->regmap = regmap; data->regmap = regmap;
data->vdd = lsm9ds0->vdd; data->vdd = lsm9ds0->vdd;
...@@ -119,7 +118,6 @@ static int st_lsm9ds0_probe_magn(struct st_lsm9ds0 *lsm9ds0, struct regmap *regm ...@@ -119,7 +118,6 @@ static int st_lsm9ds0_probe_magn(struct st_lsm9ds0 *lsm9ds0, struct regmap *regm
data = iio_priv(lsm9ds0->magn); data = iio_priv(lsm9ds0->magn);
data->sensor_settings = (struct st_sensor_settings *)settings; data->sensor_settings = (struct st_sensor_settings *)settings;
data->dev = dev;
data->irq = lsm9ds0->irq; data->irq = lsm9ds0->irq;
data->regmap = regmap; data->regmap = regmap;
data->vdd = lsm9ds0->vdd; data->vdd = lsm9ds0->vdd;
......
...@@ -611,8 +611,8 @@ EXPORT_SYMBOL(st_magn_get_settings); ...@@ -611,8 +611,8 @@ EXPORT_SYMBOL(st_magn_get_settings);
int st_magn_common_probe(struct iio_dev *indio_dev) int st_magn_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *mdata = iio_priv(indio_dev); struct st_sensor_data *mdata = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata = dev_get_platdata(mdata->dev);
struct device *parent = indio_dev->dev.parent; struct device *parent = indio_dev->dev.parent;
struct st_sensors_platform_data *pdata = dev_get_platdata(parent);
int err; int err;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
...@@ -626,7 +626,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) ...@@ -626,7 +626,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
indio_dev->channels = mdata->sensor_settings->ch; indio_dev->channels = mdata->sensor_settings->ch;
indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS; indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS;
err = iio_read_mount_matrix(mdata->dev, &mdata->mount_matrix); err = iio_read_mount_matrix(parent, &mdata->mount_matrix);
if (err) if (err)
return err; return err;
......
...@@ -677,8 +677,8 @@ EXPORT_SYMBOL(st_press_get_settings); ...@@ -677,8 +677,8 @@ EXPORT_SYMBOL(st_press_get_settings);
int st_press_common_probe(struct iio_dev *indio_dev) int st_press_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *press_data = iio_priv(indio_dev); struct st_sensor_data *press_data = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata = dev_get_platdata(press_data->dev);
struct device *parent = indio_dev->dev.parent; struct device *parent = indio_dev->dev.parent;
struct st_sensors_platform_data *pdata = dev_get_platdata(parent);
int err; int err;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
......
...@@ -220,7 +220,6 @@ struct st_sensor_settings { ...@@ -220,7 +220,6 @@ struct st_sensor_settings {
/** /**
* struct st_sensor_data - ST sensor device status * struct st_sensor_data - ST sensor device status
* @dev: Pointer to instance of struct device (I2C or SPI).
* @trig: The trigger in use by the core driver. * @trig: The trigger in use by the core driver.
* @mount_matrix: The mounting matrix of the sensor. * @mount_matrix: The mounting matrix of the sensor.
* @sensor_settings: Pointer to the specific sensor settings in use. * @sensor_settings: Pointer to the specific sensor settings in use.
...@@ -240,7 +239,6 @@ struct st_sensor_settings { ...@@ -240,7 +239,6 @@ struct st_sensor_settings {
* @buffer_data: Data used by buffer part. * @buffer_data: Data used by buffer part.
*/ */
struct st_sensor_data { struct st_sensor_data {
struct device *dev;
struct iio_trigger *trig; struct iio_trigger *trig;
struct iio_mount_matrix mount_matrix; struct iio_mount_matrix mount_matrix;
struct st_sensor_settings *sensor_settings; struct st_sensor_settings *sensor_settings;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment