Changeset ffa96c2 in mainline
- Timestamp:
- 2014-07-25T17:52:58Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a861ccb3
- Parents:
- b5111c46
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhcirh/port.c
rb5111c46 rffa96c2 269 269 int ret, count = MAX_ERROR_COUNT; 270 270 do { 271 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 271 port->attached_device.fun = ddf_fun_create(port->rh, fun_inner, 272 NULL); 273 if (port->attached_device.fun == NULL) { 274 ret = ENOMEM; 275 continue; 276 } 277 278 ret = usb_hc_new_device_wrapper(port->rh, 279 port->attached_device.fun, 280 &port->hc_connection, 272 281 speed, uhci_port_reset_enable, port, 273 &port->attached_device.address, NULL, NULL, 274 &port->attached_device.fun); 282 &port->attached_device.address, NULL); 283 284 if (ret != EOK) { 285 ddf_fun_destroy(port->attached_device.fun); 286 port->attached_device.fun = NULL; 287 } 288 275 289 } while (ret != EOK && count-- > 0); 276 290 -
uspace/drv/bus/usb/usbhub/port.c
rb5111c46 rffa96c2 424 424 ddf_fun_t *child_fun; 425 425 426 child_fun = ddf_fun_create(data->hub->usb_device->ddf_dev, 427 fun_inner, NULL); 428 if (child_fun == NULL) 429 return ENOMEM; 430 426 431 const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev, 427 &data->hub->usb_device->hc_conn, data->speed, enable_port_callback,428 data->port, &new_address, NULL, NULL, &child_fun);432 child_fun, &data->hub->usb_device->hc_conn, data->speed, 433 enable_port_callback, data->port, &new_address, NULL); 429 434 430 435 if (rc == EOK) { … … 440 445 ddf_fun_get_handle(child_fun)); 441 446 } else { 447 ddf_fun_destroy(child_fun); 442 448 usb_log_error("Failed registering device on port %zu: %s.\n", 443 449 data->port->port_number, str_error(rc)); -
uspace/drv/bus/usb/vhc/hub.c
rb5111c46 rffa96c2 114 114 115 115 ddf_fun_t *hub_dev; 116 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL, 117 pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev); 116 117 hub_dev = ddf_fun_create(ddf_fun_get_dev(hc_dev), fun_inner, NULL); 118 if (hub_dev == NULL) { 119 rc = ENOMEM; 120 usb_log_fatal("Failed to create root hub: %s.\n", 121 str_error(rc)); 122 return rc; 123 } 124 125 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), hub_dev, 126 &hc_conn, USB_SPEED_FULL, pretend_port_rest, NULL, NULL, &rh_ops); 118 127 if (rc != EOK) { 119 128 usb_log_fatal("Failed to create root hub: %s.\n", 120 129 str_error(rc)); 130 ddf_fun_destroy(hub_dev); 121 131 } 122 132 -
uspace/lib/usbdev/include/usb/dev/hub.h
rb5111c46 rffa96c2 44 44 #include <usb/hc.h> 45 45 46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,47 int (*)(void *), void *, usb_address_t *, ddf_dev_ops_t *, void *,48 ddf_fun_t **);46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, ddf_fun_t *, 47 usb_hc_connection_t *, usb_speed_t, int (*)(void *), void *, 48 usb_address_t *, ddf_dev_ops_t *); 49 49 50 50 /** Info about device attached to host controller. -
uspace/lib/usbdev/include/usb/dev/recognise.h
rb5111c46 rffa96c2 52 52 53 53 extern int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 54 ddf_dev_t *, ddf_ dev_ops_t *, void *, ddf_fun_t **);54 ddf_dev_t *, ddf_fun_t *, ddf_dev_ops_t *); 55 55 56 56 #endif -
uspace/lib/usbdev/src/hub.c
rb5111c46 rffa96c2 155 155 * request or requests for descriptors when creating match ids). 156 156 */ 157 int usb_hc_new_device_wrapper(ddf_dev_t *parent, 157 int usb_hc_new_device_wrapper(ddf_dev_t *parent, ddf_fun_t *fun, 158 158 usb_hc_connection_t *hc_conn, usb_speed_t dev_speed, 159 159 int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address, 160 ddf_dev_ops_t *dev_ops , void *new_dev_data, ddf_fun_t **new_fun)160 ddf_dev_ops_t *dev_ops) 161 161 { 162 if ( (new_fun == NULL) || (hc_conn == NULL))162 if (hc_conn == NULL) 163 163 return EINVAL; 164 164 … … 271 271 /* Register the device with devman. */ 272 272 /* FIXME: create device_register that will get opened ctrl pipe. */ 273 ddf_fun_t *child_fun;274 273 rc = usb_device_register_child_in_devman(&ctrl_pipe, 275 parent, dev_ops, new_dev_data, &child_fun);274 parent, fun, dev_ops); 276 275 if (rc != EOK) { 277 276 goto leave_release_free_address; … … 280 279 const usb_hub_attached_device_t new_device = { 281 280 .address = dev_addr, 282 .fun = child_fun,281 .fun = fun, 283 282 }; 284 283 … … 288 287 if (rc != EOK) { 289 288 /* The child function is already created. */ 290 ddf_fun_destroy(child_fun);291 289 rc = EDESTADDRREQ; 292 290 goto leave_release_free_address; … … 296 294 *assigned_address = dev_addr; 297 295 } 298 299 *new_fun = child_fun;300 296 301 297 rc = EOK; -
uspace/lib/usbdev/src/recognise.c
rb5111c46 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 … … 384 375 385 376 list_foreach(match_ids.ids, link, match_id_t, match_id) { 386 rc = ddf_fun_add_match_id( child, match_id->id, match_id->score);377 rc = ddf_fun_add_match_id(fun, match_id->id, match_id->score); 387 378 if (rc != EOK) { 388 379 clean_match_ids(&match_ids); … … 393 384 clean_match_ids(&match_ids); 394 385 395 rc = ddf_fun_bind( child);386 rc = ddf_fun_bind(fun); 396 387 if (rc != EOK) 397 388 goto failure; 398 389 399 *child_fun = child;400 390 return EOK; 401 391 402 392 failure: 403 if (child != NULL) {404 /* This takes care of match_id deallocation as well. */405 ddf_fun_destroy(child);406 }407 408 393 return rc; 409 394 }
Note:
See TracChangeset
for help on using the changeset viewer.