提交 38d1c6a9 编写于 作者: L Lee Jones 提交者: Jonathan Cameron

iio: sensors-core: st: Support sensors which don't have a Data Ready pin

Not all ST's sensors support data ready, so let's make the declaration
of one conditional.
Signed-off-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 9d6c3986
...@@ -198,21 +198,17 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) ...@@ -198,21 +198,17 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable)
} }
EXPORT_SYMBOL(st_sensors_set_axis_enable); EXPORT_SYMBOL(st_sensors_set_axis_enable);
int st_sensors_init_sensor(struct iio_dev *indio_dev, static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
struct st_sensors_platform_data *pdata) struct st_sensors_platform_data *pdata)
{ {
int err;
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
mutex_init(&sdata->tb.buf_lock);
switch (pdata->drdy_int_pin) { switch (pdata->drdy_int_pin) {
case 1: case 1:
if (sdata->sensor->drdy_irq.mask_int1 == 0) { if (sdata->sensor->drdy_irq.mask_int1 == 0) {
dev_err(&indio_dev->dev, dev_err(&indio_dev->dev,
"DRDY on INT1 not available.\n"); "DRDY on INT1 not available.\n");
err = -EINVAL; return -EINVAL;
goto init_error;
} }
sdata->drdy_int_pin = 1; sdata->drdy_int_pin = 1;
break; break;
...@@ -220,17 +216,29 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, ...@@ -220,17 +216,29 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
if (sdata->sensor->drdy_irq.mask_int2 == 0) { if (sdata->sensor->drdy_irq.mask_int2 == 0) {
dev_err(&indio_dev->dev, dev_err(&indio_dev->dev,
"DRDY on INT2 not available.\n"); "DRDY on INT2 not available.\n");
err = -EINVAL; return -EINVAL;
goto init_error;
} }
sdata->drdy_int_pin = 2; sdata->drdy_int_pin = 2;
break; break;
default: default:
dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n"); dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n");
err = -EINVAL; return -EINVAL;
goto init_error;
} }
return 0;
}
int st_sensors_init_sensor(struct iio_dev *indio_dev,
struct st_sensors_platform_data *pdata)
{
struct st_sensor_data *sdata = iio_priv(indio_dev);
int err = 0;
mutex_init(&sdata->tb.buf_lock);
if (pdata)
err = st_sensors_set_drdy_int_pin(indio_dev, pdata);
err = st_sensors_set_enable(indio_dev, false); err = st_sensors_set_enable(indio_dev, false);
if (err < 0) if (err < 0)
goto init_error; goto init_error;
...@@ -266,6 +274,9 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) ...@@ -266,6 +274,9 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
u8 drdy_mask; u8 drdy_mask;
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
if (!sdata->sensor->drdy_irq.addr)
return 0;
/* Enable/Disable the interrupt generator 1. */ /* Enable/Disable the interrupt generator 1. */
if (sdata->sensor->drdy_irq.ig1.en_addr > 0) { if (sdata->sensor->drdy_irq.ig1.en_addr > 0) {
err = st_sensors_write_data_with_mask(indio_dev, err = st_sensors_write_data_with_mask(indio_dev,
......
...@@ -254,7 +254,8 @@ int st_press_common_probe(struct iio_dev *indio_dev, ...@@ -254,7 +254,8 @@ int st_press_common_probe(struct iio_dev *indio_dev,
pdata->odr = pdata->sensor->odr.odr_avl[0].hz; pdata->odr = pdata->sensor->odr.odr_avl[0].hz;
if (!plat_data) /* Some devices don't support a data ready pin. */
if (!plat_data && pdata->sensor->drdy_irq.addr)
plat_data = plat_data =
(struct st_sensors_platform_data *)&default_press_pdata; (struct st_sensors_platform_data *)&default_press_pdata;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册