Changes in uspace/lib/usb/src/hc.c [56fd7cf:da2f1c9e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hc.c
r56fd7cf rda2f1c9e 27 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 */ 29 30 29 /** @addtogroup libusb 31 30 * @{ … … 34 33 * General communication with host controller driver (implementation). 35 34 */ 36 37 35 #include <usb/debug.h> 38 36 … … 46 44 { 47 45 assert(connection); 48 49 46 fibril_mutex_lock(&connection->guard); 50 47 if (connection->ref_count == 0) { … … 58 55 } 59 56 } 60 61 57 ++connection->ref_count; 62 58 fibril_mutex_unlock(&connection->guard); 63 59 return EOK; 64 60 } 65 61 /*----------------------------------------------------------------------------*/ 66 62 static int usb_hc_connection_del_ref(usb_hc_connection_t *connection) 67 63 { 68 64 assert(connection); 69 70 65 fibril_mutex_lock(&connection->guard); 71 66 if (connection->ref_count == 0) { 72 67 /* Closing already closed connection... */ 73 assert(connection->hc_sess = =NULL);68 assert(connection->hc_sess = NULL); 74 69 fibril_mutex_unlock(&connection->guard); 75 70 return EOK; 76 71 } 77 78 72 --connection->ref_count; 79 73 int ret = EOK; … … 115 109 */ 116 110 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection, 117 ddf_dev_t *device) 118 { 119 if (device == NULL) 111 const ddf_dev_t *device) 112 { 113 assert(connection); 114 115 if (device == NULL) { 120 116 return EBADMEM; 117 } 121 118 122 119 devman_handle_t hc_handle; 123 const int rc = usb_get_hc_by_handle(d df_dev_get_handle(device), &hc_handle);120 const int rc = usb_get_hc_by_handle(device->handle, &hc_handle); 124 121 if (rc == EOK) { 125 122 usb_hc_connection_initialize(connection, hc_handle); … … 128 125 return rc; 129 126 } 130 127 /*----------------------------------------------------------------------------*/ 131 128 void usb_hc_connection_deinitialize(usb_hc_connection_t *connection) 132 129 { … … 143 140 fibril_mutex_unlock(&connection->guard); 144 141 } 145 142 /*----------------------------------------------------------------------------*/ 146 143 /** Open connection to host controller. 147 144 * … … 153 150 return usb_hc_connection_add_ref(connection); 154 151 } 155 152 /*----------------------------------------------------------------------------*/ 156 153 /** Close connection to the host controller. 157 154 * … … 163 160 return usb_hc_connection_del_ref(connection); 164 161 } 165 162 /*----------------------------------------------------------------------------*/ 166 163 /** Ask host controller for free address assignment. 167 164 * … … 185 182 return ret == EOK ? address : ret; 186 183 } 187 184 /*----------------------------------------------------------------------------*/ 188 185 int usb_hc_bind_address(usb_hc_connection_t * connection, 189 186 usb_address_t address, devman_handle_t handle) … … 197 194 return ret; 198 195 } 199 196 /*----------------------------------------------------------------------------*/ 200 197 /** Get handle of USB device with given address. 201 198 * … … 216 213 return ret; 217 214 } 218 215 /*----------------------------------------------------------------------------*/ 219 216 int usb_hc_release_address(usb_hc_connection_t *connection, 220 217 usb_address_t address) … … 228 225 return ret; 229 226 } 230 227 /*----------------------------------------------------------------------------*/ 231 228 int usb_hc_register_endpoint(usb_hc_connection_t *connection, 232 229 usb_address_t address, usb_endpoint_t endpoint, usb_transfer_type_t type, … … 242 239 return ret; 243 240 } 244 241 /*----------------------------------------------------------------------------*/ 245 242 int usb_hc_unregister_endpoint(usb_hc_connection_t *connection, 246 243 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction) … … 255 252 return ret; 256 253 } 257 254 /*----------------------------------------------------------------------------*/ 258 255 int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address, 259 256 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, … … 269 266 return ret; 270 267 } 271 268 /*----------------------------------------------------------------------------*/ 272 269 int usb_hc_write(usb_hc_connection_t *connection, usb_address_t address, 273 270 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
Note:
See TracChangeset
for help on using the changeset viewer.