[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191215155846.37c85c2e@archlinux>
Date: Sun, 15 Dec 2019 15:58:46 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Sasha Levin <sashal@...nel.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Alexandru Ardelean <alexandru.ardelean@...log.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
linux-iio@...r.kernel.org
Subject: Re: [PATCH AUTOSEL 5.4 192/350] iio: dln2-adc: fix
iio_triggered_buffer_postenable() position
On Tue, 10 Dec 2019 16:04:57 -0500
Sasha Levin <sashal@...nel.org> wrote:
> From: Alexandru Ardelean <alexandru.ardelean@...log.com>
>
> [ Upstream commit a7bddfe2dfce1d8859422124abe1964e0ecd386e ]
>
> The iio_triggered_buffer_postenable() hook should be called first to
> attach the poll function. The iio_triggered_buffer_predisable() hook is
> called last (as is it should).
>
> This change moves iio_triggered_buffer_postenable() to be called first. It
> adds iio_triggered_buffer_predisable() on the error paths of the postenable
> hook.
> For the predisable hook, some code-paths have been changed to make sure
> that the iio_triggered_buffer_predisable() hook gets called in case there
> is an error before it.
Again, fixing logic to allow a more generic rework rather than actual bug.
I didn't do a very good job of adding notes to all of these to indicate
they weren't stable material. Sorry about that.
Note I am fairly careful about tagging fixes that should go to stable...
Jonathan
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> Signed-off-by: Sasha Levin <sashal@...nel.org>
> ---
> drivers/iio/adc/dln2-adc.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
> index 5fa78c273a258..65c7c9329b1c3 100644
> --- a/drivers/iio/adc/dln2-adc.c
> +++ b/drivers/iio/adc/dln2-adc.c
> @@ -524,6 +524,10 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
> u16 conflict;
> unsigned int trigger_chan;
>
> + ret = iio_triggered_buffer_postenable(indio_dev);
> + if (ret)
> + return ret;
> +
> mutex_lock(&dln2->mutex);
>
> /* Enable ADC */
> @@ -537,6 +541,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
> (int)conflict);
> ret = -EBUSY;
> }
> + iio_triggered_buffer_predisable(indio_dev);
> return ret;
> }
>
> @@ -550,6 +555,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
> mutex_unlock(&dln2->mutex);
> if (ret < 0) {
> dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
> + iio_triggered_buffer_predisable(indio_dev);
> return ret;
> }
> } else {
> @@ -557,12 +563,12 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
> mutex_unlock(&dln2->mutex);
> }
>
> - return iio_triggered_buffer_postenable(indio_dev);
> + return 0;
> }
>
> static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
> {
> - int ret;
> + int ret, ret2;
> struct dln2_adc *dln2 = iio_priv(indio_dev);
>
> mutex_lock(&dln2->mutex);
> @@ -577,12 +583,14 @@ static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
> ret = dln2_adc_set_port_enabled(dln2, false, NULL);
>
> mutex_unlock(&dln2->mutex);
> - if (ret < 0) {
> + if (ret < 0)
> dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
> - return ret;
> - }
>
> - return iio_triggered_buffer_predisable(indio_dev);
> + ret2 = iio_triggered_buffer_predisable(indio_dev);
> + if (ret == 0)
> + ret = ret2;
> +
> + return ret;
> }
>
> static const struct iio_buffer_setup_ops dln2_adc_buffer_setup_ops = {
Powered by blists - more mailing lists