From patchwork Fri Apr 12 11:04:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 16079 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7DAF26EB0 for ; Fri, 12 Apr 2013 11:07:08 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id t11sf2983994wey.2 for ; Fri, 12 Apr 2013 04:06:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe; bh=zVYLbkhthy7oNjoqP24dQA96Ts0NNCr9jU4wE6x+sWE=; b=ioQDwg03VNB7q3VuZLA9BbeZmzXRqnKL678uAmaZM6yebsRhRUMXlLaTKFa+IIPRfZ /ujL52EgmzuFqunMaAFLN+/SbelJlXl3sFYIp6d7FmPzxDA3gfEG0upbFZo8SB75WLxC 8mpzcR/LJm7ndXYkR5j3ll2kzsYQINPpHVT6z54BmKp70K2SCKIks/ZskziGy8/qYLRR DPifnneID9MRwd5xx7k3CtC3vwtrRXYByug7cjGyOOuv4bhfODmcXiI7HdU/+v2dt6sV ckB1zcpHnzhpPVri2vHHn+guA64l5feueaDmeNwT9gwXIYzztOVCKQ4FO6nqb6l4K9oP lI4Q== X-Received: by 10.180.75.82 with SMTP id a18mr752168wiw.0.1365764804468; Fri, 12 Apr 2013 04:06:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.24.201 with SMTP id w9ls475621wif.23.gmail; Fri, 12 Apr 2013 04:06:44 -0700 (PDT) X-Received: by 10.180.13.34 with SMTP id e2mr3230966wic.29.1365764804289; Fri, 12 Apr 2013 04:06:44 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id ft9si700197wib.69.2013.04.12.04.06.43 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Apr 2013 04:06:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id cy12so2293887veb.18 for ; Fri, 12 Apr 2013 04:06:43 -0700 (PDT) X-Received: by 10.220.242.73 with SMTP id lh9mr7907549vcb.49.1365764802872; Fri, 12 Apr 2013 04:06:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp60867veb; Fri, 12 Apr 2013 04:06:42 -0700 (PDT) X-Received: by 10.66.148.97 with SMTP id tr1mr4291688pab.49.1365764801675; Fri, 12 Apr 2013 04:06:41 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id iv6si8870291pac.270.2013.04.12.04.06.40; Fri, 12 Apr 2013 04:06:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ML5003X82UZLMQ0@mailout3.samsung.com> for patches@linaro.org; Fri, 12 Apr 2013 20:06:40 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 74.35.20872.FBAE7615; Fri, 12 Apr 2013 20:06:40 +0900 (KST) X-AuditID: cbfee68d-b7f786d000005188-18-5167eabf7355 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EE.09.13494.FBAE7615; Fri, 12 Apr 2013 20:06:39 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.214.169]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ML500IF52UIWD90@mmp2.samsung.com>; Fri, 12 Apr 2013 20:06:39 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Cc: u-boot-review@google.com, patches@linaro.org, marex@denx.de, rajeshwari.s@samsung.com, sjg@chromium.org, vikas.sajjan@samsung.com, amarendra.xt@samsung.com, vipin.kumar@st.com, gautam.vivek@samsung.com Subject: [PATCH v3 2/8] USB: Some cleanup prior to USB 3.0 interface addition Date: Fri, 12 Apr 2013 16:34:34 +0530 Message-id: <1365764680-10917-3-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1365764680-10917-1-git-send-email-gautam.vivek@samsung.com> References: <1365764680-10917-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsWyRsSkSvfAq/RAg91PGC2+LOhkt2i7cpDd 4k1bI6PFlMNfWCxa1h5gtfi2ZRujxfLXG9kt3u4FKrn5bDuTxb9L11gduDxmN1xk8Zg36wSL x4JNpR53ru1h8zh7ZwejR9+WVYweT3/sZQ5gj+KySUnNySxLLdK3S+DK+LVwAWPBDvWKHaf+ MDcw9st3MXJySAiYSC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hz+xkziM0p4ClxfulbsHohoJqV/btZJjDyLmBk WMUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kRHHnPpHcwrmqwOMQowMGoxMP7Qjg9UIg1say4 MvcQowQHs5IIb8zetEAh3pTEyqrUovz4otKc1OJDjMlAV01klhJNzgcmhbySeENjE3NTY1NL EwsTM0vShJXEeQ+2WgcKCaQnlqRmp6YWpBbBbGHi4JRqYIxaE+vaYpK++dRVE/XqpS2Rs7sZ NQT3fQ3Nub1z6t+oWwu3F+RcVHBzb2J7qXVlejrHjNMVz1qenpx2xztQZqEQ/wbz+oYlus77 Dphcbo3TDV33LkXH16v9sKrQDrOLW1Xnpeg5To/hKo2Ksgi+dj1Q92O4+g6Jjz8+7AgyXMte c41rE3fgFiWW4oxEQy3mouJEAI9VyCUAAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQlgFHILbj9zj9YtEefnIp6VAzpGWVQBqPmZQwga+KSCiLCKmZjSK09mM0cB2q+WXoTg5sDT X-Original-Sender: gautam.vivek@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Some cleanup in usb framework, nothing much on feature side. Signed-off-by: Vikas C Sajjan Signed-off-by: Vivek Gautam --- Changes from v2: - none common/usb.c | 21 +++++++++++++-------- common/usb_storage.c | 30 ++++++++++++++++-------------- include/usb_defs.h | 2 +- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/common/usb.c b/common/usb.c index 50fa466..8407974 100644 --- a/common/usb.c +++ b/common/usb.c @@ -348,6 +348,7 @@ static int usb_parse_config(struct usb_device *dev, struct usb_descriptor_header *head; int index, ifno, epno, curr_if_num; u16 ep_wMaxPacketSize; + struct usb_interface *if_desc = NULL; ifno = -1; epno = -1; @@ -375,23 +376,27 @@ static int usb_parse_config(struct usb_device *dev, &buffer[index])->bInterfaceNumber != curr_if_num) { /* this is a new interface, copy new desc */ ifno = dev->config.no_of_if; + if_desc = &dev->config.if_desc[ifno]; dev->config.no_of_if++; - memcpy(&dev->config.if_desc[ifno], - &buffer[index], buffer[index]); - dev->config.if_desc[ifno].no_of_ep = 0; - dev->config.if_desc[ifno].num_altsetting = 1; + memcpy(if_desc, &buffer[index], buffer[index]); + if_desc->no_of_ep = 0; + if_desc->num_altsetting = 1; curr_if_num = - dev->config.if_desc[ifno].desc.bInterfaceNumber; + if_desc->desc.bInterfaceNumber; } else { /* found alternate setting for the interface */ - dev->config.if_desc[ifno].num_altsetting++; + if (ifno >= 0) { + if_desc = &dev->config.if_desc[ifno]; + if_desc->num_altsetting++; + } } break; case USB_DT_ENDPOINT: epno = dev->config.if_desc[ifno].no_of_ep; + if_desc = &dev->config.if_desc[ifno]; /* found an endpoint */ - dev->config.if_desc[ifno].no_of_ep++; - memcpy(&dev->config.if_desc[ifno].ep_desc[epno], + if_desc->no_of_ep++; + memcpy(&if_desc->ep_desc[epno], &buffer[index], buffer[index]); ep_wMaxPacketSize = get_unaligned(&dev->config.\ if_desc[ifno].\ diff --git a/common/usb_storage.c b/common/usb_storage.c index 983cbab..2651042 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -269,9 +269,9 @@ int usb_stor_scan(int mode) lun++) { usb_dev_desc[usb_max_devs].lun = lun; if (usb_stor_get_info(dev, &usb_stor[start], - &usb_dev_desc[usb_max_devs]) == 1) { - usb_max_devs++; - } + &usb_dev_desc[usb_max_devs]) == 1) { + usb_max_devs++; + } } } /* if storage device */ @@ -504,7 +504,7 @@ static int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) dir_in = US_DIRECTION(srb->cmd[0]); #ifdef BBB_COMDAT_TRACE - printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n", + printf("dir %d lun %d cmdlen %d cmd %p datalen %lu pdata %p\n", dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen, srb->pdata); if (srb->cmdlen) { @@ -1209,6 +1209,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, { struct usb_interface *iface; int i; + struct usb_endpoint_descriptor *ep_desc; unsigned int flags = 0; int protocol = 0; @@ -1291,24 +1292,25 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, * We will ignore any others. */ for (i = 0; i < iface->desc.bNumEndpoints; i++) { + ep_desc = &iface->ep_desc[i]; /* is it an BULK endpoint? */ - if ((iface->ep_desc[i].bmAttributes & + if ((ep_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { - if (iface->ep_desc[i].bEndpointAddress & USB_DIR_IN) - ss->ep_in = iface->ep_desc[i].bEndpointAddress & - USB_ENDPOINT_NUMBER_MASK; + if (ep_desc->bEndpointAddress & USB_DIR_IN) + ss->ep_in = ep_desc->bEndpointAddress & + USB_ENDPOINT_NUMBER_MASK; else ss->ep_out = - iface->ep_desc[i].bEndpointAddress & + ep_desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } /* is it an interrupt endpoint? */ - if ((iface->ep_desc[i].bmAttributes & - USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { - ss->ep_int = iface->ep_desc[i].bEndpointAddress & - USB_ENDPOINT_NUMBER_MASK; - ss->irqinterval = iface->ep_desc[i].bInterval; + if ((ep_desc->bmAttributes & + USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { + ss->ep_int = ep_desc->bEndpointAddress & + USB_ENDPOINT_NUMBER_MASK; + ss->irqinterval = ep_desc->bInterval; } } debug("Endpoints In %d Out %d Int %d\n", diff --git a/include/usb_defs.h b/include/usb_defs.h index 9502544..0c78d9d 100644 --- a/include/usb_defs.h +++ b/include/usb_defs.h @@ -234,7 +234,7 @@ #define HUB_CHAR_OCPM 0x0018 /* - *Hub Status & Hub Change bit masks + * Hub Status & Hub Change bit masks */ #define HUB_STATUS_LOCAL_POWER 0x0001 #define HUB_STATUS_OVERCURRENT 0x0002