[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190508131749.GM9224@smile.fi.intel.com>
Date: Wed, 8 May 2019 16:17:49 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc: linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
linux-scsi@...r.kernel.org, gregkh@...uxfoundation.org,
jic23@...nel.org, lars@...afoo.de
Subject: Re: [PATCH 3/3][V3] iio: Handle enumerated properties with gaps
On Wed, May 08, 2019 at 02:19:13PM +0300, Alexandru Ardelean wrote:
> From: Lars-Peter Clausen <lars@...afoo.de>
>
> Some enums might have gaps or reserved values in the middle of their value
> range. E.g. consider a 2-bit enum where the values 0, 1 and 3 have a
> meaning, but 2 is a reserved value and can not be used.
>
> Add support for such enums to the IIO enum helper functions. A reserved
> values is marked by setting its entry in the items array to NULL rather
> than the normal descriptive string value.
>
> Also, `__sysfs_match_string()` now supports NULL gaps, so that doesn't
> require any changes.
> - for (i = 0; i < e->num_items; ++i)
> + for (i = 0; i < e->num_items; ++i) {
> + if (!e->items[i])
> + continue;
> len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
> + }
The problem here that the user will have no clue where the gap is happened, to
solve this we need either bitmap of array, where set bits shows defined items,
or use comma-separated list of values. The latter would need another node since
we don't break user space.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists