Changeset b6812a1 in mainline


Ignore:
Timestamp:
2013-01-26T17:25:05Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ad97131
Parents:
6785b538
Message:

libusbdev: Make list of alternate interfaces const.

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/driver.h

    r6785b538 rb6812a1  
    5959typedef struct {
    6060        /** Array of alternate interfaces descriptions. */
    61         usb_alternate_interface_descriptors_t *alternatives;
     61        const usb_alternate_interface_descriptors_t *alternatives;
    6262        /** Size of @c alternatives array. */
    6363        size_t alternative_count;
     
    8989         */
    9090        int interface_no;
    91 
    9291        /** Alternative interfaces. */
    9392        usb_alternate_interfaces_t alternate_interfaces;
  • uspace/lib/usbdev/src/altiface.c

    r6785b538 rb6812a1  
    105105        }
    106106
    107         alternates->alternative_count
    108             = usb_interface_count_alternates(config_descr, config_descr_size,
    109                 interface_number);
     107        const size_t alt_count =usb_interface_count_alternates(config_descr,
     108            config_descr_size, interface_number);
    110109
    111         if (alternates->alternative_count == 0) {
     110        if (alt_count == 0) {
    112111                return ENOENT;
    113112        }
    114113
    115         alternates->alternatives = calloc(alternates->alternative_count,
     114        usb_alternate_interface_descriptors_t *alts = calloc(alt_count,
    116115            sizeof(usb_alternate_interface_descriptors_t));
    117         if (alternates->alternatives == NULL) {
     116        if (alts == NULL) {
    118117                return ENOMEM;
    119118        }
     
    128127        };
    129128
    130         usb_alternate_interface_descriptors_t *iterator
    131             = &alternates->alternatives[0];
    132 
    133         const usb_alternate_interface_descriptors_t *end
    134             = &alternates->alternatives[alternates->alternative_count];
    135129
    136130        const void *iface_ptr =
    137131            usb_dp_get_nested_descriptor(&dp_parser, &dp_data, dp_data.data);
    138132
    139         while (iface_ptr != NULL && iterator < end) {
     133        usb_alternate_interface_descriptors_t *iterator = alts;
     134        for (; iface_ptr != NULL && iterator < &alts[alt_count]; ++iterator) {
    140135                const usb_standard_interface_descriptor_t *iface = iface_ptr;
    141136
     
    165160        }
    166161
     162        alternates->alternatives = alts;
     163        alternates->alternative_count = alt_count;
     164
    167165        return EOK;
    168166}
Note: See TracChangeset for help on using the changeset viewer.