All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"ALSA Development Mailing List" <alsa-devel@alsa-project.org>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	amadeuszx.slawinski@linux.intel.com,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32()
Date: Fri, 8 Jul 2022 14:13:14 +0200	[thread overview]
Message-ID: <6c8e4104-2239-a188-649d-585f059cabdd@intel.com> (raw)
In-Reply-To: <CAHp75VckU2ZraLJ-frjWXjUu9pFW+-XmWgTbYqUXOUNAD-1HGA@mail.gmail.com>

On 2022-07-08 1:46 PM, Andy Shevchenko wrote:
> On Fri, Jul 8, 2022 at 1:33 PM Cezary Rojewski
> <cezary.rojewski@intel.com> wrote:

...

>> When I'd written the very first version of this function many months
>> ago, get_options() looked as it does not fulfill our needs. It seems to
>> be true even today: caller needs to know the number of elements in an
>> array upfront.
> 
> Have you read a kernel doc for it? It does return the number of
> elements at the first pass.

Yes, I've checked several parts of it. Perhaps I did miss something but 
simple_strtoull() doc reads: use kstrtox() instead. Thus the 
strsplit_u32() makes use of kstrtox().

>> Also, kstrtox() takes into account '0x' and modifies the
>> base accordingly if that's the case. simple_strtoull() looks as not
>> capable of doing the same thing.
> 
> How come?! It does parse all known prefixes: 0x, 0, +, -.

Hmm.. doc says that it stops at the first non-digit character. Will 
re-check.

>> The goal is to be able to parse input such as:
>>
>> 0x1000003,0,0,0x1000004,0,0
>>
>> into a sequence of 6 uints, filling the *tkns and *num_tkns for the caller.
> 
> Yes. Have you checked the test cases for get_options()?
> 

...

>> avs-driver, which is also part of the ASoC framework has very similar
>> debug-interface. I believe there's no need to duplicate the functions -
>> move them to common code instead.
> 
> Taking the above into account, please try to use get_options() and
> then tell me what's not working with it. If so, we will add test cases
> to get_options() and fix it.

There is a difference:

	// get_options
	int ints[5];

	s = get_options(str, ARRAY_SIZE(ints), ints);

	// strsplit_u32()
	u32 *tkns, num_tkns;

	ret = strsplit_u32(str, delim, &tkns, &num_tkns);

Nothing has been told upfront for in the second case.

WARNING: multiple messages have this Message-ID (diff)
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Mark Brown" <broonie@kernel.org>,
	"ALSA Development Mailing List" <alsa-devel@alsa-project.org>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Jaroslav Kysela" <perex@perex.cz>,
	amadeuszx.slawinski@linux.intel.com,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>
Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32()
Date: Fri, 8 Jul 2022 14:13:14 +0200	[thread overview]
Message-ID: <6c8e4104-2239-a188-649d-585f059cabdd@intel.com> (raw)
In-Reply-To: <CAHp75VckU2ZraLJ-frjWXjUu9pFW+-XmWgTbYqUXOUNAD-1HGA@mail.gmail.com>

On 2022-07-08 1:46 PM, Andy Shevchenko wrote:
> On Fri, Jul 8, 2022 at 1:33 PM Cezary Rojewski
> <cezary.rojewski@intel.com> wrote:

...

>> When I'd written the very first version of this function many months
>> ago, get_options() looked as it does not fulfill our needs. It seems to
>> be true even today: caller needs to know the number of elements in an
>> array upfront.
> 
> Have you read a kernel doc for it? It does return the number of
> elements at the first pass.

Yes, I've checked several parts of it. Perhaps I did miss something but 
simple_strtoull() doc reads: use kstrtox() instead. Thus the 
strsplit_u32() makes use of kstrtox().

>> Also, kstrtox() takes into account '0x' and modifies the
>> base accordingly if that's the case. simple_strtoull() looks as not
>> capable of doing the same thing.
> 
> How come?! It does parse all known prefixes: 0x, 0, +, -.

Hmm.. doc says that it stops at the first non-digit character. Will 
re-check.

>> The goal is to be able to parse input such as:
>>
>> 0x1000003,0,0,0x1000004,0,0
>>
>> into a sequence of 6 uints, filling the *tkns and *num_tkns for the caller.
> 
> Yes. Have you checked the test cases for get_options()?
> 

...

>> avs-driver, which is also part of the ASoC framework has very similar
>> debug-interface. I believe there's no need to duplicate the functions -
>> move them to common code instead.
> 
> Taking the above into account, please try to use get_options() and
> then tell me what's not working with it. If so, we will add test cases
> to get_options() and fix it.

There is a difference:

	// get_options
	int ints[5];

	s = get_options(str, ARRAY_SIZE(ints), ints);

	// strsplit_u32()
	u32 *tkns, num_tkns;

	ret = strsplit_u32(str, delim, &tkns, &num_tkns);

Nothing has been told upfront for in the second case.

  parent reply	other threads:[~2022-07-08 12:14 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  9:13 [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() Cezary Rojewski
2022-07-07  9:13 ` Cezary Rojewski
2022-07-07  9:13 ` [PATCH 2/2] ASoC: SOF: Remove tokenize_input() Cezary Rojewski
2022-07-07  9:13   ` Cezary Rojewski
2022-07-07 13:51 ` [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() Péter Ujfalusi
2022-07-07 13:51   ` Péter Ujfalusi
2022-07-08 11:33   ` Cezary Rojewski
2022-07-08 11:33     ` Cezary Rojewski
2022-07-08 10:22 ` Andy Shevchenko
2022-07-08 10:22   ` Andy Shevchenko
2022-07-08 11:29   ` Andy Shevchenko
2022-07-08 11:29     ` Andy Shevchenko
2022-07-08 11:32   ` Cezary Rojewski
2022-07-08 11:32     ` Cezary Rojewski
2022-07-08 11:46     ` Andy Shevchenko
2022-07-08 11:46       ` Andy Shevchenko
2022-07-08 11:51       ` Andy Shevchenko
2022-07-08 11:51         ` Andy Shevchenko
2022-07-08 12:13       ` Cezary Rojewski [this message]
2022-07-08 12:13         ` Cezary Rojewski
2022-07-08 12:30         ` Andy Shevchenko
2022-07-08 12:30           ` Andy Shevchenko
2022-07-08 12:35           ` Péter Ujfalusi
2022-07-08 12:35             ` Péter Ujfalusi
2022-07-08 15:25             ` Andy Shevchenko
2022-07-08 15:25               ` Andy Shevchenko
2022-07-08 15:28               ` Andy Shevchenko
2022-07-08 15:28                 ` Andy Shevchenko
2022-07-08 16:32               ` Cezary Rojewski
2022-07-08 16:32                 ` Cezary Rojewski
2022-07-08 16:49                 ` Andy Shevchenko
2022-07-08 16:49                   ` Andy Shevchenko
2022-07-09  8:45                   ` Cezary Rojewski
2022-07-09  8:45                     ` Cezary Rojewski
2022-07-09 20:42                     ` Andy Shevchenko
2022-07-09 20:42                       ` Andy Shevchenko
2022-07-12 13:51                       ` Cezary Rojewski
2022-07-12 13:51                         ` Cezary Rojewski
2022-07-12 13:59                         ` Andy Shevchenko
2022-07-12 13:59                           ` Andy Shevchenko
2022-07-12 14:02                         ` Mark Brown
2022-07-12 14:02                           ` Mark Brown
2022-07-12 14:24                         ` Andy Shevchenko
2022-07-12 14:24                           ` Andy Shevchenko
2022-07-19 11:40                           ` Cezary Rojewski
2022-07-19 11:40                             ` Cezary Rojewski
2022-08-09  9:55                           ` Cezary Rojewski
2022-08-09  9:55                             ` Cezary Rojewski
2022-08-09 15:23                             ` Andy Shevchenko
2022-08-09 15:23                               ` Andy Shevchenko
2022-08-16  9:28                               ` Cezary Rojewski
2022-08-16  9:28                                 ` Cezary Rojewski
2022-08-25 15:09                                 ` Andy Shevchenko
2022-08-25 15:09                                   ` Andy Shevchenko
2022-08-25 16:44                                   ` Cezary Rojewski
2022-08-25 16:44                                     ` Cezary Rojewski
2022-07-13  9:14                 ` David Laight
2022-07-13  9:14                   ` David Laight
2022-07-13  9:38                   ` Andy Shevchenko
2022-07-13  9:38                     ` Andy Shevchenko

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=6c8e4104-2239-a188-649d-585f059cabdd@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.