From 3fe8c9a20ecc6cd5d03f5903e6b4a65e38a42480 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 12 May 2012 21:57:01 +0800 Subject: [PATCH] Modules/USB - Less chatty device initialisation --- KernelLand/Modules/USB/Core/usb_devinit.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/KernelLand/Modules/USB/Core/usb_devinit.c b/KernelLand/Modules/USB/Core/usb_devinit.c index 32076690..7b1b724f 100644 --- a/KernelLand/Modules/USB/Core/usb_devinit.c +++ b/KernelLand/Modules/USB/Core/usb_devinit.c @@ -6,7 +6,6 @@ * - USB Device Initialisation */ #define DEBUG 1 - #include #include #include @@ -14,6 +13,8 @@ #include "usb_proto.h" #include "usb_lowlevel.h" +#define DUMP_DESCRIPTORS 0 + // === PROTOTYPES === void USB_DeviceConnected(tUSBHub *Hub, int Port); void USB_DeviceDisconnected(tUSBHub *Hub, int Port); @@ -55,7 +56,8 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) LOG("Getting device descriptor"); // Endpoint 0, Desc Type 1, Index 0 USB_int_ReadDescriptor(dev, 0, 1, 0, sizeof(desc), &desc); - + + #if DUMP_DESCRIPTORS LOG("Device Descriptor = {"); LOG(" .Length = %i", desc.Length); LOG(" .Type = %i", desc.Type); @@ -99,6 +101,7 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) } } #endif + #endif } // TODO: Support alternate configurations @@ -112,6 +115,7 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) size_t total_length; USB_int_ReadDescriptor(dev, 0, 2, i, sizeof(desc), &desc); + #if DUMP_DESCRIPTORS LOG("Configuration Descriptor %i = {", i); LOG(" .Length = %i", desc.Length); LOG(" .Type = %i", desc.Type); @@ -127,6 +131,7 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) LOG("ConfigurationStr = '%s'", tmp); free(tmp); } + #endif // TODO: Split here and allow some method of selection @@ -167,20 +172,22 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) continue ; } + #if DUMP_DESCRIPTORS LOG("Interface %i/%i = {", i, j); LOG(" .InterfaceNum = %i", iface->InterfaceNum); LOG(" .NumEndpoints = %i", iface->NumEndpoints); LOG(" .InterfaceClass = 0x%x", iface->InterfaceClass); LOG(" .InterfaceSubClass = 0x%x", iface->InterfaceSubClass); LOG(" .InterfaceProcol = 0x%x", iface->InterfaceProtocol); - #if DEBUG + # if DEBUG if( iface->InterfaceStr ) { char *tmp = USB_int_GetDeviceString(dev, 0, iface->InterfaceStr); LOG(" .InterfaceStr = %i '%s'", iface->InterfaceStr, tmp); free(tmp); } - #endif + # endif LOG("}"); + #endif dev_if = malloc(sizeof(tUSBInterface) + iface->NumEndpoints*sizeof(dev_if->Endpoints[0])); dev_if->Dev = dev; -- 2.20.1