From: Marek Vasut <marex@denx.de>
To: Janne Grunau <j@jannau.net>
Cc: Bin Meng <bmeng.cn@gmail.com>, Tom Rini <trini@konsulko.com>,
Simon Glass <sjg@chromium.org>,
Joe Hershberger <joe.hershberger@ni.com>,
u-boot@lists.denx.de, asahi@lists.linux.dev
Subject: Re: [PATCH v2 4/6] usb: Add environment based device blocklist
Date: Fri, 22 Mar 2024 00:47:38 +0100 [thread overview]
Message-ID: <b76c69fd-7d10-41b8-9bf1-7620ac44aeb2@denx.de> (raw)
In-Reply-To: <ZfoA9VDRwaZYzd0i@robin>
On 3/19/24 10:17 PM, Janne Grunau wrote:
Hi,
sorry for the abysmal delay in response.
> On Mon, Mar 18, 2024 at 03:17:33PM +0100, Marek Vasut wrote:
>> On 3/18/24 8:33 AM, Janne Grunau wrote:
>>
>>>>>>> +static int usb_blocklist_parse_error(const char *blocklist, size_t pos)
>>>>>>> +{
>>>>>>> + printf("usb_blocklist parse error at char %zu in \"%s\"\n", pos,
>>>>>>> + blocklist);
>>>>>>> + return 0;
>>>>>>
>>>>>> This could be static void without return 0 at the end.
>>>>>
>>>>> the return is there to break out of the while loop on parsing errors in a single statement. This probably won't be necessary after using strsep and sscanf in the parsing function but see below.
>>>>
>>>> Ahh, now I see it. But then, shouldn't this return -ENODEV here already ?
>>>
>>> It returns 0 so that parsing errors in the blocklist do not result
>>> in blocking every USB device. That looked to me like the
>>> less bad error behavior to me.
>>
>> In unix , 0 is considered success and non-zero failure .
>>
>> How about this:
>>
>> - Return -EINVAL here (parsing failed)
>
> If we return 0 / negated errors we do not need this function and we can
> simply report the parsing error when usb_device_is_blocked() return
> -EINVAL.
>
>> - Instead of 'return 1' in usb_device_is_blocked() return -ENODEV
>> - In usb_select_config(), check
>> if usb_device_is_blocked returned 0, no device blocked OK
>> if usb_device_is_blocked returned -ENODEV, device blocked,
>> return -ENODEV
>> if usb_device_is_blocked returned any other error, parsing error
>> return that error
>
> I think the preferable option is to ignore parsing errors. If we
> would propagate the error the result would be that every USB device is
> ignored.
Good point.
>> What do you think ?
>
> Fine by me, -EINVAL makes the parsing error reporting less awkward. Only
> open question is what should happen on parsing errors.
I agree, ignore/skip the parsing errors and report to user that
something couldn't be parsed, that works.
> locally modified and ready to resend once we agree on the behavior on
> parsing errors
Thanks, I think we are in agreement.
next prev parent reply other threads:[~2024-03-21 23:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-17 11:07 [PATCH v2 0/6] USB keyboard improvements for asahi / desktop systems Janne Grunau via B4 Relay
2024-03-17 11:07 ` [PATCH v2 1/6] usb: xhci: refactor xhci_set_configuration Janne Grunau via B4 Relay
2024-03-17 11:07 ` [PATCH v2 2/6] usb: xhci: Set up endpoints for the first 2 interfaces Janne Grunau via B4 Relay
2024-03-17 11:07 ` [PATCH v2 3/6] usb: xhci: Abort transfers with unallocated rings Janne Grunau via B4 Relay
2024-03-17 16:06 ` Marek Vasut
2024-03-17 11:07 ` [PATCH v2 4/6] usb: Add environment based device blocklist Janne Grunau via B4 Relay
2024-03-17 11:34 ` Janne Grunau
2024-03-17 16:07 ` Marek Vasut
2024-03-17 16:18 ` Marek Vasut
2024-03-17 18:15 ` Janne Grunau
2024-03-18 5:06 ` Marek Vasut
2024-03-18 7:33 ` Janne Grunau
2024-03-18 14:17 ` Marek Vasut
2024-03-19 21:17 ` Janne Grunau
2024-03-21 23:47 ` Marek Vasut [this message]
2024-03-17 11:07 ` [PATCH v2 5/6] usb: kbd: support Apple Magic Keyboards (2021) Janne Grunau via B4 Relay
2024-03-17 16:20 ` Marek Vasut
2024-03-17 11:07 ` [PATCH v2 6/6] usb: kbd: Add probe quirk for Apple and Keychron keyboards Janne Grunau via B4 Relay
2024-03-17 16:21 ` Marek Vasut
2024-03-17 11:26 ` [PATCH v2 0/6] USB keyboard improvements for asahi / desktop systems Neal Gompa
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=b76c69fd-7d10-41b8-9bf1-7620ac44aeb2@denx.de \
--to=marex@denx.de \
--cc=asahi@lists.linux.dev \
--cc=bmeng.cn@gmail.com \
--cc=j@jannau.net \
--cc=joe.hershberger@ni.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).