Deleted Added
full compact
usb_generic.c (302408) usb_generic.c (305733)
1/* $FreeBSD: stable/11/sys/dev/usb/usb_generic.c 277417 2015-01-20 11:43:16Z hselasky $ */
1/* $FreeBSD: stable/11/sys/dev/usb/usb_generic.c 305733 2016-09-12 10:14:30Z 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.

--- 699 unchanged lines hidden (view full) ---

709 error = copyout(cdesc, ugd->ugd_data, len);
710
711 if (free_data)
712 usbd_free_config_desc(udev, cdesc);
713
714 return (error);
715}
716
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.

--- 699 unchanged lines hidden (view full) ---

709 error = copyout(cdesc, ugd->ugd_data, len);
710
711 if (free_data)
712 usbd_free_config_desc(udev, cdesc);
713
714 return (error);
715}
716
717/*
718 * This function is called having the enumeration SX locked which
719 * protects the scratch area used.
720 */
721static int
722ugen_get_sdesc(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
723{
724 void *ptr;
725 uint16_t size;
726 int error;
717static int
718ugen_get_sdesc(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
719{
720 void *ptr;
721 uint16_t size;
722 int error;
723 uint8_t do_unlock;
727
724
725 /* Protect scratch area */
726 do_unlock = usbd_ctrl_lock(f->udev);
727
728 ptr = f->udev->scratch.data;
729 size = sizeof(f->udev->scratch.data);
730
731 if (usbd_req_get_string_desc(f->udev, NULL, ptr,
732 size, ugd->ugd_lang_id, ugd->ugd_string_index)) {
733 error = EINVAL;
734 } else {
735
736 if (size > ((uint8_t *)ptr)[0]) {
737 size = ((uint8_t *)ptr)[0];
738 }
739 if (size > ugd->ugd_maxlen) {
740 size = ugd->ugd_maxlen;
741 }
742 ugd->ugd_actlen = size;
743 ugd->ugd_offset = 0;
744
745 error = copyout(ptr, ugd->ugd_data, size);
746 }
728 ptr = f->udev->scratch.data;
729 size = sizeof(f->udev->scratch.data);
730
731 if (usbd_req_get_string_desc(f->udev, NULL, ptr,
732 size, ugd->ugd_lang_id, ugd->ugd_string_index)) {
733 error = EINVAL;
734 } else {
735
736 if (size > ((uint8_t *)ptr)[0]) {
737 size = ((uint8_t *)ptr)[0];
738 }
739 if (size > ugd->ugd_maxlen) {
740 size = ugd->ugd_maxlen;
741 }
742 ugd->ugd_actlen = size;
743 ugd->ugd_offset = 0;
744
745 error = copyout(ptr, ugd->ugd_data, size);
746 }
747 if (do_unlock)
748 usbd_ctrl_unlock(f->udev);
749
747 return (error);
748}
749
750/*------------------------------------------------------------------------*
751 * ugen_get_iface_driver
752 *
753 * This function generates an USB interface description for userland.
754 *

--- 1581 unchanged lines hidden ---
750 return (error);
751}
752
753/*------------------------------------------------------------------------*
754 * ugen_get_iface_driver
755 *
756 * This function generates an USB interface description for userland.
757 *

--- 1581 unchanged lines hidden ---