Changeset 6fe7683 in mainline
- Timestamp:
- 2013-08-02T14:13:01Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1298a8fa
- Parents:
- 8e4219ab
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
r8e4219ab r6fe7683 43 43 #include <usb/dev/recognise.h> 44 44 #include "usbmid.h" 45 /** Get host controller handle by calling the parent usb_device_t. 45 46 /** Get USB device handle by calling the parent usb_device_t. 46 47 * 47 48 * @param[in] fun Device function the operation is running on. 48 * @param[out] handle Storage for the host controllerhandle.49 * @param[out] handle Device handle. 49 50 * @return Error code. 50 51 */ 51 static int usb_iface_device_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)52 {53 assert(handle);54 assert(fun);55 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));56 assert(usb_dev);57 *handle = usb_device_hc_handle(usb_dev);58 return EOK;59 }60 61 52 static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle) 62 53 { … … 64 55 assert(handle); 65 56 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 66 assert(usb_dev);67 57 *handle = usb_device_get_devman_handle(usb_dev); 68 58 return EOK; 69 59 } 70 60 71 /** Get USB device address by calling the parent usb_device_t. 72 * 73 * @param[in] fun Device function the operation is running on. 74 * @param[in] handle Devman handle of USB device we want address of. 75 * @param[out] address Storage for USB address of device with handle @p handle. 76 * @return Error code. 77 */ 78 static int usb_iface_device_address(ddf_fun_t *fun, usb_address_t *address) 79 { 80 assert(address); 81 assert(fun); 82 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 83 assert(usb_dev); 84 *address = usb_device_address(usb_dev); 85 return EOK; 86 } 87 88 /** Callback for DDF USB interface. */ 89 static int usb_iface_iface(ddf_fun_t *fun, int *iface_no) 61 /** Callback for DDF USB get interface. */ 62 static int usb_iface_iface_no(ddf_fun_t *fun, int *iface_no) 90 63 { 91 64 usbmid_interface_t *iface = ddf_fun_data_get(fun); 92 65 assert(iface); 93 66 94 if (iface_no != NULL) {67 if (iface_no) 95 68 *iface_no = iface->interface_no; 96 }97 69 98 70 return EOK; 99 71 } 100 72 101 static int usb_iface_register_endpoint(ddf_fun_t *fun, usb_endpoint_t ep, 102 usb_transfer_type_t type, usb_direction_t dir, size_t mps, unsigned inter) 103 { 104 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 105 assert(usb_dev); 106 async_exch_t *exch = usb_device_bus_exchange_begin(usb_dev); 107 if (!exch) 108 return ENOMEM; 109 const int ret = usb_register_endpoint(exch, ep, type, dir, mps, inter); 110 usb_device_bus_exchange_end(exch); 111 return ret; 112 } 113 114 static int usb_iface_unregister_endpoint(ddf_fun_t *fun, usb_endpoint_t ep, 115 usb_direction_t dir) 116 { 117 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 118 assert(usb_dev); 119 async_exch_t *exch = usb_device_bus_exchange_begin(usb_dev); 120 if (!exch) 121 return ENOMEM; 122 const int ret = usb_unregister_endpoint(exch, ep, dir); 123 usb_device_bus_exchange_end(exch); 124 return ret; 125 } 126 127 /** DDF interface of the child - interface function. */ 73 /** DDF interface of the child - USB functions. */ 128 74 static usb_iface_t child_usb_iface = { 129 .get_hc_handle = usb_iface_device_hc_handle,130 .get_my_address = usb_iface_device_address,131 75 .get_device_handle = usb_iface_device_handle, 132 .get_my_interface = usb_iface_iface, 133 .register_endpoint = usb_iface_register_endpoint, 134 .unregister_endpoint = usb_iface_unregister_endpoint, 76 .get_my_interface = usb_iface_iface_no, 135 77 }; 136 78
Note:
See TracChangeset
for help on using the changeset viewer.