From patchwork Wed Mar 27 09:28:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 15677 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E57A823E10 for ; Wed, 27 Mar 2013 09:31:26 +0000 (UTC) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by fiordland.canonical.com (Postfix) with ESMTP id 8C749A18117 for ; Wed, 27 Mar 2013 09:31:26 +0000 (UTC) Received: by mail-vb0-f48.google.com with SMTP id fc21so4996034vbb.21 for ; Wed, 27 Mar 2013 02:31:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=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; bh=fQgnCS26q9esO/sSTHfljOJzlSWcJSN4oZK978VwoiI=; b=dkZJNlCfq0knnFALquW0s9xZ+C8H9c2fM4xnZgZ3Tv9awTZVe3O/0hJI5H4o0gQmEI 7NQ+tcfY4mMBVhKJ4W2nQHYpq7TfTpYTRhu11UWzOmj4HV45Ivdd9TTMEujkT9DVazFb iXi16CnW7m7wSAJFNM0mbvxFc7kI+DNSejMFyf2NjNw4H5m8qEIs0PTNEYtWiHNxXhQK 3HACEbFwCGH9Z1R6vAr8qOPrwka/7zY4ho7O4tZWpvUNSP2rsuuy+PTmoOE0yObROGCM dKf7agil/PNUneiWmpmzKJvjVwxIYNErsYTPy0KTqhyF865gyWmw+1PjTTUvaFF6Nz9P ec1g== X-Received: by 10.52.20.239 with SMTP id q15mr19295421vde.73.1364376686058; Wed, 27 Mar 2013 02:31:26 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp107571ved; Wed, 27 Mar 2013 02:31:25 -0700 (PDT) X-Received: by 10.68.12.103 with SMTP id x7mr12067915pbb.37.1364376684880; Wed, 27 Mar 2013 02:31:24 -0700 (PDT) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id as5si4496543pbd.26.2013.03.27.02.31.24; Wed, 27 Mar 2013 02:31:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.24 as permitted sender) smtp.mail=gautam.vivek@samsung.com Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKB00EHPBSBA3J0@mailout1.samsung.com> for patches@linaro.org; Wed, 27 Mar 2013 18:31:23 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 62.CC.07735.B6CB2515; Wed, 27 Mar 2013 18:31:23 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-16-5152bc6b4f69 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id F8.A7.17838.B6CB2515; Wed, 27 Mar 2013 18:31:23 +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 <0MKB00C14BRFI6F0@mmp2.samsung.com>; Wed, 27 Mar 2013 18:31:23 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Cc: patches@linaro.org, marex@denx.de, sjg@chromium.org, rajeshwari.s@samsung.com, vikas.sajjan@samsung.com, amarendra.xt@samsung.com Subject: [PATCH 1/7] USB: Some cleanup prior to USB 3.0 interface addition Date: Wed, 27 Mar 2013 14:58:57 +0530 Message-id: <1364376543-7526-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1364376543-7526-1-git-send-email-gautam.vivek@samsung.com> References: <1364376543-7526-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsWyRsSkWjd7T1CgwaFLUhZfFnSyW7xpa2S0 mHL4C4tFy9oDrBbftmxjtHi7Fyhx89l2Jgd2j9kNF1k85s06weJx59oeNo+zd3YwevRtWcUY wBrFZZOSmpNZllqkb5fAlfFvyhPmgrtqFR/2H2NvYLwu18XIySEhYCIxu/kaO4QtJnHh3nq2 LkYuDiGBpYwSPbMussEULd43GcwWEpjOKHFurRdE0RQmiQUTXzGDJNgEdCWa3u5iBLFFBCQk fvVfZQQpYhZoZ5TYvHE2WLewgJfE8RcbWUBsFgFViQ+zHoGt5hVwlzj39xkTxDYFiTe3n4EN 5RTwkJjxahoLxGZ3iUPn9oANlRBYxC4x6dg5qEECEt8mHwKyOYASshKbDjBDzJGUOLjiBssE RuEFjAyrGEVTC5ILipPSi4z0ihNzi0vz0vWS83M3MQJD/fS/Z307GG8esD7EmAw0biKzlGhy PjBW8kriDY3NjCxMTUyNjcwtzUgTVhLnVWuxDhQSSE8sSc1OTS1ILYovKs1JLT7EyMTBKdXA mLGiWCgtN9VqWcQvrv1ROXsM6xZxeUhcUWu3WB3pdfPLybpn925PypwybVJy+LITstazFq53 OlT4VfLfaol7KUwfAvbnsnaZdJ6aNtl2/8fzGqeN+k5ksiukK6dznLYo23VCmpux1EnprK5x o9jkeYsP6qzSPfxH4THD8rSoG2EO6dwGjq/SlViKMxINtZiLihMBRgpjXYsCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRmVeSWpSXmKPExsVy+t9jQd3sPUGBBq8WClh8WdDJbvGmrZHR YsrhLywWLWsPsFp827KN0eLtXqDEzWfbmRzYPWY3XGTxmDfrBIvHnWt72DzO3tnB6NG3ZRVj AGtUA6NNRmpiSmqRQmpecn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtAh SgpliTmlQKGAxOJiJX07TBNCQ9x0LWAaI3R9Q4LgeowM0EDCGsaMf1OeMBfcVav4sP8YewPj dbkuRk4OCQETicX7JrNB2GISF+6tB7OFBKYzSpxb69XFyAVkT2GSWDDxFTNIgk1AV6Lp7S5G EFtEQELiV/9VRpAiZoF2RonNG2eDdQsLeEkcf7GRBcRmEVCV+DDrETuIzSvgLnHu7zMmiG0K Em9uPwMbyingITHj1TQWiM3uEofO7WGcwMi7gJFhFaNoakFyQXFSeq6hXnFibnFpXrpecn7u JkZwJD2T2sG4ssHiEKMAB6MSD+8MhqBAIdbEsuLK3EOMEhzMSiK8L1YAhXhTEiurUovy44tK c1KLDzEmA101kVlKNDkfGOV5JfGGxibmpsamliYWJmaWpAkrifMeaLUOFBJITyxJzU5NLUgt gtnCxMEp1cAou/rdvfUcW37qXZw96U949Q87w4PnZ0ts0OYy/5/ddnzCsqZJO3asNHl697Zg pWW8ca34RI3mbTsXzns44ZLjreb22fIsXLEvzW5kTF3Lf/FqrMmebel7FbY8q9jv8HTXlHxh k8OJ849M3XNv20HfKunMIO+Lpe1qh5cezFh9Pv+KVvKNLaZHJimxFGckGmoxFxUnAgDvGRmI 6AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm0xcIkBWtcSAm6MB837fSnsOTNb4Zqcq4SZRh8mP+uzPDOToscTlqcslt13z8gdJq+UeDj Some cleanup in usb framework, nothing much on feature side. Signed-off-by: Vikas C Sajjan Signed-off-by: Vivek Gautam --- common/usb.c | 18 ++++++++++-------- common/usb_storage.c | 30 ++++++++++++++++-------------- include/usb_defs.h | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/common/usb.c b/common/usb.c index 6fc0fc1..40c1547 100644 --- a/common/usb.c +++ b/common/usb.c @@ -360,6 +360,7 @@ static int usb_parse_config(struct usb_device *dev, int index, ifno, epno, curr_if_num; int i; u16 ep_wMaxPacketSize; + struct usb_interface *if_desc = NULL; ifno = -1; epno = -1; @@ -387,23 +388,24 @@ 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_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 fb322b4..475c218 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -278,10 +278,10 @@ 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 */ if (usb_max_devs == USB_MAX_STOR_DEV) { @@ -511,7 +511,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) { @@ -1218,6 +1218,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; @@ -1300,24 +1301,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; } } USB_STOR_PRINTF("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