Changeset 904dcc6 in mainline for uspace/lib/usbdev/src/altiface.c


Ignore:
Timestamp:
2011-11-05T13:54:01Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7fc260ff
Parents:
99a1a56
Message:

libusbdev: Convert usb_alternate_interfaces_t interrface to init/deinit.

File:
1 edited

Legend:

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

    r99a1a56 r904dcc6  
    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,
     
    170162        }
    171163
    172         *alternates_ptr = alternates;
    173 
    174164        return EOK;
    175165}
    176166
    177 void usb_alternate_interfaces_destroy(usb_alternate_interfaces_t *alternate)
     167void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *alternate)
    178168{
    179169        if (!alternate)
    180170                return;
    181171        free(alternate->alternatives);
    182         free(alternate);
    183172}
    184173/**
Note: See TracChangeset for help on using the changeset viewer.