Changes in uspace/lib/usbdev/src/recognise.c [ffa96c2:feeac0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/recognise.c
rffa96c2 rfeeac0d 33 33 * Functions for recognition of attached devices. 34 34 */ 35 36 /** XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 35 38 36 39 #include <sys/types.h> … … 315 318 */ 316 319 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 317 ddf_dev_t *parent, ddf_fun_t *fun, ddf_dev_ops_t *dev_ops) 320 ddf_dev_t *parent, ddf_dev_ops_t *dev_ops, void *dev_data, 321 ddf_fun_t **child_fun) 318 322 { 319 if (c trl_pipe == NULL)323 if (child_fun == NULL || ctrl_pipe == NULL) 320 324 return EINVAL; 321 325 322 if (!dev_ops && d df_fun_data_get(fun) != NULL) {326 if (!dev_ops && dev_data) { 323 327 usb_log_warning("Using standard fun ops with arbitrary " 324 328 "driver data. This does not have to work.\n"); … … 330 334 (size_t) atomic_preinc(&device_name_index); 331 335 336 ddf_fun_t *child = NULL; 332 337 int rc; 333 338 … … 343 348 } 344 349 345 rc = ddf_fun_set_name(fun, child_name); 346 if (rc != EOK) 350 child = ddf_fun_create(parent, fun_inner, child_name); 351 if (child == NULL) { 352 rc = ENOMEM; 347 353 goto failure; 354 } 348 355 349 356 if (dev_ops != NULL) 350 ddf_fun_set_ops( fun, dev_ops);357 ddf_fun_set_ops(child, dev_ops); 351 358 else 352 ddf_fun_set_ops(fun, &child_ops); 359 ddf_fun_set_ops(child, &child_ops); 360 361 ddf_fun_data_implant(child, dev_data); 353 362 354 363 /* … … 356 365 * driver data if there is no other data 357 366 */ 358 if ( ddf_fun_data_get(fun) == NULL) {367 if (!dev_data) { 359 368 usb_hub_attached_device_t *new_device = ddf_fun_data_alloc( 360 fun, sizeof(usb_hub_attached_device_t));369 child, sizeof(usb_hub_attached_device_t)); 361 370 if (!new_device) { 362 371 rc = ENOMEM; … … 365 374 366 375 new_device->address = ctrl_pipe->wire->address; 367 new_device->fun = fun;376 new_device->fun = child; 368 377 } 369 378 … … 375 384 376 385 list_foreach(match_ids.ids, link, match_id_t, match_id) { 377 rc = ddf_fun_add_match_id( fun, match_id->id, match_id->score);386 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 378 387 if (rc != EOK) { 379 388 clean_match_ids(&match_ids); … … 384 393 clean_match_ids(&match_ids); 385 394 386 rc = ddf_fun_bind( fun);395 rc = ddf_fun_bind(child); 387 396 if (rc != EOK) 388 397 goto failure; 389 398 399 *child_fun = child; 390 400 return EOK; 391 401 392 402 failure: 403 if (child != NULL) { 404 /* This takes care of match_id deallocation as well. */ 405 ddf_fun_destroy(child); 406 } 407 393 408 return rc; 394 409 }
Note:
See TracChangeset
for help on using the changeset viewer.