usb: kbd: allow probing even if usbkbd not in stdin
PATCH 1/1 usb: kbd: allow probing even if usbkbd not in stdin
From: Kory Maincent <[email protected]>
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.
--- common/usb_kbd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
common/usb_kbd.c +13 -12
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 4 lines · On 6/22/22 10:59, [email protected] wrote:
From: Kory Maincent <[email protected]>
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.
Quoted 4 lines
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 ?
Quoted 9 lines
stdinname = env_get("stdin"); #if CONFIG_IS_ENABLED(CONSOLE_MUX)common/usb_kbd.c +4
-3- error =iomux_doenv (stdin, stdinname); -if (error) -return error; +if (strstr (stdinname,DEVNAME ) !=NULL ) { + error =iomux_doenv (stdin, stdinname); +if (error) +return error;
common/usb_kbd.c static int probe_usb_keyboard(struct usb_device *dev) · line 591
Quoted 10 lines
common/usb_kbd.c +2
-6+ }#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 ?
Hello Marek,
Quoted 8 lines · On Fri, 24 Jun 2022 20:12:31 +0200 Marek Vasut <[email protected]> wrote:
Quoted 4 lines · On 6/22/22 10:59, [email protected] wrote:
From: Kory Maincent <[email protected]>
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.
Quoted 7 lines
Quoted 5 lines
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.
Quoted 14 lines
What exactly is the problem you are solving here ?
Quoted 13 lines
stdinname = env_get("stdin"); #if CONFIG_IS_ENABLED(CONSOLE_MUX)common/usb_kbd.c +5
-4- 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 ))
Quoted 8 lines
common/usb_kbd.c static int probe_usb_keyboard(struct usb_device *dev) · line 591
Quoted 6 lines
common/usb_kbd.c +1
-5-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
Quoted 20 lines · Köry Maincent
Hello Marek,
Quoted 8 lines · On Fri, 24 Jun 2022 20:12:31 +0200 Marek Vasut <[email protected]> wrote:
Quoted 4 lines · On 6/22/22 10:59, [email protected] wrote:
From: Kory Maincent <[email protected]>
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.
Quoted 3 lines
Quoted 3 lines
and we can not use this driver in other manner than stdin console.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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 ?
Quoted 9 lines · On Mon, 27 Jun 2022 13:39:03 +0200 Marek Vasut <[email protected]> wrote:
Quoted 5 lines
Quoted 1 line
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