Re: [PATCH 09/10] iio: core: Simplify the registration of kfifo buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2 Feb 2022 09:09:36 +0100
Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote:

> Hi Jonathan,
> 
> jic23@xxxxxxxxxx wrote on Sat, 15 Jan 2022 17:12:46 +0000:
> 
> > On Thu, 16 Dec 2021 09:52:38 +0200
> > Alexandru Ardelean <ardeleanalex@xxxxxxxxx> wrote:
> >   
> > > On Wed, Dec 15, 2021 at 10:04 PM Miquel Raynal
> > > <miquel.raynal@xxxxxxxxxxx> wrote:    
> > > >
> > > > Among all the users of the kfifo buffers, no one uses the
> > > > INDIO_BUFFER_HARDWARE mode. So let's take this as a general rule and
> > > > simplify a little bit the internals - overall the documentation - by
> > > > eliminating unused specific cases. Use the INDIO_BUFFER_SOFTWARE mode by
> > > > default with kfifo buffers, which will basically mimic what all the "non
> > > > direct" modes do.
> > > >      
> > > 
> > > I think this patch here (and 10/10) can be part of a separate series.
> > > This discussion is important enough to have it's own series.
> > > It's a bit of an API discussion.
> > >    
> > One question inline.
> >    
> > > > Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
> > > > ---
> > > >  drivers/iio/accel/fxls8962af-core.c                  |  1 -
> > > >  drivers/iio/accel/sca3000.c                          |  1 -
> > > >  drivers/iio/accel/ssp_accel_sensor.c                 |  1 -
> > > >  drivers/iio/adc/ina2xx-adc.c                         |  1 -
> > > >  drivers/iio/adc/ti_am335x_adc.c                      |  4 +---
> > > >  drivers/iio/buffer/kfifo_buf.c                       | 12 ++----------
> > > >  .../common/cros_ec_sensors/cros_ec_sensors_core.c    |  3 +--
> > > >  drivers/iio/common/scmi_sensors/scmi_iio.c           |  1 -
> > > >  drivers/iio/gyro/ssp_gyro_sensor.c                   |  1 -
> > > >  drivers/iio/health/max30100.c                        |  1 -
> > > >  drivers/iio/health/max30102.c                        |  1 -
> > > >  drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c    |  1 -
> > > >  drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c     |  1 -
> > > >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c       |  1 -
> > > >  drivers/iio/light/apds9960.c                         |  1 -
> > > >  drivers/staging/iio/impedance-analyzer/ad5933.c      |  1 -
> > > >  include/linux/iio/kfifo_buf.h                        |  5 ++---
> > > >  17 files changed, 6 insertions(+), 31 deletions(-)  
> 
> [...]
> 
> > > > --- a/drivers/iio/adc/ti_am335x_adc.c
> > > > +++ b/drivers/iio/adc/ti_am335x_adc.c
> > > > @@ -376,9 +376,7 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
> > > >  {
> > > >         int ret;
> > > >
> > > > -       ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
> > > > -                                         INDIO_BUFFER_SOFTWARE,
> > > > -                                         setup_ops);
> > > > +       ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops);
> > > >         if (ret)
> > > >                 return ret;
> > > >
> > > > diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
> > > > index 416d35a61ae2..f17473e06ee8 100644
> > > > --- a/drivers/iio/buffer/kfifo_buf.c
> > > > +++ b/drivers/iio/buffer/kfifo_buf.c
> > > > @@ -197,7 +197,7 @@ static const struct iio_buffer_access_funcs kfifo_access_funcs = {
> > > >         .set_length = &iio_set_length_kfifo,
> > > >         .release = &iio_kfifo_buffer_release,
> > > >
> > > > -       .modes = INDIO_BUFFER_SOFTWARE | INDIO_BUFFER_TRIGGERED,
> > > > +       .modes = INDIO_BUFFER_SOFTWARE,    
> > 
> > Why is this safe to do?  Don't we need triggered buffers to match mode
> > when used with a kfifo?
> > 
> > If I'm remembering / reading how the mode matching works, this breaks the
> > industrialio-triggered-buffer.c case where it sets the mode to
> > INDIO_BUFFER_TRIGGERED (mostly I think to make sure we get a warning in
> > iio_verify_update() if no trigger is supplied - I can't remember what other
> > difference it makes (or if it does).  
> 
> Mmmh that's right, I overlooked that part. Indeed we still need to
> support the INDIO_BUFFER_TRIGGERED mode in the kfifo_access_funcs
> modes.
> 
> Do you think the rest of the patch is still legit? I believe it stills
> simplifies the logic for the user but if you disagree I'll drop it off
> entirely.
> 
yup. The rest was fine from what I recall.

J
> Thanks,
> Miquèl





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux