usb_device.c (239214) | usb_device.c (239240) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_device.c 239214 2012-08-12 17:53:06Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_device.c 239240 2012-08-13 18:34:04Z hselasky $ */ |
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. --- 2762 unchanged lines hidden (view full) --- 2772 * should not be called outside enumeration context. 2773 */ 2774 2775usb_error_t 2776usbd_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, 2777 uint8_t ep_mode) 2778{ 2779 usb_error_t error; | 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. --- 2762 unchanged lines hidden (view full) --- 2772 * should not be called outside enumeration context. 2773 */ 2774 2775usb_error_t 2776usbd_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, 2777 uint8_t ep_mode) 2778{ 2779 usb_error_t error; |
2780 uint8_t do_unlock; |
|
2780 | 2781 |
2781 sx_assert(&udev->enum_sx, SA_LOCKED); | 2782 /* automatic locking */ 2783 if (usbd_enum_is_locked(udev)) { 2784 do_unlock = 0; 2785 } else { 2786 do_unlock = 1; 2787 usbd_enum_lock(udev); 2788 } |
2782 2783 if (udev->bus->methods->set_endpoint_mode != NULL) { 2784 error = (udev->bus->methods->set_endpoint_mode) ( 2785 udev, ep, ep_mode); 2786 } else if (ep_mode != USB_EP_MODE_DEFAULT) { 2787 error = USB_ERR_INVAL; 2788 } else { 2789 error = 0; 2790 } 2791 2792 /* only set new mode regardless of error */ 2793 ep->ep_mode = ep_mode; 2794 | 2789 2790 if (udev->bus->methods->set_endpoint_mode != NULL) { 2791 error = (udev->bus->methods->set_endpoint_mode) ( 2792 udev, ep, ep_mode); 2793 } else if (ep_mode != USB_EP_MODE_DEFAULT) { 2794 error = USB_ERR_INVAL; 2795 } else { 2796 error = 0; 2797 } 2798 2799 /* only set new mode regardless of error */ 2800 ep->ep_mode = ep_mode; 2801 |
2802 if (do_unlock) 2803 usbd_enum_unlock(udev); 2804 |
|
2795 return (error); 2796} 2797 2798uint8_t 2799usbd_get_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep) 2800{ 2801 return (ep->ep_mode); 2802} | 2805 return (error); 2806} 2807 2808uint8_t 2809usbd_get_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep) 2810{ 2811 return (ep->ep_mode); 2812} |