mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH v1 1/2] iio: core: Replace iio_sysfs_match_string_with_gaps() by __sysfs_match_string()
Date: Wed, 18 Jan 2023 07:22:30 -0800	[thread overview]
Message-ID: <5f9b713b-9c71-7da6-e674-b6ebd28dc5d5@metafoo.de> (raw)
In-Reply-To: <20230118074828.66155-1-andriy.shevchenko@linux.intel.com>

On 1/17/23 23:48, Andy Shevchenko wrote:
> None of the current users is using gaps in the list of the items.
> No need to have a specific function for that, just replace it by
> library available __sysfs_match_string().

Hm, I specifically remember adding this for a driver where there were 
gaps. One of the DACs. But it might be that the driver itself never made 
it upstream.

>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/iio/industrialio-core.c | 32 +-------------------------------
>   1 file changed, 1 insertion(+), 31 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 52e690f031cb..26e357f14db8 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -205,36 +205,6 @@ bool iio_buffer_enabled(struct iio_dev *indio_dev)
>   }
>   EXPORT_SYMBOL_GPL(iio_buffer_enabled);
>   
> -/**
> - * iio_sysfs_match_string_with_gaps - matches given string in an array with gaps
> - * @array: array of strings
> - * @n: number of strings in the array
> - * @str: string to match with
> - *
> - * Returns index of @str in the @array or -EINVAL, similar to match_string().
> - * Uses sysfs_streq instead of strcmp for matching.
> - *
> - * This routine will look for a string in an array of strings.
> - * The search will continue until the element is found or the n-th element
> - * is reached, regardless of any NULL elements in the array.
> - */
> -static int iio_sysfs_match_string_with_gaps(const char * const *array, size_t n,
> -					    const char *str)
> -{
> -	const char *item;
> -	int index;
> -
> -	for (index = 0; index < n; index++) {
> -		item = array[index];
> -		if (!item)
> -			continue;
> -		if (sysfs_streq(item, str))
> -			return index;
> -	}
> -
> -	return -EINVAL;
> -}
> -
>   #if defined(CONFIG_DEBUG_FS)
>   /*
>    * There's also a CONFIG_DEBUG_FS guard in include/linux/iio/iio.h for
> @@ -569,7 +539,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
>   	if (!e->set)
>   		return -EINVAL;
>   
> -	ret = iio_sysfs_match_string_with_gaps(e->items, e->num_items, buf);
> +	ret = __sysfs_match_string(e->items, e->num_items, buf);
>   	if (ret < 0)
>   		return ret;
>   



  parent reply	other threads:[~2023-01-18 15:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18  7:48 Andy Shevchenko
2023-01-18  7:48 ` [PATCH v1 2/2] iio: core: Sort headers Andy Shevchenko
2023-01-18 15:22 ` Lars-Peter Clausen [this message]
2023-01-18 15:49   ` [PATCH v1 1/2] iio: core: Replace iio_sysfs_match_string_with_gaps() by __sysfs_match_string() Andy Shevchenko
2023-01-18 16:37     ` Lars-Peter Clausen
2023-01-19  8:00       ` Nuno Sá
2023-01-19 11:23         ` Andy Shevchenko
2023-01-19 13:24           ` Nuno Sá
2023-01-21 17:49             ` 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=5f9b713b-9c71-7da6-e674-b6ebd28dc5d5@metafoo.de \
    --to=lars@metafoo.de \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.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

all inboxes | Powered by JetHome®