usb_generic.c (250201) | usb_generic.c (250207) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 250201 2013-05-03 07:44:58Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 250207 2013-05-03 11:10: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. --- 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); | 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) { | 691 if (cdesc == NULL) |
692 return (ENXIO); | 692 return (ENXIO); |
693 } | |
694 free_data = 0; 695 696 } else { | 693 free_data = 0; 694 695 } else { |
696#if (USB_HAVE_FIXED_CONFIG == 0) |
|
697 if (usbd_req_get_config_desc_full(udev, | 697 if (usbd_req_get_config_desc_full(udev, |
698 NULL, &cdesc, M_USBDEV, 699 ugd->ugd_config_index)) { | 698 NULL, &cdesc, ugd->ugd_config_index)) { |
700 return (ENXIO); 701 } 702 free_data = 1; | 699 return (ENXIO); 700 } 701 free_data = 1; |
702#else 703 /* configuration descriptor data is shared */ 704 return (EINVAL); 705#endif |
|
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 | 706 } 707 708 len = UGETW(cdesc->wTotalLength); 709 if (len > ugd->ugd_maxlen) { 710 len = ugd->ugd_maxlen; 711 } 712 DPRINTFN(6, "len=%u\n", len); 713 714 ugd->ugd_actlen = len; 715 ugd->ugd_offset = 0; 716 717 error = copyout(cdesc, ugd->ugd_data, len); 718 |
716 if (free_data) { 717 free(cdesc, M_USBDEV); 718 } | 719 if (free_data) 720 usbd_free_config_desc(udev, cdesc); 721 |
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 --- | 722 return (error); 723} 724 725/* 726 * This function is called having the enumeration SX locked which 727 * protects the scratch area used. 728 */ 729static int --- 1625 unchanged lines hidden --- |