Changeset 351113f in mainline


Ignore:
Timestamp:
2018-01-11T12:41:40Z (6 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
929599a8
Parents:
92caadd
Message:

usbhost: fix return in critical section, change misleading log messages

File:
1 edited

Legend:

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

    r92caadd r351113f  
    229229int bus_device_online(device_t *dev)
    230230{
    231         int err;
     231        int rc;
    232232        assert(dev);
    233233
    234234        fibril_mutex_lock(&dev->guard);
    235235        if (dev->online) {
    236                 fibril_mutex_unlock(&dev->guard);
    237                 return EINVAL;
     236                rc = EINVAL;
     237                goto err_lock;
    238238        }
    239239
    240240        /* First, tell the HC driver. */
    241241        const bus_ops_t *ops = BUS_OPS_LOOKUP(dev->bus->ops, device_online);
    242         if (ops && (err = ops->device_online(dev))) {
    243                 usb_log_warning("Host controller refused to make device '%s' online: %s",
    244                     ddf_fun_get_name(dev->fun), str_error(err));
    245                 return err;
     242        if (ops && (rc = ops->device_online(dev))) {
     243                usb_log_warning("Host controller failed to make device '%s' online: %s",
     244                    ddf_fun_get_name(dev->fun), str_error(rc));
     245                goto err_lock;
    246246        }
    247247
     
    252252        fibril_mutex_unlock(&dev->guard);
    253253
    254         if ((err = ddf_fun_online(dev->fun))) {
     254        if ((rc = ddf_fun_online(dev->fun))) {
    255255                usb_log_warning("Failed to take device '%s' online: %s",
    256                     ddf_fun_get_name(dev->fun), str_error(err));
    257                 return err;
    258         }
    259 
    260         usb_log_info("USB Device '%s' offlined.", ddf_fun_get_name(dev->fun));
    261         return EOK;
     256                    ddf_fun_get_name(dev->fun), str_error(rc));
     257                goto err;
     258        }
     259
     260        usb_log_info("USB Device '%s' is now online.", ddf_fun_get_name(dev->fun));
     261        return EOK;
     262
     263err_lock:
     264        fibril_mutex_unlock(&dev->guard);
     265err:
     266        return rc;
    262267}
    263268
     
    267272int bus_device_offline(device_t *dev)
    268273{
    269         int err;
     274        int rc;
    270275        assert(dev);
    271276
    272277        /* Make sure we're the one who offlines this device */
    273         if (!dev->online)
    274                 return ENOENT;
     278        if (!dev->online) {
     279                rc = ENOENT;
     280                goto err;
     281        }
    275282
    276283        /*
     
    281288       
    282289        /* Tear down all drivers working with the device. */
    283         if ((err = ddf_fun_offline(dev->fun))) {
    284                 return err;
     290        if ((rc = ddf_fun_offline(dev->fun))) {
     291                goto err;
    285292        }
    286293
     
    295302
    296303        fibril_mutex_unlock(&dev->guard);
    297         usb_log_info("USB Device '%s' offlined.", ddf_fun_get_name(dev->fun));
    298         return EOK;
     304        usb_log_info("USB Device '%s' is now offline.", ddf_fun_get_name(dev->fun));
     305        return EOK;
     306
     307err:
     308        return rc;
    299309}
    300310
Note: See TracChangeset for help on using the changeset viewer.