From 4842dfe6f77c21f7074ca79b0ce3f882f08f92b2 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Fri, 25 May 2012 09:59:19 +0200 Subject: libpayload: Free intr queue structure in usb_hid_destroy The call to destroy_intr_queue was missing in usb_hid_destroy. Change-Id: I51ccc6a79bc005819317263be24a56c51acd5f55 Signed-off-by: Nico Huber Reviewed-on: http://review.coreboot.org/1082 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/drivers/usb/usbhid.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'payloads') diff --git a/payloads/libpayload/drivers/usb/usbhid.c b/payloads/libpayload/drivers/usb/usbhid.c index 840b298cf8..d5141c6353 100644 --- a/payloads/libpayload/drivers/usb/usbhid.c +++ b/payloads/libpayload/drivers/usb/usbhid.c @@ -42,12 +42,6 @@ enum { GET_REPORT = 0x1, GET_IDLE = 0x2, GET_PROTOCOL = 0x3, SET_REPORT = 0x9, SET_IDLE = 0xa, SET_PROTOCOL = 0xb }; -static void -usb_hid_destroy (usbdev_t *dev) -{ - free (dev->data); -} - typedef struct { void* queue; hid_descriptor_t *descriptor; @@ -55,6 +49,27 @@ typedef struct { #define HID_INST(dev) ((usbhid_inst_t*)(dev)->data) +static void +usb_hid_destroy (usbdev_t *dev) +{ + if (HID_INST(dev)->queue) { + int i; + for (i = 0; i <= dev->num_endp; i++) { + if (dev->endpoints[i].endpoint == 0) + continue; + if (dev->endpoints[i].type != INTERRUPT) + continue; + if (dev->endpoints[i].direction != IN) + continue; + break; + } + dev->controller->destroy_intr_queue( + &dev->endpoints[i], HID_INST(dev)->queue); + HID_INST(dev)->queue = NULL; + } + free (dev->data); +} + /* keybuffer is global to all USB keyboards */ static int keycount; #define KEYBOARD_BUFFER_SIZE 16 -- cgit v1.2.3