Changeset b4ca0a9c in mainline for uspace/lib/usbdev/src/recognise.c
- Timestamp:
- 2012-07-10T11:53:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1e01a35
- Parents:
- a33706e (diff), 33fc3ae (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/recognise.c
ra33706e rb4ca0a9c 33 33 * Functions for recognition of attached devices. 34 34 */ 35 35 36 #include <sys/types.h> 36 37 #include <fibril_synch.h> … … 311 312 * will be written. 312 313 * @return Error code. 314 * 313 315 */ 314 316 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, … … 318 320 if (child_fun == NULL || ctrl_pipe == NULL) 319 321 return EINVAL; 320 322 321 323 if (!dev_ops && dev_data) { 322 324 usb_log_warning("Using standard fun ops with arbitrary " 323 325 "driver data. This does not have to work.\n"); 324 326 } 325 327 326 328 /** Index to append after device name for uniqueness. */ 327 329 static atomic_t device_name_index = {0}; 328 330 const size_t this_device_name_index = 329 331 (size_t) atomic_preinc(&device_name_index); 330 332 331 333 ddf_fun_t *child = NULL; 332 334 int rc; 333 335 334 336 /* 335 337 * TODO: Once the device driver framework support persistent 336 338 * naming etc., something more descriptive could be created. 337 339 */ 338 char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */340 char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */ 339 341 rc = snprintf(child_name, sizeof(child_name), 340 342 "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address); … … 342 344 goto failure; 343 345 } 344 346 345 347 child = ddf_fun_create(parent, fun_inner, child_name); 346 348 if (child == NULL) { … … 348 350 goto failure; 349 351 } 350 351 if (dev_ops != NULL) {352 353 if (dev_ops != NULL) 352 354 child->ops = dev_ops; 353 } else {355 else 354 356 child->ops = &child_ops; 355 } 356 357 357 358 child->driver_data = dev_data; 358 /* Store the attached device in fun driver data if there is no 359 * other data */ 359 /* 360 * Store the attached device in fun 361 * driver data if there is no other data 362 */ 360 363 if (!dev_data) { 361 364 usb_hub_attached_device_t *new_device = ddf_fun_data_alloc( … … 365 368 goto failure; 366 369 } 370 367 371 new_device->address = ctrl_pipe->wire->address; 368 372 new_device->fun = child; 369 373 } 370 371 374 372 375 rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids); 373 if (rc != EOK) {376 if (rc != EOK) 374 377 goto failure; 375 } 376 378 377 379 rc = ddf_fun_bind(child); 378 if (rc != EOK) {380 if (rc != EOK) 379 381 goto failure; 380 } 381 382 382 383 *child_fun = child; 383 384 return EOK; 384 385 385 386 failure: 386 387 if (child != NULL) { 387 388 /* We know nothing about the data if it came from outside. */ 388 if (dev_data) {389 if (dev_data) 389 390 child->driver_data = NULL; 390 }391 391 392 /* This takes care of match_id deallocation as well. */ 392 393 ddf_fun_destroy(child); 393 394 } 394 395 395 396 return rc; 396 397 } 397 398 398 399 399 /** 400 400 * @}
Note:
See TracChangeset
for help on using the changeset viewer.