Changeset 351113f in mainline
- Timestamp:
- 2018-01-11T12:41:40Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 929599a8
- Parents:
- 92caadd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/bus.c
r92caadd r351113f 229 229 int bus_device_online(device_t *dev) 230 230 { 231 int err;231 int rc; 232 232 assert(dev); 233 233 234 234 fibril_mutex_lock(&dev->guard); 235 235 if (dev->online) { 236 fibril_mutex_unlock(&dev->guard);237 return EINVAL;236 rc = EINVAL; 237 goto err_lock; 238 238 } 239 239 240 240 /* First, tell the HC driver. */ 241 241 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; 246 246 } 247 247 … … 252 252 fibril_mutex_unlock(&dev->guard); 253 253 254 if (( err= ddf_fun_online(dev->fun))) {254 if ((rc = ddf_fun_online(dev->fun))) { 255 255 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 263 err_lock: 264 fibril_mutex_unlock(&dev->guard); 265 err: 266 return rc; 262 267 } 263 268 … … 267 272 int bus_device_offline(device_t *dev) 268 273 { 269 int err;274 int rc; 270 275 assert(dev); 271 276 272 277 /* 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 } 275 282 276 283 /* … … 281 288 282 289 /* Tear down all drivers working with the device. */ 283 if (( err= ddf_fun_offline(dev->fun))) {284 returnerr;290 if ((rc = ddf_fun_offline(dev->fun))) { 291 goto err; 285 292 } 286 293 … … 295 302 296 303 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 307 err: 308 return rc; 299 309 } 300 310
Note:
See TracChangeset
for help on using the changeset viewer.