Changeset aff1880 in mainline for uspace/drv/bus/usb/usbhub/ports.c
- Timestamp:
- 2011-09-23T12:59:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c5abf9
- Parents:
- 48a31be
- File:
-
- 1 edited
-
uspace/drv/bus/usb/usbhub/ports.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/ports.c
r48a31be raff1880 55 55 56 56 static void usb_hub_removed_device(usb_hub_info_t *hub, size_t port); 57 static void usb_hub_port_reset_completed( usb_hub_info_t *hub,58 uint16_t port, uint32_t status);57 static void usb_hub_port_reset_completed(const usb_hub_info_t *hub, 58 size_t port, usb_port_status_t status); 59 59 static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port, 60 60 usb_port_status_t *status); … … 63 63 static int create_add_device_fibril(usb_hub_info_t *hub, size_t port, 64 64 usb_speed_t speed); 65 66 /** 67 * Clear feature on hub port. 68 * 69 * @param hc Host controller telephone 70 * @param address Hub address 71 * @param port_index Port 72 * @param feature Feature selector 73 * @return Operation result 74 */ 75 int usb_hub_clear_port_feature(usb_pipe_t *pipe, 76 int port_index, usb_hub_class_feature_t feature) 77 { 78 usb_device_request_setup_packet_t clear_request = { 79 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE, 80 .request = USB_DEVREQ_CLEAR_FEATURE, 81 .value = feature, 82 .index = port_index, 83 .length = 0, 84 }; 85 return usb_pipe_control_write(pipe, &clear_request, 86 sizeof(clear_request), NULL, 0); 87 } 88 /*----------------------------------------------------------------------------*/ 89 /** 90 * Clear feature on hub port. 91 * 92 * @param hc Host controller telephone 93 * @param address Hub address 94 * @param port_index Port 95 * @param feature Feature selector 96 * @return Operation result 97 */ 98 int usb_hub_set_port_feature(usb_pipe_t *pipe, 99 int port_index, usb_hub_class_feature_t feature) 100 { 101 102 usb_device_request_setup_packet_t clear_request = { 103 .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE, 104 .request = USB_DEVREQ_SET_FEATURE, 105 .index = port_index, 106 .value = feature, 107 .length = 0, 108 }; 109 return usb_pipe_control_write(pipe, &clear_request, 110 sizeof(clear_request), NULL, 0); 111 } 65 112 66 113 /** … … 160 207 static void usb_hub_removed_device(usb_hub_info_t *hub, size_t port) 161 208 { 162 163 209 /** \TODO remove device from device manager - not yet implemented in 164 210 * devide manager 165 211 */ 166 167 //close address168 169 212 usb_hub_port_t *the_port = hub->ports + port; 170 213 … … 204 247 * @param status 205 248 */ 206 static void usb_hub_port_reset_completed(usb_hub_info_t *hub, 207 uint16_t port, uint32_t status) 208 { 209 usb_log_debug("Port %zu reset complete.\n", (size_t) port); 210 if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) { 211 /* Finalize device adding. */ 212 usb_hub_port_t *the_port = hub->ports + port; 213 fibril_mutex_lock(&the_port->reset_mutex); 214 the_port->reset_completed = true; 215 the_port->reset_okay = true; 216 fibril_condvar_broadcast(&the_port->reset_cv); 217 fibril_mutex_unlock(&the_port->reset_mutex); 249 static void usb_hub_port_reset_completed(const usb_hub_info_t *hub, 250 size_t port, usb_port_status_t status) 251 { 252 usb_hub_port_t *the_port = hub->ports + port; 253 fibril_mutex_lock(&the_port->reset_mutex); 254 /* Finalize device adding. */ 255 the_port->reset_completed = true; 256 the_port->reset_okay = (status & USB_HUB_PORT_STATUS_ENABLED) != 0; 257 258 if (the_port->reset_okay) { 259 usb_log_debug("Port %zu reset complete.\n", port); 218 260 } else { 219 261 usb_log_warning( 220 "Port %zu reset complete but port not enabled.\n", 221 (size_t) port); 222 } 262 "Port %zu reset complete but port not enabled.\n", port); 263 } 264 fibril_condvar_broadcast(&the_port->reset_cv); 265 fibril_mutex_unlock(&the_port->reset_mutex); 266 223 267 /* Clear the port reset change. */ 224 268 int rc = usb_hub_clear_port_feature(hub->control_pipe, … … 229 273 } 230 274 } 231 275 /*----------------------------------------------------------------------------*/ 232 276 /** Retrieve port status. 233 277 * … … 285 329 assert(hub); 286 330 usb_hub_port_t *my_port = hub->ports + port_no; 287 288 usb_device_request_setup_packet_t request; 289 usb_hub_set_reset_port_request(&request, port_no); 290 291 const int rc = usb_pipe_control_write(hub->control_pipe, 292 &request, sizeof (request), NULL, 0); 331 const int rc = usb_hub_set_port_feature(hub->control_pipe, 332 port_no, USB_HUB_FEATURE_PORT_RESET); 293 333 if (rc != EOK) { 294 334 usb_log_warning("Port reset failed: %s.\n", str_error(rc));
Note:
See TracChangeset
for help on using the changeset viewer.
