Deleted Added
sdiff udiff text old ( 250201 ) new ( 250207 )
full compact
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 250201 2013-05-03 07:44:58Z 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.

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

683
684 if (ugd->ugd_data == NULL) {
685 /* userland pointer should not be zero */
686 return (EINVAL);
687 }
688 if ((ugd->ugd_config_index == USB_UNCONFIG_INDEX) ||
689 (ugd->ugd_config_index == udev->curr_config_index)) {
690 cdesc = usbd_get_config_descriptor(udev);
691 if (cdesc == NULL) {
692 return (ENXIO);
693 }
694 free_data = 0;
695
696 } else {
697 if (usbd_req_get_config_desc_full(udev,
698 NULL, &cdesc, M_USBDEV,
699 ugd->ugd_config_index)) {
700 return (ENXIO);
701 }
702 free_data = 1;
703 }
704
705 len = UGETW(cdesc->wTotalLength);
706 if (len > ugd->ugd_maxlen) {
707 len = ugd->ugd_maxlen;
708 }
709 DPRINTFN(6, "len=%u\n", len);
710
711 ugd->ugd_actlen = len;
712 ugd->ugd_offset = 0;
713
714 error = copyout(cdesc, ugd->ugd_data, len);
715
716 if (free_data) {
717 free(cdesc, M_USBDEV);
718 }
719 return (error);
720}
721
722/*
723 * This function is called having the enumeration SX locked which
724 * protects the scratch area used.
725 */
726static int

--- 1625 unchanged lines hidden ---