From 8e85e52708c54d1ce6f82074fa33c3bbaf611071 Mon Sep 17 00:00:00 2001 From: Zhihong Chen Date: Thu, 27 Jul 2023 11:27:06 +0800 Subject: [PATCH] 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 --- drivers/usbhost/usbhost_hidkbd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usbhost/usbhost_hidkbd.c b/drivers/usbhost/usbhost_hidkbd.c index bf622d2b1c..4306ad8e03 100644 --- a/drivers/usbhost/usbhost_hidkbd.c +++ b/drivers/usbhost/usbhost_hidkbd.c @@ -1420,13 +1420,14 @@ static int usbhost_kbdpoll(int argc, char *argv[]) priv->caps_lock = usbhost_get_capslock(); leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00; + *priv->tbuffer = leds; /* Send a report request to change the LED */ usbhost_send_request(priv, USB_REQ_DIR_OUT, USBHID_REQUEST_SETREPORT, USBHID_REPORTTYPE_OUTPUT << 8, 0, 1, - &leds); + priv->tbuffer); #ifdef CONFIG_HIDKBD_NOGETREPORT /* 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(); leds = usbhost_get_capslock() ? USBHID_KBDOUT_CAPSLOCK : 0x00; + *priv->tbuffer = leds; usbhost_send_request(priv, USB_REQ_DIR_OUT, USBHID_REQUEST_SETREPORT, USBHID_REPORTTYPE_OUTPUT << 8, 0, 1, - &leds); + priv->tbuffer); #ifdef CONFIG_HIDKBD_NOGETREPORT @@ -2137,7 +2139,7 @@ static int usbhost_cralloc(FAR struct usbhost_state_s *priv) FAR struct usbhost_hubport_s *hport; DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL && - priv->tbuffer == NULL); + priv->ctrlreq == NULL); hport = priv->usbclass.hport; return DRVR_ALLOC(hport->drvr, &priv->ctrlreq, &priv->ctrllen);