lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200531162123.401d54f5@archlinux>
Date:   Sun, 31 May 2020 16:21:23 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     "Ardelean, Alexandru" <alexandru.Ardelean@...log.com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        "lars@...afoo.de" <lars@...afoo.de>
Subject: Re: [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@...log.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@...log.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@...log.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,  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ