From patchwork Wed Apr 24 12:50:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 16380 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5825E23918 for ; Wed, 24 Apr 2013 12:55:10 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 1sf3466075qee.7 for ; Wed, 24 Apr 2013 05:54:19 -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=UyVILRcg2NGEdYtsDjwN2jE1QVZt7PSteSzadENXwkk=; b=YBgnxWwTVgBVLKRPoGw7WC6RecUnnsLOd2PuyTDqhruDZwdFUSSCjIlngZCm3roFuQ OdzDe0co49hFGi9P5U/sqtHTVaI1C8cSB4jZkmnj/FBRHM7eAmiii5nQFRht4v4BaQ/y JZiVC+Bzb/vZtYRA414FBFBF4Nkq2tKv1rdOGpKrgcXFYA+nCoqERDgJpoahKcVImVjR 89cI+0wHn0gcfomf1vTiK3d+wINI8/gZDiZgYnyGz0woClz2QfjMB8u3TSJ/i++uqzl8 8vkk2YbjiNMjbNxIA2H10pDn2YPNV1xW2housY52drnhTOK0Ty1e9EeWAqjFVHzXwkWc 1M2w== X-Received: by 10.224.10.6 with SMTP id n6mr21034166qan.4.1366808059413; Wed, 24 Apr 2013 05:54:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.166 with SMTP id w6ls815363qeu.14.gmail; Wed, 24 Apr 2013 05:54:19 -0700 (PDT) X-Received: by 10.220.8.75 with SMTP id g11mr24994167vcg.60.1366808059323; Wed, 24 Apr 2013 05:54:19 -0700 (PDT) Received: from mail-vb0-x22f.google.com (mail-vb0-x22f.google.com [2607:f8b0:400c:c02::22f]) by mx.google.com with ESMTPS id oy17si1198469vcb.10.2013.04.24.05.54.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Apr 2013 05:54:19 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22f; Received: by mail-vb0-f47.google.com with SMTP id x13so1595777vbb.20 for ; Wed, 24 Apr 2013 05:54:19 -0700 (PDT) X-Received: by 10.58.188.48 with SMTP id fx16mr25086108vec.22.1366808059201; Wed, 24 Apr 2013 05:54:19 -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 nf2csp172586veb; Wed, 24 Apr 2013 05:54:18 -0700 (PDT) X-Received: by 10.68.176.197 with SMTP id ck5mr46158600pbc.165.1366808058166; Wed, 24 Apr 2013 05:54:18 -0700 (PDT) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id uh1si2842841pab.297.2013.04.24.05.54.17 for ; Wed, 24 Apr 2013 05:54:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MLR00GWWFTNWN21@mailout4.samsung.com> for patches@linaro.org; Wed, 24 Apr 2013 21:54:16 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id AF.76.22414.8F5D7715; Wed, 24 Apr 2013 21:54:16 +0900 (KST) X-AuditID: cbfee691-b7f0e6d00000578e-1a-5177d5f89a75 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 08.85.10837.8F5D7715; Wed, 24 Apr 2013 21:54:16 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.214.169]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MLR00K76FQAD320@mmp1.samsung.com>; Wed, 24 Apr 2013 21:54:16 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de, marex@denx.de Cc: jwerner@chromium.org, u-boot-review@google.com, patches@linaro.org, rajeshwari.s@samsung.com, vikas.sajjan@samsung.com Subject: [PATCH 3/3] usb: common: Use a global definition for 'min3' Date: Wed, 24 Apr 2013 18:20:13 +0530 Message-id: <1366807813-10481-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1366807813-10481-1-git-send-email-gautam.vivek@samsung.com> References: <1366807813-10481-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRmVeSWpSXmKPExsWyRsSkVvfH1fJAg6srLCw6Dj1msnjT1sho MeXwFxaLlrUHWC2Wv97IbvF2bye7xc1n25kc2D1mN1xk8Zg36wSLx4JNpR53ru1h8zh7Zwej R9+WVYwBbFFcNimpOZllqUX6dglcGavbu1gKXvJXNN/1bmC8yt3FyMkhIWAicf/xBnYIW0zi wr31bCC2kMBSRommkxIwNUcfnmHtYu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HGIU4GBU4uF9MassUIg1say4MvcQowQHs5II76Zt5YFCvCmJlVWp RfnxRaU5qcWHGJOBjprILCWanA+M9LySeENjE3NTY1NLEwsTM0vShJXEeQ+0WgcKCaQnlqRm p6YWpBbBbGHi4JRqYJzI23n5lOrbkCcSK5N3e7OtYLDI2+1upM977I6ayvrLT+suczxUqp0m 6vlogUM6N6fGnucsDocvVW84xrGhYnaxksnWVdofefaKW7Dde2x06ZqWtNG7XoEqxss3DzFG K92yl+9+XnnRvE58AZfnntWTz87U1tj+4sgOj+uGR1lkjY8o3lzQmKHEUpyRaKjFXFScCACH oA+46gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnXxX4tQb0lJOavyeQVNUlMcEoiHG4b/+jbn7LXHjjFstw/aXmXwIY34xl9dT+uCy0585um X-Original-Sender: gautam.vivek@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22f 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: , We can use a common global method for calculating minimum of 3 numbers. Put the same in 'common header' and let 'ehci' use it. Signed-off-by: Vivek Gautam Acked-by: Tom Rini --- drivers/usb/host/ehci-hcd.c | 10 ---------- include/common.h | 25 +++++++++++++++++++++---- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 19d4352..e0f3e4b 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -603,16 +603,6 @@ fail: return -1; } -static inline int min3(int a, int b, int c) -{ - - if (b < a) - a = b; - if (c < a) - a = c; - return a; -} - int ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, int length, struct devrequest *req) diff --git a/include/common.h b/include/common.h index 0cfa6a8..b0258a0 100644 --- a/include/common.h +++ b/include/common.h @@ -199,18 +199,35 @@ typedef void (interrupt_handler_t)(void *); * General Purpose Utilities */ #define min(X, Y) \ - ({ typeof (X) __x = (X); \ - typeof (Y) __y = (Y); \ + ({ typeof(X) __x = (X); \ + typeof(Y) __y = (Y); \ (__x < __y) ? __x : __y; }) #define max(X, Y) \ - ({ typeof (X) __x = (X); \ - typeof (Y) __y = (Y); \ + ({ typeof(X) __x = (X); \ + typeof(Y) __y = (Y); \ (__x > __y) ? __x : __y; }) #define MIN(x, y) min(x, y) #define MAX(x, y) max(x, y) +#define min3(X, Y, Z) \ + ({ typeof(X) __x = (X); \ + typeof(Y) __y = (Y); \ + typeof(Z) __z = (Z); \ + __x < __y ? (__x < __z ? __x : __z) : \ + (__y < __z ? __y : __z); }) + +#define max3(X, Y, Z) \ + ({ typeof(X) __x = (X); \ + typeof(Y) __y = (Y); \ + typeof(Z) __z = (Z); \ + __x > __y ? (__x > __z ? __x : __z) : \ + (__y > __z ? __y : __z); }) + +#define MIN3(x, y, z) min3(x, y, z) +#define MAX3(x, y, z) max3(x, y, z) + /* * Return the absolute value of a number. *