Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp437327ybs; Sun, 24 May 2020 09:53:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYU7oNGDokO4avBj/g8rN4rJ0o3MsHU9iMKzh2XF+Bq60DyylG0a8hqRMiclNtNQwtrEOL X-Received: by 2002:a50:c314:: with SMTP id a20mr11171373edb.352.1590339224848; Sun, 24 May 2020 09:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590339224; cv=none; d=google.com; s=arc-20160816; b=VaaH7sawoTXI13PvVzIgzHZ8nneg60dLQ/q9iCW/LaackrnhAPB/jQmk2hlWRHwrPV gE1j+9IU9zSwsDkrRrOuTc6/XpEF/QsORmoalrGwzesJewjI3DOeq5nEGUbe74HrHJjq fmWLQMeomt69lz/nUlnzYu7ImISUTSwOEWfo2OT31NinhYvZh9DoJVcfL6rE1B5qtTcs mlPKsubYS1QExeWYrywpNvsFuIKcn3s2icdw8nPm3Ok7lKPRjB/fXkvJU6hFjNa0VSau 1cwf1M0GyBqq2h1czEk/IjlP/M3i933sGOcE9UfTpvp438uVFDrl5iz2doLzK5jSk1Vl W4sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9YHD8LZvMrbo9hAkaH3xklTk/1J1wZ+xCzLvVOp3LPU=; b=0ArgAnYpuFd7eMRZuhirFDjYY5YmXISMBEYG1yli5f5qk0hRmQ84BVRu6SVn++C829 FuyzbX+J46qWyLWczqaN7ouSH5bWrTPS1DObULKBkMgSZdF49vbQeRjw7MbJGLCeieD5 yW6pPNtm9UmRJ3TU4KSYaLT4BLX3unrtmCw46U1h1Ff3noUzoPoRxiEVM3YAjiJ28hIQ Xq7yuQT0QW5bd/7CLcp8vF5fgsOPBpvBOnmRyPZ9/b+uczJf0N8zb+NAfxETpY9N73Ny 5CRD92O35FtkK2ZB75+XPRiuZv7ER7on1fWMn20FjbhMIPQEexj8etNhAQZ8ilCqXf3v whSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G5VLLK49; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si2710984edg.522.2020.05.24.09.53.21; Sun, 24 May 2020 09:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G5VLLK49; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729362AbgEXQtV (ORCPT + 99 others); Sun, 24 May 2020 12:49:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbgEXQtV (ORCPT ); Sun, 24 May 2020 12:49:21 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBDE92065F; Sun, 24 May 2020 16:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590338960; bh=PDkjexY8AfjLouSaQQn51C7oydZJEO+f1bQf/PF6xFs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=G5VLLK49bfpHQoTu1wjYSdr5vw6FNF7eMh2+Yig08zXtQ9AYCZ2NkiuNXoO8MNEhJ JyQGQAYjlW4AqoQGtaYckUzwT6WGixxjInl2BB7CxU+OBNpi77hv1CJxHOWIbzIvKX isvfCpArXEaj6RHBs4wCbskTpwPcc/wFGtzxcjak= Date: Sun, 24 May 2020 17:49:16 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: , , Subject: Re: [RFC PATCH 09/14] iio: buffer: split buffer sysfs creation to take buffer as primary arg Message-ID: <20200524174916.2ff91965@archlinux> In-Reply-To: <20200508135348.15229-10-alexandru.ardelean@analog.com> References: <20200508135348.15229-1-alexandru.ardelean@analog.com> <20200508135348.15229-10-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 May 2020 16:53:43 +0300 Alexandru Ardelean 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 Looks good to me. We'll need this whatever the interface ends up being as need the separate control infrastructure. 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,