Changes in uspace/lib/usbdev/src/devdrv.c [70452dd4:fb422312] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/devdrv.c
r70452dd4 rfb422312 41 41 #include <assert.h> 42 42 43 static int generic_add_device(ddf_dev_t *); 43 static int generic_device_add(ddf_dev_t *); 44 static int generic_device_remove(ddf_dev_t *); 45 static int generic_device_gone(ddf_dev_t *); 44 46 45 47 static driver_ops_t generic_driver_ops = { 46 .add_device = generic_add_device 48 .add_device = generic_device_add, 49 .dev_remove = generic_device_remove, 50 .dev_gone = generic_device_gone, 47 51 }; 48 52 static driver_t generic_driver = { … … 123 127 return EOK; 124 128 } 125 126 /** Callback when new device is supposed to be controlled by this driver.127 * 128 * This callback is a wrapper for USB specific version of @c add_device.129 /*----------------------------------------------------------------------------*/ 130 /** Callback when a new device is supposed to be controlled by this driver. 131 * 132 * This callback is a wrapper for USB specific version of @c device_add. 129 133 * 130 134 * @param gen_dev Device structure as prepared by DDF. 131 135 * @return Error code. 132 136 */ 133 int generic_ add_device(ddf_dev_t *gen_dev)137 int generic_device_add(ddf_dev_t *gen_dev) 134 138 { 135 139 assert(driver); 136 140 assert(driver->ops); 137 assert(driver->ops-> add_device);141 assert(driver->ops->device_add); 138 142 139 143 int rc; … … 147 151 return rc; 148 152 } 149 150 return driver->ops->add_device(dev); 151 } 152 153 gen_dev->driver_data = dev; 154 155 return driver->ops->device_add(dev); 156 } 157 /*----------------------------------------------------------------------------*/ 158 /** Callback when a device is supposed to be removed from the system. 159 * 160 * This callback is a wrapper for USB specific version of @c device_remove. 161 * 162 * @param gen_dev Device structure as prepared by DDF. 163 * @return Error code. 164 */ 165 int generic_device_remove(ddf_dev_t *gen_dev) 166 { 167 assert(driver); 168 assert(driver->ops); 169 if (driver->ops->device_rem == NULL) 170 return ENOTSUP; 171 /* Just tell the driver to stop whatever it is doing, keep structures */ 172 return driver->ops->device_rem(gen_dev->driver_data); 173 } 174 /*----------------------------------------------------------------------------*/ 175 /** Callback when a device was removed from the system. 176 * 177 * This callback is a wrapper for USB specific version of @c device_gone. 178 * 179 * @param gen_dev Device structure as prepared by DDF. 180 * @return Error code. 181 */ 182 int generic_device_gone(ddf_dev_t *gen_dev) 183 { 184 assert(driver); 185 assert(driver->ops); 186 if (driver->ops->device_gone == NULL) 187 return ENOTSUP; 188 const int ret = driver->ops->device_gone(gen_dev->driver_data); 189 if (ret == EOK) 190 usb_device_destroy(gen_dev->driver_data); 191 192 return ret; 193 } 194 /*----------------------------------------------------------------------------*/ 153 195 /** Destroy existing pipes of a USB device. 154 196 * … … 275 317 * @return Error code. 276 318 */ 277 int usb_device_create_pipes( ddf_dev_t *dev, usb_device_connection_t *wire,319 int usb_device_create_pipes(const ddf_dev_t *dev, usb_device_connection_t *wire, 278 320 usb_endpoint_description_t **endpoints, 279 321 uint8_t *config_descr, size_t config_descr_size, … … 349 391 } 350 392 351 usb_hc_connection_close(&hc_conn); 393 if (usb_hc_connection_close(&hc_conn) != EOK) 394 usb_log_warning("usb_device_create_pipes(): " 395 "Failed to close connection.\n"); 352 396 353 397 *pipes_ptr = pipes; … … 371 415 } 372 416 373 usb_hc_connection_close(&hc_conn); 417 if (usb_hc_connection_close(&hc_conn) != EOK) 418 usb_log_warning("usb_device_create_pipes(): " 419 "Failed to close connection.\n"); 374 420 375 421 /* … … 395 441 * @param[in] pipes_count Number of endpoints. 396 442 */ 397 int usb_device_destroy_pipes( ddf_dev_t *dev,443 int usb_device_destroy_pipes(const ddf_dev_t *dev, 398 444 usb_endpoint_mapping_t *pipes, size_t pipes_count) 399 445 { … … 426 472 } 427 473 428 usb_hc_connection_close(&hc_conn); 474 if (usb_hc_connection_close(&hc_conn) != EOK) 475 usb_log_warning("usb_device_destroy_pipes(): " 476 "Failed to close connection.\n"); 429 477 430 478 free(pipes); … … 545 593 /* Ignore errors and hope for the best. */ 546 594 usb_device_destroy_pipes(dev->ddf_dev, dev->pipes, dev->pipes_count); 547 if (dev->descriptors.configuration != NULL) { 548 free(dev->descriptors.configuration); 549 } 595 free(dev->descriptors.configuration); 550 596 551 597 if (dev->alternate_interfaces != NULL) { 552 if (dev->alternate_interfaces->alternatives != NULL) { 553 free(dev->alternate_interfaces->alternatives); 554 } 555 free(dev->alternate_interfaces); 556 } 598 free(dev->alternate_interfaces->alternatives); 599 } 600 free(dev->alternate_interfaces); 557 601 558 602 free(dev);
Note:
See TracChangeset
for help on using the changeset viewer.