lkml.org 
[lkml]   [2020]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC PATCH 09/14] iio: buffer: split buffer sysfs creation to take buffer as primary arg
On Mon, 25 May 2020 07:28:18 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Sun, 2020-05-24 at 17:49 +0100, Jonathan Cameron wrote:
> > [External]
> >
> > On Fri, 8 May 2020 16:53:43 +0300
> > Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> >
> > > Currently the iio_buffer_{alloc,free}_sysfs_and_mask() take 'indio_dev' as
> > > primary argument. This change converts to take an IIO buffer as a primary
> > > argument.
> > >
> > > That will allow the functions to get called for multiple buffers.
> > >
> > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> >
> > Looks good to me. We'll need this whatever the interface ends up being as
> > need the separate control infrastructure.
>
> I was wanting to split this into it's own patch at some point and send it now.
> I'll probably do it.

Great.
>
> >
> > Jonathan
> >
> > > ---
> > > drivers/iio/industrialio-buffer.c | 46 ++++++++++++++++++++-----------
> > > 1 file changed, 30 insertions(+), 16 deletions(-)
> > >
> > > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-
> > > buffer.c
> > > index e7a847e7b103..6b1b5d5387bd 100644
> > > --- a/drivers/iio/industrialio-buffer.c
> > > +++ b/drivers/iio/industrialio-buffer.c
> > > @@ -1312,26 +1312,14 @@ static struct attribute *iio_buffer_attrs[] = {
> > > &dev_attr_data_available.attr,
> > > };
> > >
> > > -int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
> > > +static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer)
> > > {
> > > + struct iio_dev *indio_dev = buffer->indio_dev;
> > > struct iio_dev_attr *p;
> > > struct attribute **attr;
> > > - struct iio_buffer *buffer = indio_dev->buffer;
> > > int ret, i, attrn, attrcount, attrcount_orig = 0;
> > > const struct iio_chan_spec *channels;
> > >
> > > - channels = indio_dev->channels;
> > > - if (channels) {
> > > - int ml = indio_dev->masklength;
> > > -
> > > - for (i = 0; i < indio_dev->num_channels; i++)
> > > - ml = max(ml, channels[i].scan_index + 1);
> > > - indio_dev->masklength = ml;
> > > - }
> > > -
> > > - if (!buffer)
> > > - return 0;
> > > -
> > > attrcount = 0;
> > > if (buffer->attrs) {
> > > while (buffer->attrs[attrcount] != NULL)
> > > @@ -1411,19 +1399,45 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev
> > > *indio_dev)
> > > return ret;
> > > }
> > >
> > > -void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev)
> > > +int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
> > > {
> > > struct iio_buffer *buffer = indio_dev->buffer;
> > > + const struct iio_chan_spec *channels;
> > > + int i;
> > > +
> > > + channels = indio_dev->channels;
> > > + if (channels) {
> > > + int ml = indio_dev->masklength;
> > > +
> > > + for (i = 0; i < indio_dev->num_channels; i++)
> > > + ml = max(ml, channels[i].scan_index + 1);
> > > + indio_dev->masklength = ml;
> > > + }
> > >
> > > if (!buffer)
> > > - return;
> > > + return 0;
> > > +
> > > + return __iio_buffer_alloc_sysfs_and_mask(buffer);
> > > +}
> > >
> > > +static void __iio_buffer_free_sysfs_and_mask(struct iio_buffer *buffer)
> > > +{
> > > iio_buffer_free_scanmask(buffer);
> > > kfree(buffer->buffer_group.attrs);
> > > kfree(buffer->scan_el_group.attrs);
> > > iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list);
> > > }
> > >
> > > +void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev)
> > > +{
> > > + struct iio_buffer *buffer = indio_dev->buffer;
> > > +
> > > + if (!buffer)
> > > + return;
> > > +
> > > + __iio_buffer_free_sysfs_and_mask(buffer);
> > > +}
> > > +
> > > static const struct file_operations iio_buffer_fileops = {
> > > .read = iio_buffer_read_outer,
> > > .release = iio_buffer_chrdev_release,

\
 
 \ /
  Last update: 2020-05-31 17:22    [W:0.255 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site