Changes in uspace/drv/vhc/hub.c [1e32a63:4b4c797] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub.c
r1e32a63 r4b4c797 37 37 #include <usbvirt/device.h> 38 38 #include <errno.h> 39 #include <str_error.h>40 39 #include <stdlib.h> 41 #include <driver.h>42 40 43 41 #include "vhcd.h" 44 42 #include "hub.h" 45 43 #include "hubintern.h" 46 #include "conn.h"47 44 48 45 … … 144 141 .ops = &hub_ops, 145 142 .descriptors = &descriptors, 146 .lib_debug_level = 0,143 .lib_debug_level = 4, 147 144 .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL 148 145 }; … … 151 148 hub_device_t hub_dev; 152 149 153 static usb_address_t hub_set_address(usbvirt_device_t *hub)154 {155 usb_address_t new_address;156 int rc = vhc_iface.request_address(NULL, &new_address);157 if (rc != EOK) {158 return rc;159 }160 161 usb_device_request_setup_packet_t setup_packet = {162 .request_type = 0,163 .request = USB_DEVREQ_SET_ADDRESS,164 .index = 0,165 .length = 0,166 };167 setup_packet.value = new_address;168 169 hub->transaction_setup(hub, 0, &setup_packet, sizeof(setup_packet));170 hub->transaction_in(hub, 0, NULL, 0, NULL);171 172 return new_address;173 }174 175 150 /** Initialize virtual hub. */ 176 void hub_init(device_t *hc_dev) 177 { 178 size_t i; 179 151 void hub_init(void) 152 { 153 size_t i; 180 154 for (i = 0; i < HUB_PORT_COUNT; i++) { 181 155 hub_port_t *port = &hub_dev.ports[i]; 182 156 183 port->index = (int) i + 1;184 157 port->device = NULL; 185 158 port->state = HUB_PORT_STATE_NOT_CONFIGURED; 186 159 port->status_change = 0; 187 fibril_mutex_initialize(&port->guard);188 160 } 189 161 … … 191 163 192 164 dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT); 193 194 usb_address_t hub_address = hub_set_address(&virthub_dev);195 if (hub_address < 0) {196 dprintf(1, "problem changing hub address (%s)",197 str_error(hub_address));198 }199 200 dprintf(2, "virtual hub address changed to %d", hub_address);201 202 char *id;203 int rc = asprintf(&id, "usb&hub");204 if (rc <= 0) {205 return;206 }207 devman_handle_t hub_handle;208 rc = child_device_register_wrapper(hc_dev, "hub", id, 10, &hub_handle);209 if (rc != EOK) {210 free(id);211 }212 213 vhc_iface.bind_address(NULL, hub_address, hub_handle);214 215 dprintf(2, "virtual hub has devman handle %d", (int) hub_handle);216 165 } 217 166 … … 226 175 for (i = 0; i < HUB_PORT_COUNT; i++) { 227 176 hub_port_t *port = &hub_dev.ports[i]; 228 fibril_mutex_lock(&port->guard);229 177 230 178 if (port->device != NULL) { 231 fibril_mutex_unlock(&port->guard);232 179 continue; 233 180 } … … 244 191 //if (port->state == HUB_PORT_STATE_DISCONNECTED) { 245 192 port->state = HUB_PORT_STATE_DISABLED; 246 set_port_status_change _nl(port, HUB_STATUS_C_PORT_CONNECTION);193 set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 247 194 //} 248 195 249 fibril_mutex_unlock(&port->guard);250 251 196 return i; 252 197 }
Note:
See TracChangeset
for help on using the changeset viewer.