From: Alexandru Ardelean <[email protected]>
[ Upstream commit 3cfd6464fe23deb45bb688df66184b3f32fefc16 ]
The iio_triggered_buffer_predisable() should be called last, to detach the
poll func after the devices has been suspended.
This change re-organizes things a bit so that the postenable & predisable
are symmetrical. It also converts the preenable() to a postenable().
Not stable material as there is no known problem with the current
code, it's just not consistent with the form we would like all the
IIO drivers to adopt so as to allow subsystem wide changes.
Signed-off-by: Alexandru Ardelean <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/iio/proximity/sx9500.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 612f79c53cfc6..287d288e40c27 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -675,11 +675,15 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
return IRQ_HANDLED;
}
-static int sx9500_buffer_preenable(struct iio_dev *indio_dev)
+static int sx9500_buffer_postenable(struct iio_dev *indio_dev)
{
struct sx9500_data *data = iio_priv(indio_dev);
int ret = 0, i;
+ ret = iio_triggered_buffer_postenable(indio_dev);
+ if (ret)
+ return ret;
+
mutex_lock(&data->mutex);
for (i = 0; i < SX9500_NUM_CHANNELS; i++)
@@ -696,6 +700,9 @@ static int sx9500_buffer_preenable(struct iio_dev *indio_dev)
mutex_unlock(&data->mutex);
+ if (ret)
+ iio_triggered_buffer_predisable(indio_dev);
+
return ret;
}
@@ -704,8 +711,6 @@ static int sx9500_buffer_predisable(struct iio_dev *indio_dev)
struct sx9500_data *data = iio_priv(indio_dev);
int ret = 0, i;
- iio_triggered_buffer_predisable(indio_dev);
-
mutex_lock(&data->mutex);
for (i = 0; i < SX9500_NUM_CHANNELS; i++)
@@ -722,12 +727,13 @@ static int sx9500_buffer_predisable(struct iio_dev *indio_dev)
mutex_unlock(&data->mutex);
+ iio_triggered_buffer_predisable(indio_dev);
+
return ret;
}
static const struct iio_buffer_setup_ops sx9500_buffer_setup_ops = {
- .preenable = sx9500_buffer_preenable,
- .postenable = iio_triggered_buffer_postenable,
+ .postenable = sx9500_buffer_postenable,
.predisable = sx9500_buffer_predisable,
};
--
2.20.1
On Tue, 10 Dec 2019 16:02:59 -0500
Sasha Levin <[email protected]> wrote:
> From: Alexandru Ardelean <[email protected]>
>
> [ Upstream commit 3cfd6464fe23deb45bb688df66184b3f32fefc16 ]
>
> The iio_triggered_buffer_predisable() should be called last, to detach the
> poll func after the devices has been suspended.
>
> This change re-organizes things a bit so that the postenable & predisable
> are symmetrical. It also converts the preenable() to a postenable().
>
> Not stable material as there is no known problem with the current
> code, it's just not consistent with the form we would like all the
> IIO drivers to adopt so as to allow subsystem wide changes.
See comment.
Jonathan
>
> Signed-off-by: Alexandru Ardelean <[email protected]>
> Signed-off-by: Jonathan Cameron <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> drivers/iio/proximity/sx9500.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 612f79c53cfc6..287d288e40c27 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -675,11 +675,15 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
> return IRQ_HANDLED;
> }
>
> -static int sx9500_buffer_preenable(struct iio_dev *indio_dev)
> +static int sx9500_buffer_postenable(struct iio_dev *indio_dev)
> {
> struct sx9500_data *data = iio_priv(indio_dev);
> int ret = 0, i;
>
> + ret = iio_triggered_buffer_postenable(indio_dev);
> + if (ret)
> + return ret;
> +
> mutex_lock(&data->mutex);
>
> for (i = 0; i < SX9500_NUM_CHANNELS; i++)
> @@ -696,6 +700,9 @@ static int sx9500_buffer_preenable(struct iio_dev *indio_dev)
>
> mutex_unlock(&data->mutex);
>
> + if (ret)
> + iio_triggered_buffer_predisable(indio_dev);
> +
> return ret;
> }
>
> @@ -704,8 +711,6 @@ static int sx9500_buffer_predisable(struct iio_dev *indio_dev)
> struct sx9500_data *data = iio_priv(indio_dev);
> int ret = 0, i;
>
> - iio_triggered_buffer_predisable(indio_dev);
> -
> mutex_lock(&data->mutex);
>
> for (i = 0; i < SX9500_NUM_CHANNELS; i++)
> @@ -722,12 +727,13 @@ static int sx9500_buffer_predisable(struct iio_dev *indio_dev)
>
> mutex_unlock(&data->mutex);
>
> + iio_triggered_buffer_predisable(indio_dev);
> +
> return ret;
> }
>
> static const struct iio_buffer_setup_ops sx9500_buffer_setup_ops = {
> - .preenable = sx9500_buffer_preenable,
> - .postenable = iio_triggered_buffer_postenable,
> + .postenable = sx9500_buffer_postenable,
> .predisable = sx9500_buffer_predisable,
> };
>