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