Changeset 50ba203 in mainline for uspace/drv/uhci-rhd/port.c
- Timestamp:
- 2011-02-20T15:46:48Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6bb83c7
- Parents:
- d81ef61c (diff), 0c00dac (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
uspace/drv/uhci-rhd/port.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/port.c
rd81ef61c r50ba203 33 33 */ 34 34 #include <errno.h> 35 #include <str_error.h> 35 36 36 37 #include <usb/usb.h> /* usb_address_t */ 37 #include <usb/usbdrv.h> /* usb_drv_* */ 38 #include <usb/usbdevice.h> 39 #include <usb/hub.h> 40 #include <usb/request.h> 38 41 #include <usb/debug.h> 42 #include <usb/recognise.h> 39 43 40 44 #include "port.h" … … 56 60 port->attached_device = 0; 57 61 port->rh = rh; 58 port->hc_phone = parent_phone; 62 int rc = usb_hc_connection_initialize_from_device( 63 &port->hc_connection, rh); 64 if (rc != EOK) { 65 usb_log_error("Failed to initialize connection to HC."); 66 return rc; 67 } 59 68 60 69 port->checker = fibril_create(uhci_port_check, port); … … 96 105 97 106 if (port_status & STATUS_CONNECTED_CHANGED) { 107 int rc = usb_hc_connection_open( 108 &port_instance->hc_connection); 109 if (rc != EOK) { 110 usb_log_error("Failed to connect to HC."); 111 goto next; 112 } 113 98 114 if (port_status & STATUS_CONNECTED) { 99 115 /* new device */ … … 102 118 uhci_port_remove_device(port_instance); 103 119 } 120 121 rc = usb_hc_connection_close( 122 &port_instance->hc_connection); 123 if (rc != EOK) { 124 usb_log_error("Failed to disconnect from HC."); 125 goto next; 126 } 104 127 } 128 next: 105 129 async_usleep(port_instance->wait_period_usec); 106 130 } … … 111 135 { 112 136 assert(port); 113 assert( port->hc_phone);137 assert(usb_hc_connection_is_opened(&port->hc_connection)); 114 138 115 139 usb_log_info("Adding new device on port %d.\n", port->number); 116 140 117 141 /* get address of the future device */ 118 const usb_address_t usb_address = usb_drv_request_address(port->hc_phone); 142 const usb_address_t usb_address = usb_hc_request_address( 143 &port->hc_connection, true); 119 144 120 145 if (usb_address <= 0) { … … 126 151 127 152 /* get default address */ 128 int ret = usb_ drv_reserve_default_address(port->hc_phone);153 int ret = usb_hc_reserve_default_address(&port->hc_connection, true); 129 154 if (ret != EOK) { 130 155 usb_log_error("Failed to reserve default address on port %d.\n", 131 156 port->number); 132 int ret2 = 133 usb_drv_release_address(port->hc_phone,usb_address);157 int ret2 = usb_hc_unregister_device(&port->hc_connection, 158 usb_address); 134 159 if (ret2 != EOK) { 135 160 usb_log_fatal("Failed to return requested address on port %d.\n", … … 172 197 } 173 198 174 /* assign address to device */ 175 ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address); 199 /* 200 * Initialize connection to the device. 201 */ 202 /* FIXME: check for errors. */ 203 usb_device_connection_t new_dev_connection; 204 usb_endpoint_pipe_t new_dev_ctrl_pipe; 205 usb_device_connection_initialize_on_default_address( 206 &new_dev_connection, &port->hc_connection); 207 usb_endpoint_pipe_initialize_default_control(&new_dev_ctrl_pipe, 208 &new_dev_connection); 209 210 /* 211 * Assign new address to the device. This function updates 212 * the backing connection to still point to the same device. 213 */ 214 /* FIXME: check for errors. */ 215 usb_endpoint_pipe_start_session(&new_dev_ctrl_pipe); 216 ret = usb_request_set_address(&new_dev_ctrl_pipe, usb_address); 217 usb_endpoint_pipe_end_session(&new_dev_ctrl_pipe); 176 218 177 219 if (ret != EOK) { /* address assigning went wrong */ 178 220 usb_log_error("Failed(%d) to assign address to the device.\n", ret); 179 221 uhci_port_set_enabled(port, false); 180 int release = usb_ drv_release_default_address(port->hc_phone);222 int release = usb_hc_release_default_address(&port->hc_connection); 181 223 if (release != EOK) { 182 224 usb_log_error("Failed to release default address on port %d.\n", … … 192 234 193 235 /* release default address */ 194 ret = usb_ drv_release_default_address(port->hc_phone);236 ret = usb_hc_release_default_address(&port->hc_connection); 195 237 if (ret != EOK) { 196 238 usb_log_error("Failed to release default address on port %d.\n", … … 204 246 assert(port->attached_device == 0); 205 247 206 ret = usb_d rv_register_child_in_devman(port->hc_phone, port->rh,207 usb_address, &port->attached_device);248 ret = usb_device_register_child_in_devman(new_dev_connection.address, 249 new_dev_connection.hc_handle, port->rh, &port->attached_device); 208 250 209 251 if (ret != EOK) { /* something went wrong */ … … 215 257 port->number, usb_address, port->attached_device); 216 258 217 ret = 218 usb_drv_bind_address(port->hc_phone, usb_address, port->attached_device); 259 /* 260 * Register the device in the host controller. 261 */ 262 usb_hc_attached_device_t new_device = { 263 .address = new_dev_connection.address, 264 .handle = port->attached_device 265 }; 266 267 ret = usb_hc_register_device(&port->hc_connection, &new_device); 219 268 // TODO: proper error check here 220 269 assert(ret == EOK);
Note:
See TracChangeset
for help on using the changeset viewer.
