Changeset df949c5 in mainline for uspace/drv/uhci-rhd/port.c
- Timestamp:
- 2011-03-11T17:33:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dd6f59f
- Parents:
- b3bdb68 (diff), bf4cc3e (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
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/port.c
rb3bdb68 rdf949c5 67 67 { 68 68 assert(port); 69 asprintf(&port->id_string, "Port (%p - %d)", port, number); 70 if (port->id_string == NULL) { 71 return ENOMEM; 72 } 69 73 70 74 port->address = address; … … 116 120 assert(instance); 117 121 118 /* Iteration count, for debug purposes only */119 unsigned count = 0;120 121 122 while (1) { 122 123 async_usleep(instance->wait_period_usec); 123 124 124 125 /* read register value */ 125 port_status_t port_status = port_status_read(instance->address); 126 127 /* debug print mutex */ 128 static fibril_mutex_t dbg_mtx = 129 FIBRIL_MUTEX_INITIALIZER(dbg_mtx); 130 fibril_mutex_lock(&dbg_mtx); 131 usb_log_debug2("Port(%p - %d): Status: %#04x. === %u\n", 132 instance->address, instance->number, port_status, count++); 133 // print_port_status(port_status); 134 fibril_mutex_unlock(&dbg_mtx); 126 port_status_t port_status = uhci_port_read_status(instance); 127 128 print_port_status(instance->id_string, port_status); 135 129 136 130 if ((port_status & STATUS_CONNECTED_CHANGED) == 0) 137 131 continue; 138 132 139 usb_log_debug(" Port(%p - %d): Connected change detected: %x.\n",140 instance-> address, instance->number, port_status);133 usb_log_debug("%s: Connected change detected: %x.\n", 134 instance->id_string, port_status); 141 135 142 136 int rc = 143 137 usb_hc_connection_open(&instance->hc_connection); 144 138 if (rc != EOK) { 145 usb_log_error(" Port(%p - %d): Failed to connect to HC.",146 instance-> address, instance->number);139 usb_log_error("%s: Failed to connect to HC.", 140 instance->id_string); 147 141 continue; 148 142 } … … 150 144 /* Remove any old device */ 151 145 if (instance->attached_device) { 152 usb_log_debug2(" Port(%p - %d): Removing device.\n",153 instance-> address, instance->number);146 usb_log_debug2("%s: Removing device.\n", 147 instance->id_string); 154 148 uhci_port_remove_device(instance); 155 149 } … … 163 157 } else { 164 158 /* Write one to WC bits, to ack changes */ 165 port_status_write(instance->address, port_status);166 usb_log_debug(" Port(%p - %d): Change status ACK.\n",167 instance-> address, instance->number);159 uhci_port_write_status(instance, port_status); 160 usb_log_debug("%s: Change status ACK.\n", 161 instance->id_string); 168 162 } 169 163 170 164 rc = usb_hc_connection_close(&instance->hc_connection); 171 165 if (rc != EOK) { 172 usb_log_error(" Port(%p - %d): Failed to disconnect.",173 instance-> address, instance->number);166 usb_log_error("%s: Failed to disconnect.", 167 instance->id_string); 174 168 } 175 169 } … … 187 181 uhci_port_t *port = (uhci_port_t *) arg; 188 182 189 usb_log_debug2(" Port(%p - %d): new_device_enable_port.\n",190 port-> address, port->number);183 usb_log_debug2("%s: new_device_enable_port.\n", 184 port->id_string); 191 185 192 186 /* … … 201 195 */ 202 196 { 203 usb_log_debug("Port(%p - %d): Reset Signal start.\n", 204 port->address, port->number); 205 port_status_t port_status = 206 port_status_read(port->address); 197 usb_log_debug("%s: Reset Signal start.\n", 198 port->id_string); 199 port_status_t port_status = uhci_port_read_status(port); 207 200 port_status |= STATUS_IN_RESET; 208 port_status_write(port->address, port_status);201 uhci_port_write_status(port, port_status); 209 202 async_usleep(10000); 210 port_status = port_status_read(port->address);203 port_status = uhci_port_read_status(port); 211 204 port_status &= ~STATUS_IN_RESET; 212 port_status_write(port->address, port_status);213 usb_log_debug(" Port(%p - %d): Reset Signal stop.\n",214 port-> address, port->number);205 uhci_port_write_status(port, port_status); 206 usb_log_debug("%s: Reset Signal stop.\n", 207 port->id_string); 215 208 } 216 209 … … 233 226 assert(usb_hc_connection_is_opened(&port->hc_connection)); 234 227 235 usb_log_info(" Port(%p-%d): Detected new device.\n",236 port-> address, port->number);228 usb_log_info("%s: Detected new device.\n", 229 port->id_string); 237 230 238 231 usb_address_t dev_addr; … … 242 235 243 236 if (rc != EOK) { 244 usb_log_error(" Port(%p-%d): Failed(%d) to add device: %s.\n",245 port-> address, port->number, rc, str_error(rc));237 usb_log_error("%s: Failed(%d) to add device: %s.\n", 238 port->id_string, rc, str_error(rc)); 246 239 uhci_port_set_enabled(port, false); 247 240 return rc; 248 241 } 249 242 250 usb_log_info(" Port(%p-%d): New device has address %d (handle %zu).\n",251 port-> address, port->number, dev_addr, port->attached_device);243 usb_log_info("%s: New device has address %d (handle %zu).\n", 244 port->id_string, dev_addr, port->attached_device); 252 245 253 246 return EOK; … … 263 256 int uhci_port_remove_device(uhci_port_t *port) 264 257 { 265 usb_log_error(" Port(%p-%d): Don't know how to remove device %#x.\n",266 port-> address, port->number, (unsigned int)port->attached_device);258 usb_log_error("%s: Don't know how to remove device %d.\n", 259 port->id_string, (unsigned int)port->attached_device); 267 260 return EOK; 268 261 } … … 278 271 279 272 /* Read register value */ 280 port_status_t port_status = port_status_read(port->address);273 port_status_t port_status = uhci_port_read_status(port); 281 274 282 275 /* Set enabled bit */ … … 288 281 289 282 /* Write new value. */ 290 port_status_write(port->address, port_status);291 292 usb_log_info(" Port(%p-%d): %sabled port.\n",293 port-> address, port->number, enabled ? "En" : "Dis");283 uhci_port_write_status(port, port_status); 284 285 usb_log_info("%s: %sabled port.\n", 286 port->id_string, enabled ? "En" : "Dis"); 294 287 return EOK; 295 288 }
Note:
See TracChangeset
for help on using the changeset viewer.