usb_handle_request.c (184610) | usb_handle_request.c (184824) |
---|---|
1/* $FreeBSD: head/sys/dev/usb2/core/usb2_handle_request.c 184610 2008-11-04 02:31:03Z alfred $ */ | 1/* $FreeBSD: head/sys/dev/usb2/core/usb2_handle_request.c 184824 2008-11-10 20:54:31Z 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. --- 115 unchanged lines hidden (view full) --- 125usb2_handle_set_config(struct usb2_xfer *xfer, uint8_t conf_no) 126{ 127 usb2_error_t err = 0; 128 129 /* 130 * We need to protect against other threads doing probe and 131 * attach: 132 */ | 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. --- 115 unchanged lines hidden (view full) --- 125usb2_handle_set_config(struct usb2_xfer *xfer, uint8_t conf_no) 126{ 127 usb2_error_t err = 0; 128 129 /* 130 * We need to protect against other threads doing probe and 131 * attach: 132 */ |
133 mtx_unlock(xfer->priv_mtx); | 133 USB_XFER_UNLOCK(xfer); |
134 mtx_lock(&Giant); /* XXX */ 135 sx_xlock(xfer->udev->default_sx + 1); 136 137 if (conf_no == USB_UNCONFIG_NO) { 138 conf_no = USB_UNCONFIG_INDEX; 139 } else { 140 /* 141 * The relationship between config number and config index --- 10 unchanged lines hidden (view full) --- 152 if (usb2_probe_and_attach(xfer->udev, USB_IFACE_INDEX_ANY)) { 153 DPRINTF("probe and attach failed\n"); 154 err = USB_ERR_STALLED; 155 goto done; 156 } 157done: 158 mtx_unlock(&Giant); /* XXX */ 159 sx_unlock(xfer->udev->default_sx + 1); | 134 mtx_lock(&Giant); /* XXX */ 135 sx_xlock(xfer->udev->default_sx + 1); 136 137 if (conf_no == USB_UNCONFIG_NO) { 138 conf_no = USB_UNCONFIG_INDEX; 139 } else { 140 /* 141 * The relationship between config number and config index --- 10 unchanged lines hidden (view full) --- 152 if (usb2_probe_and_attach(xfer->udev, USB_IFACE_INDEX_ANY)) { 153 DPRINTF("probe and attach failed\n"); 154 err = USB_ERR_STALLED; 155 goto done; 156 } 157done: 158 mtx_unlock(&Giant); /* XXX */ 159 sx_unlock(xfer->udev->default_sx + 1); |
160 mtx_lock(xfer->priv_mtx); | 160 USB_XFER_LOCK(xfer); |
161 return (err); 162} 163 164/*------------------------------------------------------------------------* 165 * usb2_handle_iface_request 166 * 167 * Returns: 168 * 0: Success --- 15 unchanged lines hidden (view full) --- 184 } else { 185 iface_index = 0; /* broadcast */ 186 } 187 188 /* 189 * We need to protect against other threads doing probe and 190 * attach: 191 */ | 161 return (err); 162} 163 164/*------------------------------------------------------------------------* 165 * usb2_handle_iface_request 166 * 167 * Returns: 168 * 0: Success --- 15 unchanged lines hidden (view full) --- 184 } else { 185 iface_index = 0; /* broadcast */ 186 } 187 188 /* 189 * We need to protect against other threads doing probe and 190 * attach: 191 */ |
192 mtx_unlock(xfer->priv_mtx); | 192 USB_XFER_UNLOCK(xfer); |
193 mtx_lock(&Giant); /* XXX */ 194 sx_xlock(udev->default_sx + 1); 195 196 error = ENXIO; 197 198tr_repeat: 199 iface = usb2_get_iface(udev, iface_index); 200 if ((iface == NULL) || --- 104 unchanged lines hidden (view full) --- 305 } 306 break; 307 default: 308 goto tr_stalled; 309 } 310tr_valid: 311 mtx_unlock(&Giant); 312 sx_unlock(udev->default_sx + 1); | 193 mtx_lock(&Giant); /* XXX */ 194 sx_xlock(udev->default_sx + 1); 195 196 error = ENXIO; 197 198tr_repeat: 199 iface = usb2_get_iface(udev, iface_index); 200 if ((iface == NULL) || --- 104 unchanged lines hidden (view full) --- 305 } 306 break; 307 default: 308 goto tr_stalled; 309 } 310tr_valid: 311 mtx_unlock(&Giant); 312 sx_unlock(udev->default_sx + 1); |
313 mtx_lock(xfer->priv_mtx); | 313 USB_XFER_LOCK(xfer); |
314 return (0); 315 316tr_stalled: 317 mtx_unlock(&Giant); 318 sx_unlock(udev->default_sx + 1); | 314 return (0); 315 316tr_stalled: 317 mtx_unlock(&Giant); 318 sx_unlock(udev->default_sx + 1); |
319 mtx_lock(xfer->priv_mtx); | 319 USB_XFER_LOCK(xfer); |
320 return (USB_ERR_STALLED); 321} 322 323/*------------------------------------------------------------------------* 324 * usb2_handle_stall 325 * 326 * Returns: 327 * 0: Success 328 * Else: Failure 329 *------------------------------------------------------------------------*/ 330static usb2_error_t 331usb2_handle_set_stall(struct usb2_xfer *xfer, uint8_t ep, uint8_t do_stall) 332{ 333 usb2_error_t err; 334 | 320 return (USB_ERR_STALLED); 321} 322 323/*------------------------------------------------------------------------* 324 * usb2_handle_stall 325 * 326 * Returns: 327 * 0: Success 328 * Else: Failure 329 *------------------------------------------------------------------------*/ 330static usb2_error_t 331usb2_handle_set_stall(struct usb2_xfer *xfer, uint8_t ep, uint8_t do_stall) 332{ 333 usb2_error_t err; 334 |
335 mtx_unlock(xfer->priv_mtx); | 335 USB_XFER_UNLOCK(xfer); |
336 err = usb2_set_endpoint_stall(xfer->udev, 337 usb2_get_pipe_by_addr(xfer->udev, ep), do_stall); | 336 err = usb2_set_endpoint_stall(xfer->udev, 337 usb2_get_pipe_by_addr(xfer->udev, ep), do_stall); |
338 mtx_lock(xfer->priv_mtx); | 338 USB_XFER_LOCK(xfer); |
339 return (err); 340} 341 342/*------------------------------------------------------------------------* 343 * usb2_handle_get_stall 344 * 345 * Returns: 346 * 0: Success --- 5 unchanged lines hidden (view full) --- 352 struct usb2_pipe *pipe; 353 uint8_t halted; 354 355 pipe = usb2_get_pipe_by_addr(udev, ea_val); 356 if (pipe == NULL) { 357 /* nothing to do */ 358 return (0); 359 } | 339 return (err); 340} 341 342/*------------------------------------------------------------------------* 343 * usb2_handle_get_stall 344 * 345 * Returns: 346 * 0: Success --- 5 unchanged lines hidden (view full) --- 352 struct usb2_pipe *pipe; 353 uint8_t halted; 354 355 pipe = usb2_get_pipe_by_addr(udev, ea_val); 356 if (pipe == NULL) { 357 /* nothing to do */ 358 return (0); 359 } |
360 mtx_lock(&udev->bus->mtx); | 360 USB_BUS_LOCK(udev->bus); |
361 halted = pipe->is_stalled; | 361 halted = pipe->is_stalled; |
362 mtx_unlock(&udev->bus->mtx); | 362 USB_BUS_UNLOCK(udev->bus); |
363 364 return (halted); 365} 366 367/*------------------------------------------------------------------------* 368 * usb2_handle_remote_wakeup 369 * 370 * Returns: --- 4 unchanged lines hidden (view full) --- 375usb2_handle_remote_wakeup(struct usb2_xfer *xfer, uint8_t is_on) 376{ 377 struct usb2_device *udev; 378 struct usb2_bus *bus; 379 380 udev = xfer->udev; 381 bus = udev->bus; 382 | 363 364 return (halted); 365} 366 367/*------------------------------------------------------------------------* 368 * usb2_handle_remote_wakeup 369 * 370 * Returns: --- 4 unchanged lines hidden (view full) --- 375usb2_handle_remote_wakeup(struct usb2_xfer *xfer, uint8_t is_on) 376{ 377 struct usb2_device *udev; 378 struct usb2_bus *bus; 379 380 udev = xfer->udev; 381 bus = udev->bus; 382 |
383 mtx_lock(&bus->mtx); | 383 USB_BUS_LOCK(bus); |
384 385 if (is_on) { 386 udev->flags.remote_wakeup = 1; 387 } else { 388 udev->flags.remote_wakeup = 0; 389 } 390 391 (bus->methods->rem_wakeup_set) (xfer->udev, is_on); 392 | 384 385 if (is_on) { 386 udev->flags.remote_wakeup = 1; 387 } else { 388 udev->flags.remote_wakeup = 0; 389 } 390 391 (bus->methods->rem_wakeup_set) (xfer->udev, is_on); 392 |
393 mtx_unlock(&bus->mtx); | 393 USB_BUS_UNLOCK(bus); |
394 395 return (0); /* success */ 396} 397 398/*------------------------------------------------------------------------* 399 * usb2_handle_request 400 * 401 * Internal state sequence: --- 197 unchanged lines hidden (view full) --- 599 src_mcopy = temp.buf; 600 max_len = 1; 601 goto tr_valid; 602 603tr_handle_get_status: 604 605 wValue = 0; 606 | 394 395 return (0); /* success */ 396} 397 398/*------------------------------------------------------------------------* 399 * usb2_handle_request 400 * 401 * Internal state sequence: --- 197 unchanged lines hidden (view full) --- 599 src_mcopy = temp.buf; 600 max_len = 1; 601 goto tr_valid; 602 603tr_handle_get_status: 604 605 wValue = 0; 606 |
607 mtx_lock(&udev->bus->mtx); | 607 USB_BUS_LOCK(udev->bus); |
608 if (udev->flags.remote_wakeup) { 609 wValue |= UDS_REMOTE_WAKEUP; 610 } 611 if (udev->flags.self_powered) { 612 wValue |= UDS_SELF_POWERED; 613 } | 608 if (udev->flags.remote_wakeup) { 609 wValue |= UDS_REMOTE_WAKEUP; 610 } 611 if (udev->flags.self_powered) { 612 wValue |= UDS_SELF_POWERED; 613 } |
614 mtx_unlock(&udev->bus->mtx); | 614 USB_BUS_UNLOCK(udev->bus); |
615 616 USETW(temp.wStatus, wValue); 617 src_mcopy = temp.wStatus; 618 max_len = sizeof(temp.wStatus); 619 goto tr_valid; 620 621tr_handle_set_address: 622 if (state == ST_DATA) { --- 128 unchanged lines hidden --- | 615 616 USETW(temp.wStatus, wValue); 617 src_mcopy = temp.wStatus; 618 max_len = sizeof(temp.wStatus); 619 goto tr_valid; 620 621tr_handle_set_address: 622 if (state == ST_DATA) { --- 128 unchanged lines hidden --- |