Changeset e6b9182 in mainline for uspace/drv/bus/usb/ohci/ohci_bus.c
- Timestamp:
- 2017-10-13T08:49:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 741bcdeb
- Parents:
- 0a5833d7
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_bus.c
r0a5833d7 re6b9182 37 37 #include <stdlib.h> 38 38 #include <usb/host/utils/malloc32.h> 39 #include <usb/host/bandwidth.h> 39 40 40 #include "ohci_ endpoint.h"41 #include "ohci_bus.h" 41 42 #include "hc.h" 42 43 … … 46 47 * @param[in] toggle new value of toggle bit 47 48 */ 48 static void ohci_ep_toggle_set( void *ohci_ep, inttoggle)49 static void ohci_ep_toggle_set(endpoint_t *ep, bool toggle) 49 50 { 50 ohci_endpoint_t *instance = ohci_e p;51 ohci_endpoint_t *instance = ohci_endpoint_get(ep); 51 52 assert(instance); 52 53 assert(instance->ed); 54 ep->toggle = toggle; 53 55 ed_toggle_set(instance->ed, toggle); 54 56 } … … 59 61 * @return Current value of toggle bit. 60 62 */ 61 static int ohci_ep_toggle_get(void *ohci_ep)63 static bool ohci_ep_toggle_get(endpoint_t *ep) 62 64 { 63 ohci_endpoint_t *instance = ohci_e p;65 ohci_endpoint_t *instance = ohci_endpoint_get(ep); 64 66 assert(instance); 65 67 assert(instance->ed); … … 68 70 69 71 /** Creates new hcd endpoint representation. 70 *71 * @param[in] ep USBD endpoint structure72 * @return Error code.73 72 */ 74 int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep)73 static endpoint_t *ohci_endpoint_create(bus_t *bus) 75 74 { 76 assert(ep); 75 assert(bus); 76 77 77 ohci_endpoint_t *ohci_ep = malloc(sizeof(ohci_endpoint_t)); 78 78 if (ohci_ep == NULL) 79 return ENOMEM;79 return NULL; 80 80 81 81 ohci_ep->ed = malloc32(sizeof(ed_t)); 82 82 if (ohci_ep->ed == NULL) { 83 83 free(ohci_ep); 84 return ENOMEM;84 return NULL; 85 85 } 86 86 … … 89 89 free32(ohci_ep->ed); 90 90 free(ohci_ep); 91 return ENOMEM;91 return NULL; 92 92 } 93 93 94 94 link_initialize(&ohci_ep->link); 95 ed_init(ohci_ep->ed, ep, ohci_ep->td);96 endpoint_set_hc_data(97 ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set);98 hc_enqueue_endpoint(hcd_get_driver_data(hcd), ep);99 95 return EOK; 100 96 } … … 105 101 * @param[in] ep endpoint structure. 106 102 */ 107 void ohci_endpoint_fini(hcd_t *hcd,endpoint_t *ep)103 static void ohci_endpoint_destroy(endpoint_t *ep) 108 104 { 109 assert(hcd);110 105 assert(ep); 111 106 ohci_endpoint_t *instance = ohci_endpoint_get(ep); 112 hc_dequeue_endpoint(hcd_get_driver_data(hcd), ep); 113 endpoint_clear_hc_data(ep); 114 if (instance) { 115 free32(instance->ed); 116 free32(instance->td); 117 free(instance); 118 } 107 108 free32(instance->ed); 109 free32(instance->td); 110 free(instance); 111 } 112 113 114 static int ohci_register_ep(bus_t *bus_base, endpoint_t *ep) 115 { 116 ohci_bus_t *bus = (ohci_bus_t *) bus_base; 117 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 118 119 const int err = bus->parent_ops.register_endpoint(bus_base, ep); 120 if (err) 121 return err; 122 123 ed_init(ohci_ep->ed, ep, ohci_ep->td); 124 hc_enqueue_endpoint(bus->hc, ep); 125 126 return EOK; 127 } 128 129 static int ohci_release_ep(bus_t *bus_base, endpoint_t *ep) 130 { 131 ohci_bus_t *bus = (ohci_bus_t *) bus_base; 132 assert(bus); 133 assert(ep); 134 135 const int err = bus->parent_ops.release_endpoint(bus_base, ep); 136 if (err) 137 return err; 138 139 hc_dequeue_endpoint(bus->hc, ep); 140 return EOK; 141 142 } 143 144 int ohci_bus_init(ohci_bus_t *bus, hc_t *hc) 145 { 146 assert(hc); 147 assert(bus); 148 149 usb2_bus_init(&bus->base, BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 150 151 bus_ops_t *ops = &bus->base.base.ops; 152 bus->parent_ops = *ops; 153 ops->create_endpoint = ohci_endpoint_create; 154 ops->destroy_endpoint = ohci_endpoint_destroy; 155 ops->endpoint_set_toggle = ohci_ep_toggle_set; 156 ops->endpoint_get_toggle = ohci_ep_toggle_get; 157 158 ops->register_endpoint = ohci_register_ep; 159 ops->release_endpoint = ohci_release_ep; 160 161 return EOK; 119 162 } 120 163
Note:
See TracChangeset
for help on using the changeset viewer.