linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <aardelean@deviqon.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	denis.ciocca@st.com
Subject: Re: [PATCH 1/4] iio: pressure: st_pressure: use devm_iio_triggered_buffer_setup() for buffer
Date: Mon, 26 Jul 2021 09:48:49 +0300	[thread overview]
Message-ID: <CAASAkoasKea5t_nB6JZtaPj4hrzShQh7kjeBwHieCyq4+S=O6g@mail.gmail.com> (raw)
In-Reply-To: <20210724164301.54008712@jic23-huawei>

On Sat, 24 Jul 2021 at 18:40, Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Tue, 20 Jul 2021 10:46:39 +0300
> Alexandru Ardelean <aardelean@deviqon.com> wrote:
>
> > The st_press_allocate_ring() function calls iio_triggered_buffer_setup() to
> > allocate a triggered buffer.
> >
> > But the same can be done with devm_iio_triggered_buffer_setup() and then
> > the st_press_common_remove() no longer needs to manually deallocate it.
> >
> > We know that the parent of the IIO device is used to manage other instances
> > of the devm unwind, so it can be used in the st_press_allocate_ring() as
> > well.
>
> This raises an interesting point.  This driver mixes and matches between
> hanging devm off the parent and off the iio_dev->dev.

iio_dev->dev.parent and the devm parent are the same reference but
coming off from different pointers

>
> That's probably not a good thing to do as it could lead to an odd unwind
> order.  I'm pretty sure the changes here are fine, but we should take
> a closer look...

hmm, let me send a follow-up series

>
> Series applied to the togreg branch of iio.git and pushed out as testing.
>

thank you :)

> You can do the same thing with the trigger with only slightly more complex
> patch, but I'd like to discuss whether there are races because of the current
> dev mix and match before that.

will send follow-up series;
i was not sure whether to send everything in one go;
maybe it would have been a good idea; but i thought this one could be
find on it's own;

>
> Thanks,
>
> Jonathan
>
>
> >
> > Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
> > ---
> >  drivers/iio/pressure/st_pressure.h        | 5 -----
> >  drivers/iio/pressure/st_pressure_buffer.c | 9 ++-------
> >  drivers/iio/pressure/st_pressure_core.c   | 6 +-----
> >  3 files changed, 3 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
> > index 9417b3bd7513..156e6a72dc5c 100644
> > --- a/drivers/iio/pressure/st_pressure.h
> > +++ b/drivers/iio/pressure/st_pressure.h
> > @@ -43,7 +43,6 @@ static __maybe_unused const struct st_sensors_platform_data default_press_pdata
> >
> >  #ifdef CONFIG_IIO_BUFFER
> >  int st_press_allocate_ring(struct iio_dev *indio_dev);
> > -void st_press_deallocate_ring(struct iio_dev *indio_dev);
> >  int st_press_trig_set_state(struct iio_trigger *trig, bool state);
> >  #define ST_PRESS_TRIGGER_SET_STATE (&st_press_trig_set_state)
> >  #else /* CONFIG_IIO_BUFFER */
> > @@ -51,10 +50,6 @@ static inline int st_press_allocate_ring(struct iio_dev *indio_dev)
> >  {
> >       return 0;
> >  }
> > -
> > -static inline void st_press_deallocate_ring(struct iio_dev *indio_dev)
> > -{
> > -}
> >  #define ST_PRESS_TRIGGER_SET_STATE NULL
> >  #endif /* CONFIG_IIO_BUFFER */
> >
> > diff --git a/drivers/iio/pressure/st_pressure_buffer.c b/drivers/iio/pressure/st_pressure_buffer.c
> > index b651e7c31e90..25dbd5476b26 100644
> > --- a/drivers/iio/pressure/st_pressure_buffer.c
> > +++ b/drivers/iio/pressure/st_pressure_buffer.c
> > @@ -41,13 +41,8 @@ static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = {
> >
> >  int st_press_allocate_ring(struct iio_dev *indio_dev)
> >  {
> > -     return iio_triggered_buffer_setup(indio_dev, NULL,
> > -             &st_sensors_trigger_handler, &st_press_buffer_setup_ops);
> > -}
> > -
> > -void st_press_deallocate_ring(struct iio_dev *indio_dev)
> > -{
> > -     iio_triggered_buffer_cleanup(indio_dev);
> > +     return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev,
> > +             NULL, &st_sensors_trigger_handler, &st_press_buffer_setup_ops);
> >  }
> >
> >  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
> > diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> > index 4ff6d40e3670..ab1c17fac807 100644
> > --- a/drivers/iio/pressure/st_pressure_core.c
> > +++ b/drivers/iio/pressure/st_pressure_core.c
> > @@ -718,7 +718,7 @@ int st_press_common_probe(struct iio_dev *indio_dev)
> >               err = st_sensors_allocate_trigger(indio_dev,
> >                                                 ST_PRESS_TRIGGER_OPS);
> >               if (err < 0)
> > -                     goto st_press_probe_trigger_error;
> > +                     return err;
> >       }
> >
> >       err = iio_device_register(indio_dev);
> > @@ -733,8 +733,6 @@ int st_press_common_probe(struct iio_dev *indio_dev)
> >  st_press_device_register_error:
> >       if (press_data->irq > 0)
> >               st_sensors_deallocate_trigger(indio_dev);
> > -st_press_probe_trigger_error:
> > -     st_press_deallocate_ring(indio_dev);
> >       return err;
> >  }
> >  EXPORT_SYMBOL(st_press_common_probe);
> > @@ -746,8 +744,6 @@ void st_press_common_remove(struct iio_dev *indio_dev)
> >       iio_device_unregister(indio_dev);
> >       if (press_data->irq > 0)
> >               st_sensors_deallocate_trigger(indio_dev);
> > -
> > -     st_press_deallocate_ring(indio_dev);
> >  }
> >  EXPORT_SYMBOL(st_press_common_remove);
> >
>

      reply	other threads:[~2021-07-26  6:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20  7:46 Alexandru Ardelean
2021-07-20  7:46 ` [PATCH 2/4] iio: accel: st_accel: " Alexandru Ardelean
2021-07-20  7:46 ` [PATCH 3/4] iio: magn: st_magn: " Alexandru Ardelean
2021-07-20  7:46 ` [PATCH 4/4] iio: gyro: st_gyro: " Alexandru Ardelean
2021-07-24 15:43 ` [PATCH 1/4] iio: pressure: st_pressure: " Jonathan Cameron
2021-07-26  6:48   ` Alexandru Ardelean [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAASAkoasKea5t_nB6JZtaPj4hrzShQh7kjeBwHieCyq4+S=O6g@mail.gmail.com' \
    --to=aardelean@deviqon.com \
    --cc=denis.ciocca@st.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 1/4] iio: pressure: st_pressure: use devm_iio_triggered_buffer_setup() for buffer' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).