* [PATCH] usb: kbd: allow probing even if usbkbd not in stdin
@ 2022-06-22 8:59 kory.maincent
2022-06-24 18:12 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: kory.maincent @ 2022-06-22 8:59 UTC (permalink / raw)
To: u-boot; +Cc: marex, thomas.petazzoni, Kory Maincent
From: Kory Maincent <kory.maincent@bootlin.com>
For now the driver does not probe if usbkbd was not present in stdin.
This presents two issues, we can not probe the driver before setting stdin
and we can not use this driver in other manner than stdin console.
This patch fixes this by adding an else statement. It simply probes the
driver without console management in the case "usbkbd" is not in stdin.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
common/usb_kbd.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 352d86fb2e..d385bea532 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -581,21 +581,22 @@ static int probe_usb_keyboard(struct usb_device *dev)
stdinname = env_get("stdin");
#if CONFIG_IS_ENABLED(CONSOLE_MUX)
- error = iomux_doenv(stdin, stdinname);
- if (error)
- return error;
+ if (strstr(stdinname, DEVNAME) != NULL) {
+ error = iomux_doenv(stdin, stdinname);
+ if (error)
+ return error;
+ }
#else
/* Check if this is the standard input device. */
- if (strcmp(stdinname, DEVNAME))
- return 1;
-
- /* Reassign the console */
- if (overwrite_console())
- return 1;
+ if (!strcmp(stdinname, DEVNAME)) {
+ /* Reassign the console */
+ if (overwrite_console())
+ return 1;
- error = console_assign(stdin, DEVNAME);
- if (error)
- return error;
+ error = console_assign(stdin, DEVNAME);
+ if (error)
+ return error;
+ }
#endif
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: kbd: allow probing even if usbkbd not in stdin
2022-06-22 8:59 [PATCH] usb: kbd: allow probing even if usbkbd not in stdin kory.maincent
@ 2022-06-24 18:12 ` Marek Vasut
2022-06-27 10:03 ` Köry Maincent
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2022-06-24 18:12 UTC (permalink / raw)
To: kory.maincent, u-boot; +Cc: thomas.petazzoni
On 6/22/22 10:59, kory.maincent@bootlin.com wrote:
> From: Kory Maincent <kory.maincent@bootlin.com>
>
> For now the driver does not probe if usbkbd was not present in stdin.
> This presents two issues, we can not probe the driver before setting stdin
Environment should be up and running before USB, so this is likely not a
problem.
> and we can not use this driver in other manner than stdin console.
>
> This patch fixes this by adding an else statement. It simply probes the
> driver without console management in the case "usbkbd" is not in stdin.
Can you document the usecase in a bit more detail ?
What exactly is the problem you are solving here ?
> stdinname = env_get("stdin");
> #if CONFIG_IS_ENABLED(CONSOLE_MUX)
> - error = iomux_doenv(stdin, stdinname);
> - if (error)
> - return error;
> + if (strstr(stdinname, DEVNAME) != NULL) {
> + error = iomux_doenv(stdin, stdinname);
> + if (error)
> + return error;
> + }
> #else
> /* Check if this is the standard input device. */
> - if (strcmp(stdinname, DEVNAME))
> - return 1;
> -
> - /* Reassign the console */
> - if (overwrite_console())
> - return 1;
> + if (!strcmp(stdinname, DEVNAME)) {
Maybe use strcmp() == NULL to be consistent with the != NULL check above ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: kbd: allow probing even if usbkbd not in stdin
2022-06-24 18:12 ` Marek Vasut
@ 2022-06-27 10:03 ` Köry Maincent
2022-06-27 11:39 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Köry Maincent @ 2022-06-27 10:03 UTC (permalink / raw)
To: Marek Vasut; +Cc: u-boot, thomas.petazzoni
Hello Marek,
On Fri, 24 Jun 2022 20:12:31 +0200
Marek Vasut <marex@denx.de> wrote:
> On 6/22/22 10:59, kory.maincent@bootlin.com wrote:
> > From: Kory Maincent <kory.maincent@bootlin.com>
> >
> > For now the driver does not probe if usbkbd was not present in stdin.
> > This presents two issues, we can not probe the driver before setting stdin
>
> Environment should be up and running before USB, so this is likely not a
> problem.
Having a driver probing only in this specific state is weird?
It should probe whatever the state of stdin.
>
> > and we can not use this driver in other manner than stdin console.
> >
> > This patch fixes this by adding an else statement. It simply probes the
> > driver without console management in the case "usbkbd" is not in stdin.
>
> Can you document the usecase in a bit more detail ?
My usecase is to get a key press from the USB keyboard and do some thing about
it in board_init. I do not want to multiplex the keyboard input to stdin but I
still want to read character from it.
> What exactly is the problem you are solving here ?
> > stdinname = env_get("stdin");
> > #if CONFIG_IS_ENABLED(CONSOLE_MUX)
> > - error = iomux_doenv(stdin, stdinname);
> > - if (error)
> > - return error;
> > + if (strstr(stdinname, DEVNAME) != NULL) {
> > + error = iomux_doenv(stdin, stdinname);
> > + if (error)
> > + return error;
> > + }
> > #else
> > /* Check if this is the standard input device. */
> > - if (strcmp(stdinname, DEVNAME))
> > - return 1;
> > -
> > - /* Reassign the console */
> > - if (overwrite_console())
> > - return 1;
> > + if (!strcmp(stdinname, DEVNAME)) {
>
> Maybe use strcmp() == NULL to be consistent with the != NULL check above ?
Yes, you are right.
Regards,
Köry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: kbd: allow probing even if usbkbd not in stdin
2022-06-27 10:03 ` Köry Maincent
@ 2022-06-27 11:39 ` Marek Vasut
2022-06-27 12:27 ` Köry Maincent
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2022-06-27 11:39 UTC (permalink / raw)
To: Köry Maincent; +Cc: u-boot, thomas.petazzoni
On 6/27/22 12:03, Köry Maincent wrote:
> Hello Marek,
>
> On Fri, 24 Jun 2022 20:12:31 +0200
> Marek Vasut <marex@denx.de> wrote:
>
>> On 6/22/22 10:59, kory.maincent@bootlin.com wrote:
>>> From: Kory Maincent <kory.maincent@bootlin.com>
>>>
>>> For now the driver does not probe if usbkbd was not present in stdin.
>>> This presents two issues, we can not probe the driver before setting stdin
>>
>> Environment should be up and running before USB, so this is likely not a
>> problem.
>
> Having a driver probing only in this specific state is weird?
> It should probe whatever the state of stdin.
>
>>
>>> and we can not use this driver in other manner than stdin console.
>>>
>>> This patch fixes this by adding an else statement. It simply probes the
>>> driver without console management in the case "usbkbd" is not in stdin.
>>
>> Can you document the usecase in a bit more detail ?
>
> My usecase is to get a key press from the USB keyboard and do some thing about
> it in board_init. I do not want to multiplex the keyboard input to stdin but I
> still want to read character from it.
All right, understood, both. Thanks for clarification.
I applied this to usb/next , I hope that's OK ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: kbd: allow probing even if usbkbd not in stdin
2022-06-27 11:39 ` Marek Vasut
@ 2022-06-27 12:27 ` Köry Maincent
0 siblings, 0 replies; 5+ messages in thread
From: Köry Maincent @ 2022-06-27 12:27 UTC (permalink / raw)
To: Marek Vasut; +Cc: u-boot, thomas.petazzoni
On Mon, 27 Jun 2022 13:39:03 +0200
Marek Vasut <marex@denx.de> wrote:
> >> Can you document the usecase in a bit more detail ?
> >
> > My usecase is to get a key press from the USB keyboard and do some thing
> > about it in board_init. I do not want to multiplex the keyboard input to
> > stdin but I still want to read character from it.
>
> All right, understood, both. Thanks for clarification.
>
> I applied this to usb/next , I hope that's OK ?
Great! Thanks!
Köry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-27 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-22 8:59 [PATCH] usb: kbd: allow probing even if usbkbd not in stdin kory.maincent
2022-06-24 18:12 ` Marek Vasut
2022-06-27 10:03 ` Köry Maincent
2022-06-27 11:39 ` Marek Vasut
2022-06-27 12:27 ` Köry Maincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox