From owner-svn-src-stable-8@FreeBSD.ORG Tue Apr 6 23:24:56 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14DF41065675; Tue, 6 Apr 2010 23:24:56 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A4C7F8FC26; Tue, 6 Apr 2010 23:24:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o36NOttp013171; Tue, 6 Apr 2010 23:24:55 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o36NOt4b013166; Tue, 6 Apr 2010 23:24:55 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201004062324.o36NOt4b013166@svn.freebsd.org> From: Andrew Thompson Date: Tue, 6 Apr 2010 23:24:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206311 - stable/8/sys/dev/usb/template X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 23:24:56 -0000 Author: thompsa Date: Tue Apr 6 23:24:55 2010 New Revision: 206311 URL: http://svn.freebsd.org/changeset/base/206311 Log: MFC r205030 - make the usb_temp_setup() and usb_temp_unsetup() functions public so that other modules can generate USB descriptors. - extend the vendor specific request function by one length pointer argument, because not all descriptors store the length in the first byte. For example HID descriptors. Submitted by: Hans Petter Selasky Modified: stable/8/sys/dev/usb/template/usb_template.c stable/8/sys/dev/usb/template/usb_template.h stable/8/sys/dev/usb/template/usb_template_mtp.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/template/usb_template.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template.c Tue Apr 6 23:24:29 2010 (r206310) +++ stable/8/sys/dev/usb/template/usb_template.c Tue Apr 6 23:24:55 2010 (r206311) @@ -98,13 +98,10 @@ static void *usb_temp_get_config_desc(st static const void *usb_temp_get_string_desc(struct usb_device *, uint16_t, uint8_t); static const void *usb_temp_get_vendor_desc(struct usb_device *, - const struct usb_device_request *); + const struct usb_device_request *, uint16_t *plen); static const void *usb_temp_get_hub_desc(struct usb_device *); static usb_error_t usb_temp_get_desc(struct usb_device *, struct usb_device_request *, const void **, uint16_t *); -static usb_error_t usb_temp_setup(struct usb_device *, - const struct usb_temp_device_desc *); -static void usb_temp_unsetup(struct usb_device *); static usb_error_t usb_temp_setup_by_index(struct usb_device *, uint16_t index); static void usb_temp_init(void *); @@ -1035,7 +1032,7 @@ usb_temp_get_config_desc(struct usb_devi *------------------------------------------------------------------------*/ static const void * usb_temp_get_vendor_desc(struct usb_device *udev, - const struct usb_device_request *req) + const struct usb_device_request *req, uint16_t *plen) { const struct usb_temp_device_desc *tdd; @@ -1046,7 +1043,7 @@ usb_temp_get_vendor_desc(struct usb_devi if (tdd->getVendorDesc == NULL) { return (NULL); } - return ((tdd->getVendorDesc) (req)); + return ((tdd->getVendorDesc) (req, plen)); } /*------------------------------------------------------------------------* @@ -1109,7 +1106,6 @@ usb_temp_get_desc(struct usb_device *ude default: goto tr_stalled; } - break; case UT_READ_CLASS_DEVICE: switch (req->bRequest) { case UR_GET_DESCRIPTOR: @@ -1117,11 +1113,6 @@ usb_temp_get_desc(struct usb_device *ude default: goto tr_stalled; } - break; - case UT_READ_VENDOR_DEVICE: - case UT_READ_VENDOR_OTHER: - buf = usb_temp_get_vendor_desc(udev, req); - goto tr_valid; default: goto tr_stalled; } @@ -1158,7 +1149,6 @@ tr_handle_get_descriptor: default: goto tr_stalled; } - goto tr_stalled; tr_handle_get_class_descriptor: if (req->wValue[0]) { @@ -1168,17 +1158,20 @@ tr_handle_get_class_descriptor: goto tr_valid; tr_valid: - if (buf == NULL) { + if (buf == NULL) goto tr_stalled; - } - if (len == 0) { + if (len == 0) len = buf[0]; - } *pPtr = buf; *pLength = len; return (0); /* success */ tr_stalled: + /* try to get a vendor specific descriptor */ + len = 0; + buf = usb_temp_get_vendor_desc(udev, req, &len); + if (buf != NULL) + goto tr_valid; *pPtr = NULL; *pLength = 0; return (0); /* we ignore failures */ @@ -1195,7 +1188,7 @@ tr_stalled: * 0: Success * Else: Failure *------------------------------------------------------------------------*/ -static usb_error_t +usb_error_t usb_temp_setup(struct usb_device *udev, const struct usb_temp_device_desc *tdd) { @@ -1285,7 +1278,7 @@ error: * This function frees any memory associated with the currently * setup template, if any. *------------------------------------------------------------------------*/ -static void +void usb_temp_unsetup(struct usb_device *udev) { if (udev->usb_template_ptr) { Modified: stable/8/sys/dev/usb/template/usb_template.h ============================================================================== --- stable/8/sys/dev/usb/template/usb_template.h Tue Apr 6 23:24:29 2010 (r206310) +++ stable/8/sys/dev/usb/template/usb_template.h Tue Apr 6 23:24:55 2010 (r206311) @@ -31,7 +31,7 @@ #define _USB_TEMPLATE_H_ typedef const void *(usb_temp_get_string_desc_t)(uint16_t lang_id, uint8_t string_index); -typedef const void *(usb_temp_get_vendor_desc_t)(const struct usb_device_request *req); +typedef const void *(usb_temp_get_vendor_desc_t)(const struct usb_device_request *req, uint16_t *plen); struct usb_temp_packet_size { uint16_t mps[USB_SPEED_MAX]; @@ -98,5 +98,8 @@ extern const struct usb_temp_device_desc extern const struct usb_temp_device_desc usb_template_msc; /* Mass Storage Class */ extern const struct usb_temp_device_desc usb_template_mtp; /* Message Transfer * Protocol */ +usb_error_t usb_temp_setup(struct usb_device *, + const struct usb_temp_device_desc *); +void usb_temp_unsetup(struct usb_device *); #endif /* _USB_TEMPLATE_H_ */ Modified: stable/8/sys/dev/usb/template/usb_template_mtp.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template_mtp.c Tue Apr 6 23:24:29 2010 (r206310) +++ stable/8/sys/dev/usb/template/usb_template_mtp.c Tue Apr 6 23:24:55 2010 (r206311) @@ -211,7 +211,7 @@ const struct usb_temp_device_desc usb_te * Else: Success. Pointer to vendor descriptor is returned. *------------------------------------------------------------------------*/ static const void * -mtp_get_vendor_desc(const struct usb_device_request *req) +mtp_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) { static const uint8_t dummy_desc[0x28] = { 0x28, 0, 0, 0, 0, 1, 4, 0,