From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C8EDC43334 for ; Fri, 8 Jul 2022 11:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238069AbiGHLrg (ORCPT ); Fri, 8 Jul 2022 07:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238062AbiGHLrf (ORCPT ); Fri, 8 Jul 2022 07:47:35 -0400 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B568E951D3 for ; Fri, 8 Jul 2022 04:47:33 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id f73so6561279yba.10 for ; Fri, 08 Jul 2022 04:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8LXcNpiL0hugCcH3yPL4TbK7rxIaV5AKYrpbt4Nl4sQ=; b=V7bktCTJf9G6gqkLOYPmGR9Uh2eHfOZUgCs4tdTkpPxghs3aZzaZxMM5EaO05LZVbh jJ9/vn/oMbawWLJPrFb3h1v6mvjeR3EPg4pbWOxBS/oZu+V8DBiypl9w8fiVghF1g3EW gTuGwQ3o3t0Bm/oHPxSSzK3yF9j0aZkhZgzhn26e+VzfIS3NFaDWhGJfvMldbBYgEaB5 H5xuFgRAyUp4aCFvmyndkXi9dWuu3Xpj6uqWT4Bwt6s+T/NctA4wDoN+kcMZw+Km54kx pCpkHMe7iZkGA8z+UjYeSaKH12QoLc+gH8YPPN3x0sSZH6+baAz5GQVIriMYTDENsw2D IsCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8LXcNpiL0hugCcH3yPL4TbK7rxIaV5AKYrpbt4Nl4sQ=; b=ILAvnLshL1oVyc3oWA7jDM9BETONhA6/rWQdYHZHE2UVjyb+tmqkT3+KldTsuoUnhf hMPIUBpJANQOvZ0b755mTOGFEbyJ6fcXYhLYjKr3Fw42SOI1CLsuxaC/lphUwLuYZTBQ ZP7nHMWgu0bOOIj8sIUezEKlbIZZlncmfTFoZ9tjCQHZ2uHf42loI7OZTHeYr3/2t/RV 1y/beZLwZI0+/xlRS90Ua8uEEWhq19+g8RCUcI3rlkFxIyCpmRsB3ZT9f59EnfhDgSQU CG+oJnc5PCX4MFvLYIaObj27z85JtPiqEe/1Lb/+MlIqgxRBWR3cPGrvUbdn0Z8Hi/QE fySQ== X-Gm-Message-State: AJIora+RyHp241zJ3lXg18LKMHH45QnNrgkEyD8Ui1utaD15cFkLMvis 5OvS+9235Ug+qQRg95moH9X6BkyVCC7L4HEQmu8= X-Google-Smtp-Source: AGRyM1tdP4x7JQy/x8EF4GTgKqBJp8bVVhJs9zL0bB2Xb32Aq50XDeqCZxjHY+getXx/QdxDCe7PG4rZ4CDZs0+VldA= X-Received: by 2002:a05:6902:154c:b0:66e:8254:146e with SMTP id r12-20020a056902154c00b0066e8254146emr3318465ybu.570.1657280852776; Fri, 08 Jul 2022 04:47:32 -0700 (PDT) MIME-Version: 1.0 References: <20220707091301.1282291-1-cezary.rojewski@intel.com> In-Reply-To: From: Andy Shevchenko Date: Fri, 8 Jul 2022 13:46:56 +0200 Message-ID: Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() To: Cezary Rojewski Cc: Andy Shevchenko , Mark Brown , ALSA Development Mailing List , Takashi Iwai , Jaroslav Kysela , amadeuszx.slawinski@linux.intel.com, Pierre-Louis Bossart , Hans de Goede , =?UTF-8?Q?P=C3=A9ter_Ujfalusi?= , Ranjani Sridharan , Linux Kernel Mailing List , Liam Girdwood , Kai Vehmanen , Bard Liao Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 8, 2022 at 1:33 PM Cezary Rojewski wrote: > On 2022-07-08 12:22 PM, Andy Shevchenko wrote: > > On Thu, Jul 7, 2022 at 11:03 AM Cezary Rojewski > > wrote: > >> > >> Add strsplit_u32() and its __user variant to allow for splitting > >> specified string into array of u32 tokens. > > > > And I believe we have more of this done in old code. > > Since all callers use ',' as a delimiter, have you considered using > > get_options()? > > > Thanks for your input, Andy. > > 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. > 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, +, -. > 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()? > >> Originally this functionality was added for the SOF sound driver. As > >> more users are on the horizon, relocate it so it becomes a common good. > > > > Maybe it can be fixed just there. > > 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. -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FF8CC433EF for ; Fri, 8 Jul 2022 11:48:35 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 43F7A161D; Fri, 8 Jul 2022 13:47:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 43F7A161D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1657280913; bh=n3+Z5krWR99OlKbSR+5aQodSgHT9dp4WKx4WJCrDO3I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iZarsu986sLVElFtK/AnS0pk96wREXYEEdXW7EWMTVxl1Gpvoyq1xRomUXUIuT2u6 ovuabC1azulbeSbbwSJbg9inZtjPe0o47I90eohIzmjoZwoJmAoUgnjIno2lvHpj5t vGXLwvucYxprXuG88WPWHSVbqjo10iWysa9hpnAU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D272CF80166; Fri, 8 Jul 2022 13:47:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA34CF800C5; Fri, 8 Jul 2022 13:47:40 +0200 (CEST) Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B3498F800C5 for ; Fri, 8 Jul 2022 13:47:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B3498F800C5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V7bktCTJ" Received: by mail-yb1-xb35.google.com with SMTP id y195so6147715yby.0 for ; Fri, 08 Jul 2022 04:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8LXcNpiL0hugCcH3yPL4TbK7rxIaV5AKYrpbt4Nl4sQ=; b=V7bktCTJf9G6gqkLOYPmGR9Uh2eHfOZUgCs4tdTkpPxghs3aZzaZxMM5EaO05LZVbh jJ9/vn/oMbawWLJPrFb3h1v6mvjeR3EPg4pbWOxBS/oZu+V8DBiypl9w8fiVghF1g3EW gTuGwQ3o3t0Bm/oHPxSSzK3yF9j0aZkhZgzhn26e+VzfIS3NFaDWhGJfvMldbBYgEaB5 H5xuFgRAyUp4aCFvmyndkXi9dWuu3Xpj6uqWT4Bwt6s+T/NctA4wDoN+kcMZw+Km54kx pCpkHMe7iZkGA8z+UjYeSaKH12QoLc+gH8YPPN3x0sSZH6+baAz5GQVIriMYTDENsw2D IsCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8LXcNpiL0hugCcH3yPL4TbK7rxIaV5AKYrpbt4Nl4sQ=; b=blte22qSjs7fVKcuMM82DGtQxTzZ1tg/qmJ0q/PG7Oowsk4ICHDMPqHybvaKupq9XM S6WA+TAJBkepZ2OtK7kjW3D6ADCKDS78CkiwoisZ9VoNrbj3h1AuHvZ5M0XeMXI2mSBJ /4pRXMSLQWATdVIUHCY0um7AS3eoNbre6AAXvKaYsRkqnOPJyIll0UWhtOhhpc/dRKTy tIxFsXRZwZH5JSOlYnzURsTK0hHyAQ4cfU5vVKyU5dsHDCRnAibKKlCFZLpOIDYbL3qw K9yF00eaqxBFMhdXtFBbe+TtUEAQXF9gsJ48MkwEDyXxsScp77wIQamO5b16o394W5ZJ FYHA== X-Gm-Message-State: AJIora+dZkeio+IGjY/aRdgxFvDosVFMNQ7XLYOwkaYsXATHWSICPcCn KtYukphA1gE+SeBxNGXdoNRuMG0QV7ORaf5nJfY= X-Google-Smtp-Source: AGRyM1tdP4x7JQy/x8EF4GTgKqBJp8bVVhJs9zL0bB2Xb32Aq50XDeqCZxjHY+getXx/QdxDCe7PG4rZ4CDZs0+VldA= X-Received: by 2002:a05:6902:154c:b0:66e:8254:146e with SMTP id r12-20020a056902154c00b0066e8254146emr3318465ybu.570.1657280852776; Fri, 08 Jul 2022 04:47:32 -0700 (PDT) MIME-Version: 1.0 References: <20220707091301.1282291-1-cezary.rojewski@intel.com> In-Reply-To: From: Andy Shevchenko Date: Fri, 8 Jul 2022 13:46:56 +0200 Message-ID: Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() To: Cezary Rojewski Content-Type: text/plain; charset="UTF-8" Cc: Andy Shevchenko , Pierre-Louis Bossart , ALSA Development Mailing List , Kai Vehmanen , Liam Girdwood , Linux Kernel Mailing List , Takashi Iwai , Hans de Goede , Mark Brown , Bard Liao , Ranjani Sridharan , amadeuszx.slawinski@linux.intel.com, =?UTF-8?Q?P=C3=A9ter_Ujfalusi?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Fri, Jul 8, 2022 at 1:33 PM Cezary Rojewski wrote: > On 2022-07-08 12:22 PM, Andy Shevchenko wrote: > > On Thu, Jul 7, 2022 at 11:03 AM Cezary Rojewski > > wrote: > >> > >> Add strsplit_u32() and its __user variant to allow for splitting > >> specified string into array of u32 tokens. > > > > And I believe we have more of this done in old code. > > Since all callers use ',' as a delimiter, have you considered using > > get_options()? > > > Thanks for your input, Andy. > > 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. > 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, +, -. > 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()? > >> Originally this functionality was added for the SOF sound driver. As > >> more users are on the horizon, relocate it so it becomes a common good. > > > > Maybe it can be fixed just there. > > 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. -- With Best Regards, Andy Shevchenko