Changes in uspace/drv/bus/usb/ohci/main.c [55346870:920d0fc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/main.c
r55346870 r920d0fc 33 33 * Main routines of OHCI driver. 34 34 */ 35 36 #include <assert.h>37 35 #include <ddf/driver.h> 38 36 #include <errno.h> 39 #include <io/log.h>40 37 #include <str_error.h> 41 38 42 39 #include <usb/debug.h> 43 #include <usb/host/ddf_helpers.h>44 40 45 #include " hc.h"41 #include "ohci.h" 46 42 47 43 #define NAME "ohci" 48 static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);49 static void ohci_driver_fini(hcd_t *);50 51 static const ddf_hc_driver_t ohci_hc_driver = {52 .hc_speed = USB_SPEED_FULL,53 .irq_code_gen = ohci_hc_gen_irq_code,54 .init = ohci_driver_init,55 .fini = ohci_driver_fini,56 .name = "OHCI",57 .ops = {58 .schedule = ohci_hc_schedule,59 .ep_add_hook = ohci_endpoint_init,60 .ep_remove_hook = ohci_endpoint_fini,61 .irq_hook = ohci_hc_interrupt,62 .status_hook = ohci_hc_status,63 },64 };65 66 67 static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)68 {69 assert(hcd);70 assert(hcd_get_driver_data(hcd) == NULL);71 72 hc_t *instance = malloc(sizeof(hc_t));73 if (!instance)74 return ENOMEM;75 76 const int ret = hc_init(instance, res, irq);77 if (ret == EOK) {78 hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops);79 } else {80 free(instance);81 }82 return ret;83 }84 85 static void ohci_driver_fini(hcd_t *hcd)86 {87 assert(hcd);88 hc_t *hc = hcd_get_driver_data(hcd);89 if (hc)90 hc_fini(hc);91 92 hcd_set_implementation(hcd, NULL, NULL);93 free(hc);94 }95 44 96 45 /** Initializes a new ddf driver instance of OHCI hcd. … … 103 52 usb_log_debug("ohci_dev_add() called\n"); 104 53 assert(device); 105 return hcd_ddf_add_hc(device, &ohci_hc_driver); 54 55 int ret = device_setup_ohci(device); 56 if (ret != EOK) { 57 usb_log_error("Failed to initialize OHCI driver: %s.\n", 58 str_error(ret)); 59 return ret; 60 } 61 usb_log_info("Controlling new OHCI device '%s'.\n", ddf_dev_get_name(device)); 62 63 return EOK; 106 64 } 107 65 108 static constdriver_ops_t ohci_driver_ops = {66 static driver_ops_t ohci_driver_ops = { 109 67 .dev_add = ohci_dev_add, 110 68 }; 111 69 112 static constdriver_t ohci_driver = {70 static driver_t ohci_driver = { 113 71 .name = NAME, 114 72 .driver_ops = &ohci_driver_ops
Note:
See TracChangeset
for help on using the changeset viewer.