Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1f1fa64 in mainline for uspace/drv/bus/usb/usbmid/explore.c


Ignore:
Timestamp:
2014-07-28T21:53:11Z (7 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
lfn, master
Children:
c3b25985, f2f4c00
Parents:
cbfece7 (diff), 7eb6c96 (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:

Make MAC address change possible on ethip side. Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmid/explore.c

    rcbfece7 r1f1fa64  
    3434 * Exploration of available interfaces in the USB device.
    3535 */
     36#include <ddf/driver.h>
    3637#include <errno.h>
    3738#include <str_error.h>
     
    7071 * @param config_descriptor_size Size of configuration descriptor in bytes.
    7172 * @param list List where to add the interfaces.
    72  */
    73 static void create_interfaces(const uint8_t *config_descriptor,
    74     size_t config_descriptor_size, list_t *list)
     73 * @return EOK on success, ENOMEM if out of memory.
     74 */
     75static int create_interfaces(usb_mid_t *mid, const uint8_t *config_descriptor,
     76    size_t config_descriptor_size)
    7577{
    7678        const usb_dp_parser_data_t data = {
     
    101103
    102104                /* Skip alternate interfaces. */
    103                 if (interface_in_list(list, interface->interface_number)) {
     105                if (interface_in_list(&mid->interface_list,
     106                    interface->interface_number)) {
    104107                        /* TODO: add the alternatives and create match ids
    105108                         * for them. */
    106109                        continue;
    107110                }
    108                 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
    109                 if (iface == NULL) {
    110                         //TODO: Do something about that failure.
    111                         break;
    112                 }
     111
     112                /* Create the function */
     113                ddf_fun_t *fun = ddf_fun_create(mid->dev, fun_inner, NULL);
     114                if (fun == NULL)
     115                        goto error;
     116
     117                usbmid_interface_t *iface = ddf_fun_data_alloc(fun,
     118                    sizeof(usbmid_interface_t));
     119                if (iface == NULL)
     120                        goto error;
    113121
    114122                link_initialize(&iface->link);
    115                 iface->fun = NULL;
     123                iface->fun = fun;
    116124                iface->interface_no = interface->interface_number;
    117125                iface->interface = interface;
    118126
    119                 list_append(&iface->link, list);
    120         }
     127                list_append(&iface->link, &mid->interface_list);
     128        }
     129
     130        return EOK;
     131error:
     132        while (!list_empty(&mid->interface_list)) {
     133                link_t *link = list_first(&mid->interface_list);
     134                usbmid_interface_t *iface = list_get_instance(link,
     135                    usbmid_interface_t, link);
     136
     137                ddf_fun_destroy(iface->fun);
     138        }
     139
     140        return ENOMEM;
    121141}
    122142
     
    165185        }
    166186
     187        usb_mid->dev = dev->ddf_dev;
     188
    167189        /* Create control function. */
    168190        usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
     
    182204        }
    183205
    184 
    185206        /* Create interface children. */
    186207        list_initialize(&usb_mid->interface_list);
    187         create_interfaces(config_descriptor_raw, config_descriptor_size,
    188             &usb_mid->interface_list);
     208        create_interfaces(usb_mid, config_descriptor_raw, config_descriptor_size);
    189209
    190210        /* Start child function for every interface. */
Note: See TracChangeset for help on using the changeset viewer.