Changeset 612af1a0 in mainline
- Timestamp:
- 2011-10-13T10:23:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb422312
- Parents:
- 0d103aef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhcirh/port.c
r0d103aef r612af1a0 44 44 #include "port.h" 45 45 46 #define MAX_ERROR_COUNT 5 47 46 48 static int uhci_port_check(void *port); 47 49 static int uhci_port_reset_enable(void *arg); … … 151 153 assert(instance); 152 154 155 unsigned allowed_failures = MAX_ERROR_COUNT; 156 #define CHECK_RET_FAIL(ret, msg...) \ 157 if (ret != EOK) { \ 158 usb_log_error(msg); \ 159 if (!(allowed_failures-- > 0)) { \ 160 usb_log_fatal( \ 161 "Maximum number of failures reached, " \ 162 "bailing out.\n"); \ 163 return ret; \ 164 } \ 165 continue; \ 166 } else (void)0 167 153 168 while (1) { 154 169 async_usleep(instance->wait_period_usec); … … 165 180 continue; 166 181 167 int ret =168 usb_hc_connection_open(&instance->hc_connection);169 if (ret != EOK) {170 usb_log_error("%s: Failed to connect to HC.",171 instance->id_string);172 continue;173 }174 175 182 usb_log_debug("%s: Connected change detected: %x.\n", 176 183 instance->id_string, port_status); 177 184 185 int ret = usb_hc_connection_open(&instance->hc_connection); 186 CHECK_RET_FAIL(ret, "%s: Failed to connect to HC %s.\n", 187 instance->id_string, str_error(ret)); 188 178 189 /* Remove any old device */ 179 190 if (instance->attached_device.fun) { 180 usb_log_debug2("%s: Removing device.\n",181 instance->id_string);182 191 uhci_port_remove_device(instance); 183 192 } 184 193 185 186 194 if ((port_status & STATUS_CONNECTED) != 0) { 187 /* New device */195 /* New device, this will take care of WC bits */ 188 196 const usb_speed_t speed = 189 197 ((port_status & STATUS_LOW_SPEED) != 0) ? … … 198 206 199 207 ret = usb_hc_connection_close(&instance->hc_connection); 200 if (ret != EOK) { 201 usb_log_error("%s: Failed to disconnect.", 202 instance->id_string); 203 } 208 CHECK_RET_FAIL(ret, "%s: Failed to disconnect from hc: %s.\n", 209 instance->id_string, str_error(ret)); 204 210 } 205 211 return EOK; … … 258 264 usb_log_debug("%s: Detected new device.\n", port->id_string); 259 265 260 int ret, count = 0;266 int ret, count = MAX_ERROR_COUNT; 261 267 do { 262 268 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, … … 264 270 &port->attached_device.address, NULL, NULL, 265 271 &port->attached_device.fun); 266 } while (ret != EOK && ++count < 4);272 } while (ret != EOK && count-- > 0); 267 273 268 274 if (ret != EOK) { … … 273 279 } 274 280 275 usb_log_info(" New device at port %u, address %d (handle %" PRIun ").\n",276 port-> number, port->attached_device.address,281 usb_log_info("%s: New device, address %d (handle %" PRIun ").\n", 282 port->id_string, port->attached_device.address, 277 283 port->attached_device.fun->handle); 278 284 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.