Changeset 20eaa82 in mainline for uspace/lib/usbhost/src/hcd.c
- Timestamp:
- 2017-10-15T13:44:39Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2770b66
- Parents:
- 867b375
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/hcd.c
r867b375 r20eaa82 45 45 46 46 47 /*[>* Calls ep_add_hook upon endpoint registration.48 * @param ep Endpoint to be registered.49 * @param arg hcd_t in disguise.50 * @return Error code.51 * OH TODO: remove52 <]53 static int register_helper(endpoint_t *ep, void *arg)54 {55 hcd_t *hcd = arg;56 assert(ep);57 assert(hcd);58 if (hcd->ops.ep_add_hook)59 return hcd->ops.ep_add_hook(hcd, ep);60 return EOK;61 }62 63 [>* Calls ep_remove_hook upon endpoint removal.64 * @param ep Endpoint to be unregistered.65 * @param arg hcd_t in disguise.66 * OH TODO: remove67 <]68 static void unregister_helper(endpoint_t *ep, void *arg)69 {70 hcd_t *hcd = arg;71 assert(ep);72 assert(hcd);73 if (hcd->ops.ep_remove_hook)74 hcd->ops.ep_remove_hook(hcd, ep);75 }76 77 [>* Calls ep_remove_hook upon endpoint removal. Prints warning.78 * * @param ep Endpoint to be unregistered.79 * * @param arg hcd_t in disguise.80 * OH TODO: remove81 * <]82 static void unregister_helper_warn(endpoint_t *ep, void *arg)83 {84 assert(ep);85 usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n",86 ep->target.address, ep->target.endpoint, usb_str_direction(ep->direction));87 unregister_helper(ep, arg);88 }89 */90 91 47 /** Initialize hcd_t structure. 92 48 * Initializes device and endpoint managers. Sets data and hook pointer to NULL. … … 112 68 return address; 113 69 } 114 115 int hcd_release_address(hcd_t *hcd, usb_address_t address)116 {117 assert(hcd);118 return bus_release_address(hcd->bus, address);119 // OH TODO removed helper120 }121 122 int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed)123 {124 assert(hcd);125 usb_address_t address = 0;126 return bus_request_address(hcd->bus, &address, true, speed);127 }128 129 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,130 usb_transfer_type_t type, size_t max_packet_size, unsigned packets,131 size_t size, usb_tt_address_t tt)132 {133 assert(hcd);134 135 /* Temporary reference */136 endpoint_t *ep = bus_create_endpoint(hcd->bus);137 if (!ep)138 return ENOMEM;139 140 ep->target = target;141 ep->direction = dir;142 ep->transfer_type = type;143 ep->max_packet_size = max_packet_size;144 ep->packets = packets;145 ep->tt = tt;146 147 ep->bandwidth = bus_count_bw(ep, size);148 149 const int err = bus_register_endpoint(hcd->bus, ep);150 151 /* drop Temporary reference */152 endpoint_del_ref(ep);153 154 return err;155 }156 157 int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir)158 {159 assert(hcd);160 endpoint_t *ep = bus_find_endpoint(hcd->bus, target, dir);161 if (!ep)162 return ENOENT;163 164 return bus_release_endpoint(hcd->bus, ep);165 // OH TODO removed helper166 }167 168 70 169 71 typedef struct {
Note:
See TracChangeset
for help on using the changeset viewer.