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