Changeset 983e135 in mainline for uspace/drv/bus/usb/usbhub/usbhub.c
- Timestamp:
- 2011-09-19T13:31:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5b6f8dd
- Parents:
- d46b13d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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");
Note:
See TracChangeset
for help on using the changeset viewer.