Ignore:
File:
1 edited

Legend:

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

    r8a121b1 r160b75e  
    7575 * @return Whether @p ptr points inside <code>data->data</code> field.
    7676 */
    77 static bool is_valid_descriptor_pointer(const usb_dp_parser_data_t *data,
    78     const uint8_t *ptr)
     77static bool is_valid_descriptor_pointer(usb_dp_parser_data_t *data,
     78    uint8_t *ptr)
    7979{
    8080        if (ptr == NULL) {
     
    100100 * @retval NULL Invalid input or no next descriptor.
    101101 */
    102 static const uint8_t *get_next_descriptor(const usb_dp_parser_data_t *data,
    103     const uint8_t *current)
     102static uint8_t *get_next_descriptor(usb_dp_parser_data_t *data,
     103    uint8_t *current)
    104104{
    105105        assert(is_valid_descriptor_pointer(data, current));
    106106
    107         const uint8_t current_length = *current;
    108         const uint8_t *next = current + current_length;
     107        uint8_t current_length = *current;
     108        uint8_t *next = current + current_length;
    109109
    110110        if (!is_valid_descriptor_pointer(data, next)) {
     
    124124 * @retval -1 Invalid input.
    125125 */
    126 static int get_descriptor_type(const usb_dp_parser_data_t *data, const uint8_t *start)
     126static int get_descriptor_type(usb_dp_parser_data_t *data, uint8_t *start)
    127127{
    128128        if (start == NULL) {
     
    145145 * @return Whether @p child could be child of @p parent.
    146146 */
    147 static bool is_nested_descriptor_type(const usb_dp_parser_t *parser,
     147static bool is_nested_descriptor_type(usb_dp_parser_t *parser,
    148148    int child, int parent)
    149149{
    150         const usb_dp_descriptor_nesting_t *nesting = parser->nesting;
     150        usb_dp_descriptor_nesting_t *nesting = parser->nesting;
    151151        while ((nesting->child > 0) && (nesting->parent > 0)) {
    152152                if ((nesting->child == child) && (nesting->parent == parent)) {
     
    166166 * @return Whether @p child could be child of @p parent.
    167167 */
    168 static bool is_nested_descriptor(const usb_dp_parser_t *parser,
    169     const usb_dp_parser_data_t *data, const uint8_t *child, const uint8_t *parent)
     168static bool is_nested_descriptor(usb_dp_parser_t *parser,
     169    usb_dp_parser_data_t *data, uint8_t *child, uint8_t *parent)
    170170{
    171171        return is_nested_descriptor_type(parser,
     
    183183 * @retval NULL Invalid input.
    184184 */
    185 const uint8_t *usb_dp_get_nested_descriptor(const usb_dp_parser_t *parser,
    186     const usb_dp_parser_data_t *data, const uint8_t *parent)
     185uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *parser,
     186    usb_dp_parser_data_t *data, uint8_t *parent)
    187187{
    188188        if (!is_valid_descriptor_pointer(data, parent)) {
     
    190190        }
    191191
    192         const uint8_t *next = get_next_descriptor(data, parent);
     192        uint8_t *next = get_next_descriptor(data, parent);
    193193        if (next == NULL) {
    194194                return NULL;
     
    211211 * @retval NULL Invalid input.
    212212 */
    213 static const uint8_t *skip_nested_descriptors(const usb_dp_parser_t *parser,
    214     const usb_dp_parser_data_t *data, const uint8_t *parent)
    215 {
    216         const uint8_t *child =
    217             usb_dp_get_nested_descriptor(parser, data, parent);
     213static uint8_t *skip_nested_descriptors(usb_dp_parser_t *parser,
     214    usb_dp_parser_data_t *data, uint8_t *parent)
     215{
     216        uint8_t *child = usb_dp_get_nested_descriptor(parser, data, parent);
    218217        if (child == NULL) {
    219218                return get_next_descriptor(data, parent);
    220219        }
    221         const uint8_t *next_child =
    222             skip_nested_descriptors(parser, data, child);
     220        uint8_t *next_child = skip_nested_descriptors(parser, data, child);
    223221        while (is_nested_descriptor(parser, data, next_child, parent)) {
    224222                next_child = skip_nested_descriptors(parser, data, next_child);
     
    238236 * @retval NULL Invalid input.
    239237 */
    240 const uint8_t *usb_dp_get_sibling_descriptor(
    241     const usb_dp_parser_t *parser, const usb_dp_parser_data_t *data,
    242     const uint8_t *parent, const uint8_t *sibling)
     238uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *parser,
     239    usb_dp_parser_data_t *data, uint8_t *parent, uint8_t *sibling)
    243240{
    244241        if (!is_valid_descriptor_pointer(data, parent)
     
    247244        }
    248245
    249         const uint8_t *possible_sibling =
    250             skip_nested_descriptors(parser, data, sibling);
     246        uint8_t *possible_sibling = skip_nested_descriptors(parser, data, sibling);
    251247        if (possible_sibling == NULL) {
    252248                return NULL;
     
    273269 * @param arg Custom (user) argument.
    274270 */
    275 static void usb_dp_browse_simple_internal(const usb_dp_parser_t *parser,
    276     const usb_dp_parser_data_t *data, const uint8_t *root, size_t depth,
    277     void (*callback)(const uint8_t *, size_t, void *), void *arg)
     271static void usb_dp_browse_simple_internal(usb_dp_parser_t *parser,
     272    usb_dp_parser_data_t *data, uint8_t *root, size_t depth,
     273    void (*callback)(uint8_t *, size_t, void *), void *arg)
    278274{
    279275        if (root == NULL) {
     
    281277        }
    282278        callback(root, depth, arg);
    283         const uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);
     279        uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);
    284280        do {
    285281                usb_dp_browse_simple_internal(parser, data, child, depth + 1,
     
    305301 */
    306302void usb_dp_walk_simple(uint8_t *descriptors, size_t descriptors_size,
    307     const usb_dp_descriptor_nesting_t *descriptor_nesting,
    308     walk_callback_t callback, void *arg)
     303    usb_dp_descriptor_nesting_t *descriptor_nesting,
     304    void (*callback)(uint8_t *, size_t, void *), void *arg)
    309305{
    310306        if ((descriptors == NULL) || (descriptors_size == 0)
     
    313309        }
    314310
    315         const usb_dp_parser_data_t data = {
     311        usb_dp_parser_data_t data = {
    316312                .data = descriptors,
    317313                .size = descriptors_size,
     
    319315        };
    320316
    321         const usb_dp_parser_t parser = {
     317        usb_dp_parser_t parser = {
    322318                .nesting = descriptor_nesting
    323319        };
Note: See TracChangeset for help on using the changeset viewer.