drivers: usbhost: fix usbhost_hidkbd some errors

- usbhost_send_request(): data should using DRVR_ALLOC buffer
- fix usbhost_cralloc() assert variable

Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
This commit is contained in:
Zhihong Chen 2023-07-27 11:27:06 +08:00 committed by Xiang Xiao
parent b515f9a360
commit 8e85e52708

View File

@ -1420,13 +1420,14 @@ static int usbhost_kbdpoll(int argc, char *argv[])
priv->caps_lock = usbhost_get_capslock(); priv->caps_lock = usbhost_get_capslock();
leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00; leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00;
*priv->tbuffer = leds;
/* Send a report request to change the LED */ /* Send a report request to change the LED */
usbhost_send_request(priv, USB_REQ_DIR_OUT, usbhost_send_request(priv, USB_REQ_DIR_OUT,
USBHID_REQUEST_SETREPORT, USBHID_REQUEST_SETREPORT,
USBHID_REPORTTYPE_OUTPUT << 8, 0, 1, USBHID_REPORTTYPE_OUTPUT << 8, 0, 1,
&leds); priv->tbuffer);
#ifdef CONFIG_HIDKBD_NOGETREPORT #ifdef CONFIG_HIDKBD_NOGETREPORT
/* Setup to receive the next report */ /* Setup to receive the next report */
@ -1915,9 +1916,10 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv)
priv->caps_lock = usbhost_get_capslock(); priv->caps_lock = usbhost_get_capslock();
leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00; leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00;
*priv->tbuffer = leds;
usbhost_send_request(priv, USB_REQ_DIR_OUT, USBHID_REQUEST_SETREPORT, usbhost_send_request(priv, USB_REQ_DIR_OUT, USBHID_REQUEST_SETREPORT,
USBHID_REPORTTYPE_OUTPUT << 8, 0, 1, USBHID_REPORTTYPE_OUTPUT << 8, 0, 1,
&leds); priv->tbuffer);
#ifdef CONFIG_HIDKBD_NOGETREPORT #ifdef CONFIG_HIDKBD_NOGETREPORT
@ -2137,7 +2139,7 @@ static int usbhost_cralloc(FAR struct usbhost_state_s *priv)
FAR struct usbhost_hubport_s *hport; FAR struct usbhost_hubport_s *hport;
DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL && DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL &&
priv->tbuffer == NULL); priv->ctrlreq == NULL);
hport = priv->usbclass.hport; hport = priv->usbclass.hport;
return DRVR_ALLOC(hport->drvr, &priv->ctrlreq, &priv->ctrllen); return DRVR_ALLOC(hport->drvr, &priv->ctrlreq, &priv->ctrllen);