lkml.org 
[lkml]   [2021]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 05/11] iio: buffer: group attr count and attr alloc

> > >
> > > + attr = kcalloc(buffer_attrcount + ARRAY_SIZE(iio_buffer_attrs) + 1,
> > > + sizeof(struct attribute *), GFP_KERNEL);
> > > + if (!attr) {
> > > + ret = -ENOMEM;
> > > + goto error_free_scan_mask;
> > > + }
> > > +
> > > + memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
> > > + if (!buffer->access->set_length)
> > > + attr[0] = &dev_attr_length_ro.attr;
> > > +
> > > + if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK)
> > > + attr[2] = &dev_attr_watermark_ro.attr;
> >
> > Again a comment for the future rather than now, but when we are copying
> > 4 items and then looking at whether to change 2 of them it might be cleaner
> > to just set them directly! Touch of bit rot here :)
>
> So, I've been on-and-off about how to deal with this one.
> I wanted to clean it in various ways using new kernel sysfs APIs.
> Maybe, also remove the readonly variants and use the is_visible()
> property to set RO/RW modes.
> But I also came to the conclusion that this is an idea to address later.
> Trying to address this early-on confused me with other overlapping changes.
Absolutely agree. It's not something to do in this series.

Jonathan

\
 
 \ /
  Last update: 2021-02-05 13:42    [W:0.108 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site