Changeset 747ef72 in mainline for uspace/lib/usbdev/src/altiface.c


Ignore:
Timestamp:
2011-11-10T11:29:10Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
54464f6a, c2245a3, c6f189f7
Parents:
2e1b9dc (diff), 2d1ba51 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge USB changes.

Interface changes:

  • GET_ADDRESS has been renamed to GET_MY_ADDRESS and the handle parameter was dropped. Tis call no longer cascades up to the root hub, but it is answered in the first place the information is available (nearest hub)
  • Reintroduced address reservation for USB_DEFAULT_ADDRESS. The interface now enables device drivers to request specific address on initialization and either insists on that address or accept any other if the address is not available. Note that it is not possible to get the default address if the driver does not insist.
  • Any endpoint registered is removed when address is released and a warning is produced if there were any such endpoints.
  • It is no longer necessary or possible to pass device speed information when registering endpoints.

Driver fixes: memory leaks and crashes (not only) in error paths.
Fixes or removes flaky device_remove implementation in device drivers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/altiface.c

    r2e1b9dc r747ef72  
    9090 * @return Error code.
    9191 */
    92 int usb_alternate_interfaces_create(const uint8_t *config_descr,
    93     size_t config_descr_size, int interface_number,
    94     usb_alternate_interfaces_t **alternates_ptr)
     92int usb_alternate_interfaces_init(usb_alternate_interfaces_t *alternates,
     93    const uint8_t *config_descr, size_t config_descr_size, int interface_number)
    9594{
    96         assert(alternates_ptr != NULL);
     95        assert(alternates != NULL);
    9796        assert(config_descr != NULL);
    9897        assert(config_descr_size > 0);
    9998
    100         *alternates_ptr = NULL;
     99        alternates->alternatives = NULL;
     100        alternates->alternative_count = 0;
     101        alternates->current = 0;
     102
    101103        if (interface_number < 0) {
    102104                return EOK;
    103         }
    104 
    105         usb_alternate_interfaces_t *alternates
    106             = malloc(sizeof(usb_alternate_interfaces_t));
    107         if (alternates == NULL) {
    108                 return ENOMEM;
    109105        }
    110106
     
    114110
    115111        if (alternates->alternative_count == 0) {
    116                 free(alternates);
    117112                return ENOENT;
    118113        }
     
    121116            sizeof(usb_alternate_interface_descriptors_t));
    122117        if (alternates->alternatives == NULL) {
    123                 free(alternates);
    124118                return ENOMEM;
    125119        }
    126120
    127         alternates->current = 0;
    128 
    129         usb_dp_parser_t dp_parser = {
     121        const usb_dp_parser_t dp_parser = {
    130122                .nesting = usb_dp_standard_descriptor_nesting
    131123        };
    132         usb_dp_parser_data_t dp_data = {
     124        const usb_dp_parser_data_t dp_data = {
    133125                .data = config_descr,
    134126                .size = config_descr_size,
     
    147139                    || (iface->interface_number != interface_number)) {
    148140                        iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser,
    149                             &dp_data,
    150                             dp_data.data, iface_ptr);
     141                            &dp_data, dp_data.data, iface_ptr);
    151142                        continue;
    152143                }
     
    170161        }
    171162
    172         *alternates_ptr = alternates;
    173 
    174163        return EOK;
    175164}
    176165
    177 void usb_alternate_interfaces_destroy(usb_alternate_interfaces_t *alternate)
     166void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate)
    178167{
    179168        if (!alternate)
    180169                return;
    181170        free(alternate->alternatives);
    182         free(alternate);
    183171}
    184172/**
Note: See TracChangeset for help on using the changeset viewer.