linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio <linux-iio@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] iio: core: Forbid use of both labels and extended names
Date: Thu, 17 Jun 2021 10:07:23 +0300	[thread overview]
Message-ID: <CA+U=Dsqcf5EERsFHh5LFHwe5U9MhpPxQNLBVUjM9boTMnp+rQQ@mail.gmail.com> (raw)
In-Reply-To: <20210616155706.17444-2-paul@crapouillou.net>

On Wed, Jun 16, 2021 at 7:01 PM Paul Cercueil <paul@crapouillou.net> wrote:
>
> Extended names are a problem for user-space as they make the filenames
> in sysfs sometimes not parsable. They are now deprecated in favor of
> labels.
>
> This change makes sure that a device driver won't provide both labels
> and extended names for its channels. It has never been the case and we
> don't want it to happen.
>

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/industrialio-core.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 59efb36db2c7..81f40dab778a 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1836,6 +1836,24 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
>         return 0;
>  }
>
> +static int iio_check_extended_name(const struct iio_dev *indio_dev)
> +{
> +       unsigned int i;
> +
> +       if (!indio_dev->info->read_label)
> +               return 0;
> +
> +       for (i = 0; i < indio_dev->num_channels; i++) {
> +               if (indio_dev->channels[i].extend_name) {
> +                       dev_err(&indio_dev->dev,
> +                               "Cannot use labels and extend_name at the same time\n");
> +                       return -EINVAL;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
>  static const struct iio_buffer_setup_ops noop_ring_setup_ops;
>
>  int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
> @@ -1860,6 +1878,10 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
>         if (ret < 0)
>                 return ret;
>
> +       ret = iio_check_extended_name(indio_dev);
> +       if (ret < 0)
> +               return ret;
> +
>         iio_device_register_debugfs(indio_dev);
>
>         ret = iio_buffers_alloc_sysfs_and_mask(indio_dev);
> --
> 2.30.2
>

  reply	other threads:[~2021-06-17  7:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 15:57 [PATCH v2 0/2] Add "extended_name" to label Paul Cercueil
2021-06-16 15:57 ` [PATCH v2 1/2] iio: core: Forbid use of both labels and extended names Paul Cercueil
2021-06-17  7:07   ` Alexandru Ardelean [this message]
2021-06-16 15:57 ` [PATCH v2 2/2] iio: core: Support reading extended name as label Paul Cercueil
2021-06-17  7:22   ` Alexandru Ardelean
2021-06-17  9:08     ` Paul Cercueil

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='CA+U=Dsqcf5EERsFHh5LFHwe5U9MhpPxQNLBVUjM9boTMnp+rQQ@mail.gmail.com' \
    --to=ardeleanalex@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --subject='Re: [PATCH v2 1/2] iio: core: Forbid use of both labels and extended names' \
    /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

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).