All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	platform-driver-x86@vger.kernel.org,
	"Gregor Riepl" <onitake@gmail.com>
Subject: Re: [PATCH] platform/x86: touchscreen_dmi: Add support for setting touchscreen properties from cmdline
Date: Thu, 23 May 2024 10:47:16 +0200	[thread overview]
Message-ID: <376bd875-e4ab-403d-9265-e6833ccb31d9@redhat.com> (raw)
In-Reply-To: <CAHp75Vex78gE+e8kaUvvNjVUtkv-3GGgcMFZ3tFFqK49WRQDrA@mail.gmail.com>

Hi Andy,

On 5/22/24 9:32 PM, Andy Shevchenko wrote:
> On Wed, May 22, 2024 at 9:40 PM Hans de Goede <hdegoede@redhat.com> wrote:
>> On 5/22/24 7:19 PM, Andy Shevchenko wrote:
>>> On Wed, May 22, 2024 at 06:48:07PM +0200, Hans de Goede wrote:
> 
> ...
> 
>>>> +    /*
>>>> +     * str is part of the static_command_line from init/main.c and poking
>>>> +     * holes in that by writing 0 to it is allowed, as is taking long
>>>> +     * lasting references to it.
>>>> +     */
>>>> +    ts_cmdline_data.acpi_name = strsep(&str, ",");
>>>> +
>>>> +    for (i = 0; i < MAX_CMDLINE_PROPS; i++) {
>>>> +            name = strsep(&str, ",");
>>>> +            if (!name)
>>>> +                    break;
>>>> +
>>>> +            /* Replace '=' with 0 and make value point past '=' or NULL */
>>>> +            value = name;
>>>> +            strsep(&value, "=");
>>>> +            if (!value) {
>>>> +                    ts_cmdline_props[i] = PROPERTY_ENTRY_BOOL(name);
>>>> +            } else if (isdigit(value[0])) {
>>>> +                    ret = kstrtou32(value, 10, &u32val);
>>>> +                    if (ret)
>>>> +                            return ret;
>>>> +
>>>> +                    ts_cmdline_props[i] = PROPERTY_ENTRY_U32(name, u32val);
>>>> +            } else {
>>>> +                    ts_cmdline_props[i] = PROPERTY_ENTRY_STRING(name, value);
>>>> +            }
>>>> +    }
>>>
>>> This reminds me a lot from the next_arg(), can we not reinvent a wheel?
>>
>> next_arg is meant for parsing different arguments on the kernel cmdline
>> split by spaces. It has space as separator hardcoded so it cannot be
>> used here.
> 
> I believe it's not the first time I hear such an excuse for
> duplicating Yet Another (Same) Parser.
> If you think you really need another separator, we may patch
> next_arg() or add next_arg_any(is_separator_fn *fn) and make
> next_arg() to be a wrapper of the other one.

The kernel already has a generic parser for most things in the form of
include/linux/parser.h but that will not work here since that assumes
a list of fixed keywords while in this case I want to allow any keyword
and change it into a device-property with that name.

Also the actual splitting into key=value code here is maybe 5 lines,
the whole patch itself is not that big and most of the parsing is
figuring out if value represents a bool, uint or string.

And the kind of refactoring of next_arg() you are asking for here
is way out of scope, so sorry but I don't plan to change this part
of the patch.

Regards,

Hans



  parent reply	other threads:[~2024-05-23  8:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 16:48 [PATCH] platform/x86: touchscreen_dmi: Add support for setting touchscreen properties from cmdline Hans de Goede
2024-05-22 17:19 ` Andy Shevchenko
2024-05-22 17:20   ` Andy Shevchenko
2024-05-22 18:40   ` Hans de Goede
2024-05-22 19:32     ` Andy Shevchenko
2024-05-22 19:34       ` Andy Shevchenko
2024-05-23  8:47       ` Hans de Goede [this message]
2024-05-25 14:07         ` Andy Shevchenko
2024-05-25 17:41           ` Gregor Riepl
2024-05-27 13:44             ` Andy Shevchenko
2024-05-22 19:01 ` Randy Dunlap
2024-05-23  9:48   ` Hans de Goede

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=376bd875-e4ab-403d-9265-e6833ccb31d9@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=onitake@gmail.com \
    --cc=platform-driver-x86@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 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.