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