Changeset 2179cf95 in mainline for uspace/lib/usbdev/src/recognise.c
- Timestamp:
- 2011-11-04T21:55:48Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37e4025
- Parents:
- 3238506
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/recognise.c
r3238506 r2179cf95 316 316 match_id_list_t *matches) 317 317 { 318 assert(ctrl_pipe); 318 319 int rc; 319 320 /* … … 338 339 /** Probe for device kind and register it in devman. 339 340 * 340 * @param[in] address Address of the (unknown) attached device. 341 * @param[in] hc_handle Handle of the host controller. 341 * @param[in] ctrl_pipe Control pipe to the device. 342 342 * @param[in] parent Parent device. 343 343 * @param[in] dev_ops Child device ops. Default child_ops will be used if NULL. … … 348 348 * @return Error code. 349 349 */ 350 int usb_device_register_child_in_devman(usb_ address_t address,351 d evman_handle_t hc_handle, ddf_dev_t *parent,352 ddf_ dev_ops_t *dev_ops, void *dev_data, ddf_fun_t **child_fun)350 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 351 ddf_dev_t *parent, ddf_dev_ops_t *dev_ops, void *dev_data, 352 ddf_fun_t **child_fun) 353 353 { 354 if (child_fun == NULL )354 if (child_fun == NULL || ctrl_pipe == NULL) 355 355 return EINVAL; 356 356 … … 360 360 } 361 361 362 size_t this_device_name_index;363 364 362 fibril_mutex_lock(&device_name_index_mutex); 365 this_device_name_index = device_name_index; 366 device_name_index++; 363 const size_t this_device_name_index = device_name_index++; 367 364 fibril_mutex_unlock(&device_name_index_mutex); 368 365 369 366 ddf_fun_t *child = NULL; 370 char *child_name = NULL;371 367 int rc; 372 usb_device_connection_t dev_connection;373 usb_pipe_t ctrl_pipe;374 375 rc = usb_device_connection_initialize(376 &dev_connection, hc_handle, address);377 if (rc != EOK) {378 goto failure;379 }380 381 rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_connection);382 if (rc != EOK) {383 goto failure;384 }385 rc = usb_pipe_probe_default_control(&ctrl_pipe);386 if (rc != EOK) {387 goto failure;388 }389 368 390 369 /* … … 392 371 * naming etc., something more descriptive could be created. 393 372 */ 394 rc = asprintf(&child_name, "usb%02zu_a%d", 395 this_device_name_index, address); 373 char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */ 374 rc = snprintf(child_name, sizeof(child_name), 375 "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address); 396 376 if (rc < 0) { 397 377 goto failure; … … 399 379 400 380 child = ddf_fun_create(parent, fun_inner, child_name); 401 free(child_name);402 381 if (child == NULL) { 403 382 rc = ENOMEM; … … 421 400 goto failure; 422 401 } 423 new_device->address = address;402 new_device->address = ctrl_pipe->wire->address; 424 403 new_device->fun = child; 425 404 } 426 405 427 406 428 rc = usb_device_create_match_ids( &ctrl_pipe, &child->match_ids);407 rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids); 429 408 if (rc != EOK) { 430 409 goto failure;
Note:
See TracChangeset
for help on using the changeset viewer.