Changeset b4b534ac in mainline for uspace/drv/bus/usb/ohci/main.c
- Timestamp:
- 2016-07-22T08:24:47Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/main.c
r5b18137 rb4b534ac 33 33 * Main routines of OHCI driver. 34 34 */ 35 36 #include <assert.h> 35 37 #include <ddf/driver.h> 36 38 #include <errno.h> 39 #include <io/log.h> 37 40 #include <str_error.h> 38 41 39 42 #include <usb/debug.h> 43 #include <usb/host/ddf_helpers.h> 40 44 41 #include " ohci.h"45 #include "hc.h" 42 46 43 47 #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 } 44 95 45 96 /** Initializes a new ddf driver instance of OHCI hcd. … … 52 103 usb_log_debug("ohci_dev_add() called\n"); 53 104 assert(device); 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; 105 return hcd_ddf_add_hc(device, &ohci_hc_driver); 64 106 } 65 107 66 static driver_ops_t ohci_driver_ops = {108 static const driver_ops_t ohci_driver_ops = { 67 109 .dev_add = ohci_dev_add, 68 110 }; 69 111 70 static driver_t ohci_driver = {112 static const driver_t ohci_driver = { 71 113 .name = NAME, 72 114 .driver_ops = &ohci_driver_ops
Note:
See TracChangeset
for help on using the changeset viewer.