linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-scsi@vger.kernel.org, gregkh@linuxfoundation.org,
	jic23@kernel.org, lars@metafoo.de
Subject: Re: [PATCH 3/3][V3] iio: Handle enumerated properties with gaps
Date: Wed, 8 May 2019 16:17:49 +0300	[thread overview]
Message-ID: <20190508131749.GM9224@smile.fi.intel.com> (raw)
In-Reply-To: <20190508111913.7276-3-alexandru.ardelean@analog.com>

On Wed, May 08, 2019 at 02:19:13PM +0300, Alexandru Ardelean wrote:
> From: Lars-Peter Clausen <lars@metafoo.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



  reply	other threads:[~2019-05-08 13:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 11:19 [PATCH 1/3][V3] lib: fix __sysfs_match_string() helper when n != -1 Alexandru Ardelean
2019-05-08 11:19 ` [PATCH 2/3][V3] scsi: sd: remove sysfs_match_string() dense array comment Alexandru Ardelean
2019-05-08 11:19 ` [PATCH 3/3][V3] iio: Handle enumerated properties with gaps Alexandru Ardelean
2019-05-08 13:17   ` Andy Shevchenko [this message]
2019-05-09  7:31     ` Ardelean, Alexandru
2019-07-05 13:35       ` Ardelean, Alexandru
2019-05-28  7:18 ` [PATCH 1/3][V3] lib: fix __sysfs_match_string() helper when n != -1 Ardelean, Alexandru
2019-06-25 13:01 ` [PATCH][V4] " Alexandru Ardelean
2019-06-25 13:28   ` Andy Shevchenko
2019-06-25 19:42     ` Andrew Morton
2019-06-26  7:57       ` Ardelean, Alexandru
2019-07-14 10:12 ` [PATCH 1/3][V3] " 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=20190508131749.GM9224@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).