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

Changeset 516d361 in mainline


Ignore:
Timestamp:
2017-12-20T15:55:28Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
d9f0894
Parents:
4547f11
Message:

Return address from usb_bus_get_free_address() separately from error code.

File:
1 edited

Legend:

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

    r4547f11 r516d361  
    102102 *
    103103 * @param[in] instance Device manager structure to use.
    104  * @return Free address, or error code.
    105  */
    106 static usb_address_t usb_bus_get_free_address(usb_bus_t *instance)
     104 * @param[out] address Free address.
     105 * @return Error code.
     106 */
     107static int usb_bus_get_free_address(usb_bus_t *instance, usb_address_t *address)
    107108{
    108109
     
    119120        instance->last_address = new_address;
    120121
    121         return new_address;
     122        *address = new_address;
     123        return EOK;
    122124}
    123125
     
    474476/** Request USB address.
    475477 * @param instance usb_device_manager
    476  * @param address Pointer to requested address value, place to store new address
     478 * @param[inout] address Pointer to requested address value, place to store new address
    477479 * @parma strict Fail if the requested address is not available.
    478480 * @return Error code.
     
    491493
    492494        usb_address_t addr = *address;
     495        int rc;
    493496
    494497        fibril_mutex_lock(&instance->guard);
    495498        /* Only grant default address to strict requests */
    496499        if ((addr == USB_ADDRESS_DEFAULT) && !strict) {
    497                 addr = usb_bus_get_free_address(instance);
     500                rc = usb_bus_get_free_address(instance, &addr);
     501                if (rc != EOK) {
     502                        fibril_mutex_unlock(&instance->guard);
     503                        return rc;
     504                }
    498505        }
    499506
     
    503510                        return ENOENT;
    504511                }
    505                 addr = usb_bus_get_free_address(instance);
     512                rc = usb_bus_get_free_address(instance, &addr);
     513                if (rc != EOK) {
     514                        fibril_mutex_unlock(&instance->guard);
     515                        return rc;
     516                }
    506517        }
    507518        if (usb_address_is_valid(addr)) {
     
    516527
    517528        fibril_mutex_unlock(&instance->guard);
    518         return addr;
     529
     530        *address = addr;
     531        return EOK;
    519532}
    520533
Note: See TracChangeset for help on using the changeset viewer.