Changeset 0816c2e in mainline
- Timestamp:
- 2013-01-04T11:22:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b4c1c95
- Parents:
- 17bbb28
- Location:
- uspace/lib/usbhost
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/hcd.h
r17bbb28 r0816c2e 82 82 } 83 83 84 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir, 85 usb_transfer_type_t type, size_t max_packet_size, size_t size); 86 87 int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir); 88 84 89 int hcd_send_batch(hcd_t *hcd, usb_target_t target, usb_direction_t direction, 85 90 void *data, size_t size, uint64_t setup_data, -
uspace/lib/usbhost/src/hcd.c
r17bbb28 r0816c2e 62 62 hcd->ep_remove_hook = NULL; 63 63 } 64 65 /** Calls ep_add_hook upon endpoint registration. 66 * @param ep Endpoint to be registered. 67 * @param arg hcd_t in disguise. 68 * @return Error code. 69 */ 70 static int register_helper(endpoint_t *ep, void *arg) 71 { 72 hcd_t *hcd = arg; 73 assert(ep); 74 assert(hcd); 75 if (hcd->ep_add_hook) 76 return hcd->ep_add_hook(hcd, ep); 77 return EOK; 78 } 79 80 81 /** Calls ep_remove_hook upon endpoint removal. 82 * @param ep Endpoint to be unregistered. 83 * @param arg hcd_t in disguise. 84 */ 85 static void unregister_helper(endpoint_t *ep, void *arg) 86 { 87 hcd_t *hcd = arg; 88 assert(ep); 89 assert(hcd); 90 if (hcd->ep_remove_hook) 91 hcd->ep_remove_hook(hcd, ep); 92 } 93 94 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir, 95 usb_transfer_type_t type, size_t max_packet_size, size_t size) 96 { 97 assert(hcd); 98 usb_speed_t speed = USB_SPEED_MAX; 99 const int ret = usb_device_manager_get_info_by_address( 100 &hcd->dev_manager, target.address, NULL, &speed); 101 if (ret != EOK) { 102 return ret; 103 } 104 return usb_endpoint_manager_add_ep(&hcd->ep_manager, target.address, 105 target.endpoint, dir, type, speed, max_packet_size, size, 106 register_helper, hcd); 107 } 108 109 int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir) 110 { 111 assert(hcd); 112 return usb_endpoint_manager_remove_ep(&hcd->ep_manager, target.address, 113 target.endpoint, dir, unregister_helper, hcd); 114 } 115 64 116 65 117 typedef struct { -
uspace/lib/usbhost/src/iface.c
r17bbb28 r0816c2e 42 42 #include "ddf_helpers.h" 43 43 44 /** Calls ep_add_hook upon endpoint registration.45 * @param ep Endpoint to be registered.46 * @param arg hcd_t in disguise.47 * @return Error code.48 */49 static int register_helper(endpoint_t *ep, void *arg)50 {51 hcd_t *hcd = arg;52 assert(ep);53 assert(hcd);54 if (hcd->ep_add_hook)55 return hcd->ep_add_hook(hcd, ep);56 return EOK;57 }58 59 /** Calls ep_remove_hook upon endpoint removal.60 * @param ep Endpoint to be unregistered.61 * @param arg hcd_t in disguise.62 */63 static void unregister_helper(endpoint_t *ep, void *arg)64 {65 hcd_t *hcd = arg;66 assert(ep);67 assert(hcd);68 if (hcd->ep_remove_hook)69 hcd->ep_remove_hook(hcd, ep);70 }71 72 44 /** Calls ep_remove_hook upon endpoint removal. Prints warning. 73 45 * @param ep Endpoint to be unregistered. … … 181 153 assert(hcd); 182 154 const size_t size = max_packet_size; 183 usb_speed_t speed = USB_SPEED_MAX; 184 const int ret = usb_device_manager_get_info_by_address( 185 &hcd->dev_manager, address, NULL, &speed); 186 if (ret != EOK) { 187 return ret; 188 } 189 190 usb_log_debug("Register endpoint %d:%d %s-%s %s %zuB %ums.\n", 155 const usb_target_t target = {{.address = address, .endpoint = endpoint}}; 156 157 usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n", 191 158 address, endpoint, usb_str_transfer_type(transfer_type), 192 usb_str_direction(direction), usb_str_speed(speed), 193 max_packet_size, interval); 194 195 return usb_endpoint_manager_add_ep(&hcd->ep_manager, address, endpoint, 196 direction, transfer_type, speed, max_packet_size, size, 197 register_helper, hcd); 159 usb_str_direction(direction), max_packet_size, interval); 160 161 return hcd_add_ep(hcd, target, direction, transfer_type, 162 max_packet_size, size); 198 163 } 199 164 … … 212 177 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 213 178 assert(hcd); 179 const usb_target_t target = {{.address = address, .endpoint = endpoint}}; 214 180 usb_log_debug("Unregister endpoint %d:%d %s.\n", 215 181 address, endpoint, usb_str_direction(direction)); 216 return usb_endpoint_manager_remove_ep(&hcd->ep_manager, address, 217 endpoint, direction, unregister_helper, hcd); 182 return hcd_remove_ep(hcd, target, direction); 218 183 } 219 184
Note:
See TracChangeset
for help on using the changeset viewer.