Changeset 20a3465 in mainline for uspace/drv/bus/usb/usbmid/usbmid.c


Ignore:
Timestamp:
2011-10-30T19:50:54Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3ce78580, 48902fa
Parents:
4c3ad56 (diff), 45bf63c (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 mainline changes

File:
1 edited

Legend:

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

    r4c3ad56 r20a3465  
    4545
    4646/** Callback for DDF USB interface. */
    47 static int usb_iface_get_address_impl(ddf_fun_t *fun, devman_handle_t handle,
    48     usb_address_t *address)
    49 {
    50         return usb_iface_get_address_hub_impl(fun, handle, address);
    51 }
    52 
    53 /** Callback for DDF USB interface. */
    5447static int usb_iface_get_interface_impl(ddf_fun_t *fun, devman_handle_t handle,
    5548    int *iface_no)
     
    7063static usb_iface_t child_usb_iface = {
    7164        .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl,
    72         .get_address = usb_iface_get_address_impl,
     65        .get_address = usb_iface_get_address_hub_impl,
    7366        .get_interface = usb_iface_get_interface_impl
    7467};
     
    7972};
    8073
     74int usbmid_interface_destroy(usbmid_interface_t *mid_iface)
     75{
     76        assert(mid_iface);
     77        assert_link_not_used(&mid_iface->link);
     78        const int ret = ddf_fun_unbind(mid_iface->fun);
     79        if (ret != EOK) {
     80                return ret;
     81        }
     82        /* NOTE: usbmid->interface points somewhere, but we did not
     83         * allocate that space, so don't touch */
     84        ddf_fun_destroy(mid_iface->fun);
     85        /* NOTE: mid_iface is invalid at this point, it was assigned to
     86         * mid_iface->fun->driver_data and freed in ddf_fun_destroy */
     87        return EOK;
     88}
    8189
    8290/** Spawn new child device from one interface.
     
    106114            (int) interface_descriptor->interface_number);
    107115        if (rc < 0) {
    108                 goto error_leave;
     116                return ENOMEM;
    109117        }
    110118
    111119        /* Create the device. */
    112120        child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
     121        free(child_name);
    113122        if (child == NULL) {
    114                 rc = ENOMEM;
    115                 goto error_leave;
     123                return ENOMEM;
    116124        }
    117125
     
    122130
    123131        rc = usb_device_create_match_ids_from_interface(device_descriptor,
    124             interface_descriptor,
    125             &child->match_ids);
     132            interface_descriptor, &child->match_ids);
    126133        if (rc != EOK) {
    127                 goto error_leave;
     134                ddf_fun_destroy(child);
     135                return rc;
    128136        }
    129137
    130138        rc = ddf_fun_bind(child);
    131139        if (rc != EOK) {
    132                 goto error_leave;
     140                /* This takes care of match_id deallocation as well. */
     141                ddf_fun_destroy(child);
     142                return rc;
    133143        }
    134144
    135145        return EOK;
    136 
    137 error_leave:
    138         if (child != NULL) {
    139                 child->name = NULL;
    140                 /* This takes care of match_id deallocation as well. */
    141                 ddf_fun_destroy(child);
    142         }
    143         if (child_name != NULL) {
    144                 free(child_name);
    145         }
    146 
    147         return rc;
    148146}
    149147
Note: See TracChangeset for help on using the changeset viewer.