Changeset 983e135 in mainline
- Timestamp:
- 2011-09-19T13:31:23Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5b6f8dd
- Parents:
- d46b13d
- Location:
- uspace/drv/bus/usb/usbhub
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/ports.c
rd46b13d r983e135 95 95 * @param port port number, starting from 1 96 96 */ 97 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, 98 uint16_t port){97 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, uint16_t port) 98 { 99 99 usb_log_debug("Interrupt at port %zu\n", (size_t) port); 100 100 //determine type of change -
uspace/drv/bus/usb/usbhub/ports.h
rd46b13d r983e135 70 70 71 71 72 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, 73 uint16_t port); 72 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, uint16_t port); 74 73 75 74 -
uspace/drv/bus/usb/usbhub/usbhub.c
rd46b13d r983e135 160 160 */ 161 161 bool hub_port_changes_callback(usb_device_t *dev, 162 uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) { 162 uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) 163 { 163 164 usb_log_debug("hub_port_changes_callback\n"); 164 usb_hub_info_t *hub = (usb_hub_info_t *)arg;165 usb_hub_info_t *hub = arg; 165 166 166 167 /* FIXME: check that we received enough bytes. */ … … 169 170 } 170 171 171 bool change;172 c hange = ((uint8_t*) change_bitmap)[0] & 1;172 /* Lowest bit indicates global change */ 173 const bool change = change_bitmap[0] & 1; 173 174 if (change) { 174 175 usb_hub_process_global_interrupt(hub); 175 176 } 176 177 177 size_t port; 178 for (port = 1; port < hub->port_count + 1; port++) { 179 bool change = (change_bitmap[port / 8] >> (port % 8)) % 2; 178 /* N + 1 bit indicates change on port N */ 179 size_t port = 1; 180 for (; port < hub->port_count + 1; port++) { 181 const bool change = (change_bitmap[port / 8] >> (port % 8)) & 1; 180 182 if (change) { 181 183 usb_hub_process_port_interrupt(hub, port); … … 184 186 leave: 185 187 /* FIXME: proper interval. */ 188 // TODO Interval should be handled by USB HC scheduler not here 186 189 async_usleep(1000 * 250); 187 190 … … 205 208 static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev) 206 209 { 207 usb_hub_info_t *result = malloc(sizeof (usb_hub_info_t)); 210 assert(usb_dev); 211 usb_hub_info_t *result = malloc(sizeof(usb_hub_info_t)); 208 212 if (!result) 209 213 return NULL; … … 215 219 216 220 result->ports = NULL; 217 result->port_count = (size_t) -1;221 result->port_count = -1; 218 222 fibril_mutex_initialize(&result->port_mutex); 219 220 223 fibril_mutex_initialize(&result->pending_ops_mutex); 221 224 fibril_condvar_initialize(&result->pending_ops_cv); … … 315 318 * @return error code 316 319 */ 317 static int usb_hub_set_configuration(usb_hub_info_t *hub_info) { 320 static int usb_hub_set_configuration(usb_hub_info_t *hub_info) 321 { 318 322 //device descriptor 319 usb_standard_device_descriptor_t *std_descriptor323 const usb_standard_device_descriptor_t *std_descriptor 320 324 = &hub_info->usb_device->descriptors.device; 321 325 usb_log_debug("Hub has %d configurations\n", 322 326 std_descriptor->configuration_count); 327 323 328 if (std_descriptor->configuration_count < 1) { 324 329 usb_log_error("There are no configurations available\n"); -
uspace/drv/bus/usb/usbhub/usbhub.h
rd46b13d r983e135 77 77 * searched again and again for the 'right pipe'. 78 78 */ 79 usb_pipe_t * 79 usb_pipe_t *status_change_pipe; 80 80 81 /** convenience pointer to control pipe81 /** Convenience pointer to control pipe 82 82 * 83 83 * Control pipe is initialized in usb_device structure. This is 84 * pointer into th is structure, so that it does not have to be85 * search edagain and again for the 'right pipe'.84 * pointer into that structure, so that we don't not have to 85 * search again and again for the 'right pipe'. 86 86 */ 87 usb_pipe_t * 87 usb_pipe_t *control_pipe; 88 88 89 /** generic usb device data*/90 usb_device_t * 89 /** Generic usb device data*/ 90 usb_device_t *usb_device; 91 91 92 92 /** Number of pending operations on the mutex to prevent shooting … … 101 101 /** Condition variable for pending_ops_count. */ 102 102 fibril_condvar_t pending_ops_cv; 103 104 103 }; 105 104
Note:
See TracChangeset
for help on using the changeset viewer.