Changeset 621ba8c in mainline


Ignore:
Timestamp:
2011-09-23T14:44:31Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4559d89
Parents:
3b617579
Message:

usbhub: Request only hub descriptor header. DOn't use deserialize function.

Remove utils.h/c.

Location:
uspace
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/Makefile

    r3b617579 r621ba8c  
    4444SOURCES = \
    4545        main.c \
    46         utils.c \
    4746        usbhub.c \
    4847        port.c
  • uspace/drv/bus/usb/usbhub/port.c

    r3b617579 r621ba8c  
    4545#include "port.h"
    4646#include "usbhub.h"
    47 #include "utils.h"
    4847#include "port_status.h"
    4948
  • uspace/drv/bus/usb/usbhub/usbhub.c

    r3b617579 r621ba8c  
    5454
    5555#include "usbhub.h"
    56 #include "utils.h"
    5756#include "port_status.h"
    5857
     
    242241        usb_log_debug("Retrieving descriptor\n");
    243242        usb_pipe_t *control_pipe = &hub_info->usb_device->ctrl_pipe;
    244         uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
    245         int opResult;
    246 
     243
     244        usb_hub_descriptor_header_t descriptor;
    247245        size_t received_size;
    248         opResult = usb_request_get_descriptor(control_pipe,
     246        int opResult = usb_request_get_descriptor(control_pipe,
    249247            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
    250             USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
    251             USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
    252 
     248            USB_DESCTYPE_HUB, 0, 0, &descriptor,
     249            sizeof(usb_hub_descriptor_t), &received_size);
    253250        if (opResult != EOK) {
    254251                usb_log_error("Failed to receive hub descriptor: %s.\n",
     
    256253                return opResult;
    257254        }
    258         usb_log_debug2("Parsing descriptor\n");
    259         usb_hub_descriptor_t descriptor;
    260         opResult = usb_deserialize_hub_desriptor(
    261                 serialized_descriptor, received_size, &descriptor);
    262         if (opResult != EOK) {
    263                 usb_log_error("Could not parse descriptor: %s\n",
    264                     str_error(opResult));
    265                 return opResult;
    266         }
    267         usb_log_debug("Setting port count to %d.\n", descriptor.ports_count);
    268         hub_info->port_count = descriptor.ports_count;
     255
     256        usb_log_debug("Setting port count to %d.\n", descriptor.port_count);
     257        hub_info->port_count = descriptor.port_count;
    269258
    270259        // TODO Why +1 ?
     
    281270
    282271        const bool is_power_switched =
    283             !(descriptor.hub_characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG);
     272            !(descriptor.characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG);
    284273        if (is_power_switched) {
    285274                usb_log_debug("Hub power switched\n");
    286                 const bool per_port_power = descriptor.hub_characteristics
     275                const bool per_port_power = descriptor.characteristics
    287276                    & HUB_CHAR_POWER_PER_PORT_FLAG;
    288277
     
    303292                        }
    304293                }
    305 
    306294        } else {
    307295                usb_log_debug("Power not switched, ports always powered\n");
  • uspace/lib/usb/include/usb/classes/hub.h

    r3b617579 r621ba8c  
    7272        uint8_t port_count;
    7373        /** Characteristics bitmask. */
    74         uint16_t characteristics;
     74        uint8_t characteristics;
     75#define HUB_CHAR_POWER_PER_PORT_FLAG  (1 << 0)
     76#define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)
     77        /* Unused part of characteristics field */
     78        uint8_t characteristics_reservered;
    7579        /** Time from power-on to stabilization of current on the port. */
    7680        uint8_t power_good_time;
     
    9296
    9397    /** Number of downstream ports that this hub supports */
    94     uint8_t ports_count;
     98    uint8_t port_count;
    9599
    96100    /**
     
    119123     */
    120124    uint16_t hub_characteristics;
    121 #define HUB_CHAR_POWER_PER_PORT_FLAG  (1 << 0)
    122 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)
    123125
    124126    /**
     
    214216 *      Maximum size of usb hub descriptor in bytes
    215217 */
    216 extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
    217 
    218 
    219 
    220 
    221 
    222 
     218/* 7 (basic size) + 2*32 (port bitmasks) */
     219#define USB_HUB_MAX_DESCRIPTOR_SIZE 71
    223220
    224221#endif
Note: See TracChangeset for help on using the changeset viewer.