usb_handle_request.c (186730) | usb_handle_request.c (187173) |
---|---|
1/* $FreeBSD: head/sys/dev/usb2/core/usb2_handle_request.c 186730 2009-01-04 00:12:01Z alfred $ */ | 1/* $FreeBSD: head/sys/dev/usb2/core/usb2_handle_request.c 187173 2009-01-13 19:03:12Z thompsa $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 71 unchanged lines hidden (view full) --- 81 82 /* handle the request */ 83 err = usb2_handle_request(xfer); 84 85 if (err) { 86 87 if (err == USB_ERR_BAD_CONTEXT) { 88 /* we need to re-setup the control transfer */ | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 71 unchanged lines hidden (view full) --- 81 82 /* handle the request */ 83 err = usb2_handle_request(xfer); 84 85 if (err) { 86 87 if (err == USB_ERR_BAD_CONTEXT) { 88 /* we need to re-setup the control transfer */ |
89 usb2_needs_explore(xfer->udev->bus, 0); | 89 usb2_needs_explore(xfer->xroot->bus, 0); |
90 break; 91 } 92 /* 93 * If no control transfer is active, 94 * receive the next SETUP message: 95 */ 96 goto tr_restart; 97 } --- 23 unchanged lines hidden (view full) --- 121 * 122 * Returns: 123 * 0: Success 124 * Else: Failure 125 *------------------------------------------------------------------------*/ 126static usb2_error_t 127usb2_handle_set_config(struct usb2_xfer *xfer, uint8_t conf_no) 128{ | 90 break; 91 } 92 /* 93 * If no control transfer is active, 94 * receive the next SETUP message: 95 */ 96 goto tr_restart; 97 } --- 23 unchanged lines hidden (view full) --- 121 * 122 * Returns: 123 * 0: Success 124 * Else: Failure 125 *------------------------------------------------------------------------*/ 126static usb2_error_t 127usb2_handle_set_config(struct usb2_xfer *xfer, uint8_t conf_no) 128{ |
129 struct usb2_device *udev = xfer->xroot->udev; |
|
129 usb2_error_t err = 0; 130 131 /* 132 * We need to protect against other threads doing probe and 133 * attach: 134 */ 135 USB_XFER_UNLOCK(xfer); 136 mtx_lock(&Giant); /* XXX */ | 130 usb2_error_t err = 0; 131 132 /* 133 * We need to protect against other threads doing probe and 134 * attach: 135 */ 136 USB_XFER_UNLOCK(xfer); 137 mtx_lock(&Giant); /* XXX */ |
137 sx_xlock(xfer->udev->default_sx + 1); | 138 sx_xlock(udev->default_sx + 1); |
138 139 if (conf_no == USB_UNCONFIG_NO) { 140 conf_no = USB_UNCONFIG_INDEX; 141 } else { 142 /* 143 * The relationship between config number and config index 144 * is very simple in our case: 145 */ 146 conf_no--; 147 } 148 | 139 140 if (conf_no == USB_UNCONFIG_NO) { 141 conf_no = USB_UNCONFIG_INDEX; 142 } else { 143 /* 144 * The relationship between config number and config index 145 * is very simple in our case: 146 */ 147 conf_no--; 148 } 149 |
149 if (usb2_set_config_index(xfer->udev, conf_no)) { | 150 if (usb2_set_config_index(udev, conf_no)) { |
150 DPRINTF("set config %d failed\n", conf_no); 151 err = USB_ERR_STALLED; 152 goto done; 153 } | 151 DPRINTF("set config %d failed\n", conf_no); 152 err = USB_ERR_STALLED; 153 goto done; 154 } |
154 if (usb2_probe_and_attach(xfer->udev, USB_IFACE_INDEX_ANY)) { | 155 if (usb2_probe_and_attach(udev, USB_IFACE_INDEX_ANY)) { |
155 DPRINTF("probe and attach failed\n"); 156 err = USB_ERR_STALLED; 157 goto done; 158 } 159done: 160 mtx_unlock(&Giant); /* XXX */ | 156 DPRINTF("probe and attach failed\n"); 157 err = USB_ERR_STALLED; 158 goto done; 159 } 160done: 161 mtx_unlock(&Giant); /* XXX */ |
161 sx_unlock(xfer->udev->default_sx + 1); | 162 sx_unlock(udev->default_sx + 1); |
162 USB_XFER_LOCK(xfer); 163 return (err); 164} 165 166/*------------------------------------------------------------------------* 167 * usb2_handle_iface_request 168 * 169 * Returns: 170 * 0: Success 171 * Else: Failure 172 *------------------------------------------------------------------------*/ 173static usb2_error_t 174usb2_handle_iface_request(struct usb2_xfer *xfer, 175 void **ppdata, uint16_t *plen, 176 struct usb2_device_request req, uint16_t off, uint8_t state) 177{ 178 struct usb2_interface *iface; 179 struct usb2_interface *iface_parent; /* parent interface */ | 163 USB_XFER_LOCK(xfer); 164 return (err); 165} 166 167/*------------------------------------------------------------------------* 168 * usb2_handle_iface_request 169 * 170 * Returns: 171 * 0: Success 172 * Else: Failure 173 *------------------------------------------------------------------------*/ 174static usb2_error_t 175usb2_handle_iface_request(struct usb2_xfer *xfer, 176 void **ppdata, uint16_t *plen, 177 struct usb2_device_request req, uint16_t off, uint8_t state) 178{ 179 struct usb2_interface *iface; 180 struct usb2_interface *iface_parent; /* parent interface */ |
180 struct usb2_device *udev = xfer->udev; | 181 struct usb2_device *udev = xfer->xroot->udev; |
181 int error; 182 uint8_t iface_index; 183 184 if ((req.bmRequestType & 0x1F) == UT_INTERFACE) { 185 iface_index = req.wIndex[0]; /* unicast */ 186 } else { 187 iface_index = 0; /* broadcast */ 188 } --- 138 unchanged lines hidden (view full) --- 327 * 328 * Returns: 329 * 0: Success 330 * Else: Failure 331 *------------------------------------------------------------------------*/ 332static usb2_error_t 333usb2_handle_set_stall(struct usb2_xfer *xfer, uint8_t ep, uint8_t do_stall) 334{ | 182 int error; 183 uint8_t iface_index; 184 185 if ((req.bmRequestType & 0x1F) == UT_INTERFACE) { 186 iface_index = req.wIndex[0]; /* unicast */ 187 } else { 188 iface_index = 0; /* broadcast */ 189 } --- 138 unchanged lines hidden (view full) --- 328 * 329 * Returns: 330 * 0: Success 331 * Else: Failure 332 *------------------------------------------------------------------------*/ 333static usb2_error_t 334usb2_handle_set_stall(struct usb2_xfer *xfer, uint8_t ep, uint8_t do_stall) 335{ |
336 struct usb2_device *udev = xfer->xroot->udev; |
|
335 usb2_error_t err; 336 337 USB_XFER_UNLOCK(xfer); | 337 usb2_error_t err; 338 339 USB_XFER_UNLOCK(xfer); |
338 err = usb2_set_endpoint_stall(xfer->udev, 339 usb2_get_pipe_by_addr(xfer->udev, ep), do_stall); | 340 err = usb2_set_endpoint_stall(udev, 341 usb2_get_pipe_by_addr(udev, ep), do_stall); |
340 USB_XFER_LOCK(xfer); 341 return (err); 342} 343 344/*------------------------------------------------------------------------* 345 * usb2_handle_get_stall 346 * 347 * Returns: --- 26 unchanged lines hidden (view full) --- 374 * Else: Failure 375 *------------------------------------------------------------------------*/ 376static usb2_error_t 377usb2_handle_remote_wakeup(struct usb2_xfer *xfer, uint8_t is_on) 378{ 379 struct usb2_device *udev; 380 struct usb2_bus *bus; 381 | 342 USB_XFER_LOCK(xfer); 343 return (err); 344} 345 346/*------------------------------------------------------------------------* 347 * usb2_handle_get_stall 348 * 349 * Returns: --- 26 unchanged lines hidden (view full) --- 376 * Else: Failure 377 *------------------------------------------------------------------------*/ 378static usb2_error_t 379usb2_handle_remote_wakeup(struct usb2_xfer *xfer, uint8_t is_on) 380{ 381 struct usb2_device *udev; 382 struct usb2_bus *bus; 383 |
382 udev = xfer->udev; | 384 udev = xfer->xroot->udev; |
383 bus = udev->bus; 384 385 USB_BUS_LOCK(bus); 386 387 if (is_on) { 388 udev->flags.remote_wakeup = 1; 389 } else { 390 udev->flags.remote_wakeup = 0; --- 83 unchanged lines hidden (view full) --- 474 off = UGETW(req.wLength) - rem; 475 } 476 477 /* set some defaults */ 478 479 max_len = 0; 480 src_zcopy = NULL; 481 src_mcopy = NULL; | 385 bus = udev->bus; 386 387 USB_BUS_LOCK(bus); 388 389 if (is_on) { 390 udev->flags.remote_wakeup = 1; 391 } else { 392 udev->flags.remote_wakeup = 0; --- 83 unchanged lines hidden (view full) --- 476 off = UGETW(req.wLength) - rem; 477 } 478 479 /* set some defaults */ 480 481 max_len = 0; 482 src_zcopy = NULL; 483 src_mcopy = NULL; |
482 udev = xfer->udev; | 484 udev = xfer->xroot->udev; |
483 484 /* get some request fields decoded */ 485 486 wValue = UGETW(req.wValue); 487 wIndex = UGETW(req.wIndex); 488 489 DPRINTF("req 0x%02x 0x%02x 0x%04x 0x%04x " 490 "off=0x%x rem=0x%x, state=%d\n", req.bmRequestType, --- 264 unchanged lines hidden --- | 485 486 /* get some request fields decoded */ 487 488 wValue = UGETW(req.wValue); 489 wIndex = UGETW(req.wIndex); 490 491 DPRINTF("req 0x%02x 0x%02x 0x%04x 0x%04x " 492 "off=0x%x rem=0x%x, state=%d\n", req.bmRequestType, --- 264 unchanged lines hidden --- |