From: Jonathan Cameron <jic23@kernel.org>
To: Octavian Purdila <octavian.purdila@intel.com>, linux-iio@vger.kernel.org
Cc: srinivas.pandruvada@linux.intel.com
Subject: Re: [PATCH v3 1/9] iio: buffer: refactor buffer attributes setup
Date: Wed, 04 Feb 2015 18:47:36 +0000 [thread overview]
Message-ID: <54D26948.30901@kernel.org> (raw)
In-Reply-To: <1422662408-8149-2-git-send-email-octavian.purdila@intel.com>
On 31/01/15 00:00, Octavian Purdila wrote:
> Move all core (non-custom) buffer attributes to a vector to make it
> easier to add more of them in the future.
>
> Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Applied to the togreg branch of iio.git - will get pushed out as
testing sometime around Sunday/Monday (back home).
> ---
> drivers/iio/industrialio-buffer.c | 31 +++++++++++++++++++------------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 7133314..c2d5440 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -761,6 +761,11 @@ static struct device_attribute dev_attr_length_ro = __ATTR(length,
> static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
> iio_buffer_show_enable, iio_buffer_store_enable);
>
> +static struct attribute *iio_buffer_attrs[] = {
> + &dev_attr_length.attr,
> + &dev_attr_enable.attr,
> +};
> +
> int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
> {
> struct iio_dev_attr *p;
> @@ -778,21 +783,23 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
> attrcount++;
> }
>
> - buffer->buffer_group.name = "buffer";
> - buffer->buffer_group.attrs = kcalloc(attrcount + 3,
> - sizeof(*buffer->buffer_group.attrs), GFP_KERNEL);
> - if (!buffer->buffer_group.attrs)
> + attr = kcalloc(attrcount + ARRAY_SIZE(iio_buffer_attrs) + 1,
> + sizeof(struct attribute *), GFP_KERNEL);
> + if (!attr)
> return -ENOMEM;
>
> - if (buffer->access->set_length)
> - buffer->buffer_group.attrs[0] = &dev_attr_length.attr;
> - else
> - buffer->buffer_group.attrs[0] = &dev_attr_length_ro.attr;
> - buffer->buffer_group.attrs[1] = &dev_attr_enable.attr;
> + memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
> + if (!buffer->access->set_length)
> + attr[0] = &dev_attr_length_ro.attr;
> +
> if (buffer->attrs)
> - memcpy(&buffer->buffer_group.attrs[2], buffer->attrs,
> - sizeof(*&buffer->buffer_group.attrs) * attrcount);
> - buffer->buffer_group.attrs[attrcount+2] = NULL;
> + memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
> + sizeof(struct attribute *) * attrcount);
> +
> + attr[attrcount + ARRAY_SIZE(iio_buffer_attrs)] = NULL;
> +
> + buffer->buffer_group.name = "buffer";
> + buffer->buffer_group.attrs = attr;
>
> indio_dev->groups[indio_dev->groupcounter++] = &buffer->buffer_group;
>
>
next prev parent reply other threads:[~2015-02-04 18:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 23:59 [PATCH v3 0/9] iio: add support for hardware fifo Octavian Purdila
2015-01-31 0:00 ` [PATCH v3 1/9] iio: buffer: refactor buffer attributes setup Octavian Purdila
2015-02-04 18:47 ` Jonathan Cameron [this message]
2015-01-31 0:00 ` [PATCH v3 2/9] iio: add watermark logic to iio read and poll Octavian Purdila
2015-02-04 18:49 ` Jonathan Cameron
2015-02-04 19:29 ` Octavian Purdila
2015-01-31 0:00 ` [PATCH v3 3/9] iio: add support for hardware fifo Octavian Purdila
2015-02-08 10:33 ` Jonathan Cameron
2015-01-31 0:00 ` [PATCH v3 4/9] iio: bmc150: refactor slope duration and threshold update Octavian Purdila
2015-02-05 17:02 ` Srinivas Pandruvada
2015-02-08 10:37 ` Jonathan Cameron
2015-02-09 9:54 ` Octavian Purdila
2015-01-31 0:00 ` [PATCH v3 5/9] iio: bmc150: refactor interrupt enabling Octavian Purdila
2015-02-05 17:06 ` Srinivas Pandruvada
2015-02-08 10:39 ` Jonathan Cameron
2015-01-31 0:00 ` [PATCH v3 6/9] iio: bmc150: exit early if event / trigger state is not changed Octavian Purdila
2015-02-05 17:09 ` Srinivas Pandruvada
2015-02-08 10:40 ` Jonathan Cameron
2015-01-31 0:00 ` [PATCH v3 7/9] iio: bmc150: introduce bmc150_accel_interrupt Octavian Purdila
2015-02-08 11:01 ` Jonathan Cameron
2015-01-31 0:00 ` [PATCH v3 8/9] iio: bmc150: introduce bmc150_accel_trigger Octavian Purdila
2015-02-08 11:07 ` Jonathan Cameron
2015-02-14 0:03 ` Srinivas Pandruvada
2015-01-31 0:00 ` [PATCH v3 9/9] iio: bmc150: add support for hardware fifo Octavian Purdila
2015-02-08 11:26 ` Jonathan Cameron
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=54D26948.30901@kernel.org \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox