@@ -172,11 +172,6 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info ec_sensors_info = {
- .read_raw = &cros_ec_sensors_read,
- .write_raw = &cros_ec_sensors_write,
-};
-
static int cros_ec_sensors_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -199,7 +194,6 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
if (ret)
return ret;
- indio_dev->info = &ec_sensors_info;
state = iio_priv(indio_dev);
for (channel = state->channels, i = CROS_EC_SENSOR_X;
i < CROS_EC_SENSOR_MAX_AXIS; i++, channel++) {
@@ -235,6 +229,8 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
return -EINVAL;
}
}
+ state->core.info.read_raw = &cros_ec_sensors_read;
+ state->core.info.write_raw = &cros_ec_sensors_write;
/* Timestamp */
channel->type = IIO_TIMESTAMP;
@@ -68,6 +68,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
state->loc = state->resp->info.location;
}
+ indio_dev->info = &state->info;
+
return 0;
}
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
@@ -161,11 +161,6 @@ static int cros_ec_light_prox_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info cros_ec_light_prox_info = {
- .read_raw = &cros_ec_light_prox_read,
- .write_raw = &cros_ec_light_prox_write,
-};
-
static int cros_ec_light_prox_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -188,10 +183,11 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
if (ret)
return ret;
- indio_dev->info = &cros_ec_light_prox_info;
state = iio_priv(indio_dev);
state->core.type = state->core.resp->info.type;
state->core.loc = state->core.resp->info.location;
+ state->core.info.read_raw = &cros_ec_light_prox_read;
+ state->core.info.write_raw = &cros_ec_light_prox_write;
channel = state->channels;
/* Common part */
@@ -107,11 +107,6 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info cros_ec_baro_info = {
- .read_raw = &cros_ec_baro_read,
- .write_raw = &cros_ec_baro_write,
-};
-
static int cros_ec_baro_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -134,10 +129,11 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
if (ret)
return ret;
- indio_dev->info = &cros_ec_baro_info;
state = iio_priv(indio_dev);
state->core.type = state->core.resp->info.type;
state->core.loc = state->core.resp->info.location;
+ state->core.info.read_raw = &cros_ec_baro_read;
+ state->core.info.write_raw = &cros_ec_baro_write;
channel = state->channels;
/* Common part */
channel->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
@@ -70,6 +70,7 @@ struct cros_ec_sensors_core_state {
unsigned long scan_mask, s16 *data);
int curr_sampl_freq;
+ struct iio_info info;
};
/**
In order to avoid code duplication and make future works easier, we add an iio_info structure to cros_ec_sensors_core_state structure. Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com> --- drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 8 ++------ drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 2 ++ drivers/iio/light/cros_ec_light_prox.c | 8 ++------ drivers/iio/pressure/cros_ec_baro.c | 8 ++------ include/linux/iio/common/cros_ec_sensors_core.h | 1 + 5 files changed, 9 insertions(+), 18 deletions(-)