Changeset 26e7d6d in mainline for uspace/drv/bus/usb/usbhub/usbhub.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
r3842a955 r26e7d6d 131 131 opResult = ddf_fun_bind(hub_fun); 132 132 assert(opResult == EOK); 133 opResult = ddf_fun_add_to_c lass(hub_fun, "hub");133 opResult = ddf_fun_add_to_category(hub_fun, "hub"); 134 134 assert(opResult == EOK); 135 135 … … 220 220 * @return error code 221 221 */ 222 static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info) { 222 int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info) 223 { 223 224 // get hub descriptor 224 usb_log_debug(" Creating serializeddescriptor\n");225 usb_log_debug("Retrieving descriptor\n"); 225 226 uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE]; 226 usb_hub_descriptor_t * descriptor;227 227 int opResult; 228 228 … … 234 234 235 235 if (opResult != EOK) { 236 usb_log_error("Failed when receiving hub descriptor, " 237 "%s\n", 238 str_error(opResult)); 239 free(serialized_descriptor); 236 usb_log_error("Failed to receive hub descriptor: %s.\n", 237 str_error(opResult)); 240 238 return opResult; 241 239 } 242 usb_log_debug2("Deserializing descriptor\n"); 243 descriptor = usb_create_deserialized_hub_desriptor( 244 serialized_descriptor); 245 if (descriptor == NULL) { 246 usb_log_warning("could not deserialize descriptor \n"); 247 return ENOMEM; 248 } 249 usb_log_debug("setting port count to %d\n", descriptor->ports_count); 250 hub_info->port_count = descriptor->ports_count; 251 bool is_power_switched = 252 ((descriptor->hub_characteristics & 1) == 0); 253 bool has_individual_port_powering = 254 ((descriptor->hub_characteristics & 1) != 0); 255 hub_info->ports = malloc( 256 sizeof (usb_hub_port_t) * (hub_info->port_count + 1)); 240 usb_log_debug2("Parsing descriptor\n"); 241 usb_hub_descriptor_t descriptor; 242 opResult = usb_deserialize_hub_desriptor( 243 serialized_descriptor, received_size, &descriptor); 244 if (opResult != EOK) { 245 usb_log_error("Could not parse descriptor: %s\n", 246 str_error(opResult)); 247 return opResult; 248 } 249 usb_log_debug("Setting port count to %d.\n", descriptor.ports_count); 250 hub_info->port_count = descriptor.ports_count; 251 252 hub_info->ports = 253 malloc(sizeof(usb_hub_port_t) * (hub_info->port_count + 1)); 257 254 if (!hub_info->ports) { 258 255 return ENOMEM; 259 256 } 257 260 258 size_t port; 261 259 for (port = 0; port < hub_info->port_count + 1; ++port) { 262 260 usb_hub_port_init(&hub_info->ports[port]); 263 261 } 262 263 const bool is_power_switched = 264 !(descriptor.hub_characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG); 264 265 if (is_power_switched) { 265 266 usb_log_debug("Hub power switched\n"); 266 267 if (!has_individual_port_powering) { 268 //this setting actually makes no difference 269 usb_log_debug("Hub has global powering\n"); 270 } 267 const bool per_port_power = descriptor.hub_characteristics 268 & HUB_CHAR_POWER_PER_PORT_FLAG; 271 269 272 270 for (port = 1; port <= hub_info->port_count; ++port) { 273 271 usb_log_debug("Powering port %zu.\n", port); 274 opResult = usb_hub_set_port_feature(hub_info->control_pipe, 272 opResult = usb_hub_set_port_feature( 273 hub_info->control_pipe, 275 274 port, USB_HUB_FEATURE_PORT_POWER); 276 275 if (opResult != EOK) { 277 276 usb_log_error("Cannot power on port %zu: %s.\n", 278 277 port, str_error(opResult)); 278 } else { 279 if (!per_port_power) { 280 usb_log_debug( 281 "Ganged power switching mode, " 282 "one port is enough.\n"); 283 break; 284 } 279 285 } 280 286 } … … 283 289 usb_log_debug("Power not switched, not going to be powered\n"); 284 290 } 285 usb_log_debug2("Freeing data\n");286 free(descriptor);287 291 return EOK; 288 292 }
Note:
See TracChangeset
for help on using the changeset viewer.