Changeset 1bab1c8 in mainline


Ignore:
Timestamp:
2018-01-29T15:07:45Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ddbd088
Parents:
f3ae58b
Message:

libusbhost: bus_remove_endpoint no longer consumes a reference

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/bus.c

    rf3ae58b r1bab1c8  
    173173                endpoint_t * const ep = dev->endpoints[i];
    174174                endpoint_add_ref(ep);
    175                
     175
    176176                fibril_mutex_unlock(&dev->guard);
    177                 bus_endpoint_remove(ep);
     177                const int err = bus_endpoint_remove(ep);
     178                if (err)
     179                        usb_log_warning("Endpoint %u cannot be removed. "
     180                            "Some deffered cleanup was faster?", ep->endpoint);
     181
     182                endpoint_del_ref(ep);
    178183                fibril_mutex_lock(&dev->guard);
    179 
     184        }
     185
     186        for (usb_endpoint_t i = 1; i < USB_ENDPOINT_MAX; ++i)
    180187                assert(dev->endpoints[i] == NULL);
    181         }
    182188
    183189        /* Remove also orphaned children. */
     
    185191                device_t * const child = list_get_instance(list_first(&dev->devices), device_t, link);
    186192
    187                 usb_log_warning("USB device '%s' driver left device '%s' behind after %s.",
     193                /*
     194                 * This is not an error condition, as devices cannot remove
     195                 * their children devices while they are removed, because for
     196                 * DDF, they are siblings.
     197                 */
     198                usb_log_debug("USB device '%s' driver left device '%s' behind after %s.",
    188199                    ddf_fun_get_name(dev->fun), ddf_fun_get_name(child->fun), op);
     200
    189201                /*
    190202                 * The child node won't disappear, because its parent's driver
     
    463475
    464476/**
    465  * Remove an endpoint from the device. Consumes a reference.
     477 * Remove an endpoint from the device.
    466478 */
    467479int bus_endpoint_remove(endpoint_t *ep)
     
    491503
    492504        fibril_mutex_lock(&device->guard);
     505
     506        /* Check whether the endpoint is registered */
     507        if (device->endpoints[idx] != ep) {
     508                fibril_mutex_unlock(&device->guard);
     509                return EINVAL;
     510        }
     511
    493512        bus->ops->endpoint_unregister(ep);
    494513        device->endpoints[idx] = NULL;
     
    496515
    497516        /* Bus reference */
    498         endpoint_del_ref(ep);
    499 
    500         /* Given reference */
    501517        endpoint_del_ref(ep);
    502518
Note: See TracChangeset for help on using the changeset viewer.