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