From patchwork Wed Dec 9 13:07:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ley Foon Tan X-Patchwork-Id: 7808431 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E44F49F350 for ; Wed, 9 Dec 2015 13:08:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1351D204AE for ; Wed, 9 Dec 2015 13:08:27 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F25D5204A9 for ; Wed, 9 Dec 2015 13:08:25 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E22DFE4F; Wed, 9 Dec 2015 13:08:25 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D87C9E53 for ; Wed, 9 Dec 2015 13:08:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0091.outbound.protection.outlook.com [157.56.110.91]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1EFBBDF for ; Wed, 9 Dec 2015 13:08:24 +0000 (UTC) Received: from BLUPR03CA006.namprd03.prod.outlook.com (10.255.124.23) by BLUPR0301MB2065.namprd03.prod.outlook.com (10.164.22.143) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 13:08:21 +0000 Received: from BY2FFO11FD045.protection.gbl (10.255.124.4) by BLUPR03CA006.outlook.office365.com (10.255.124.23) with Microsoft SMTP Server (TLS) id 15.1.355.16 via Frontend Transport; Wed, 9 Dec 2015 13:08:21 +0000 Authentication-Results: spf=softfail (sender IP is 66.35.236.227) smtp.mailfrom=altera.com; lists.linuxfoundation.org; dkim=none (message not signed) header.d=none; lists.linuxfoundation.org; dmarc=none action=none header.from=altera.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning altera.com discourages use of 66.35.236.227 as permitted sender) Received: from sj-itexedge03.altera.priv.altera.com (66.35.236.227) by BY2FFO11FD045.mail.protection.outlook.com (10.1.15.177) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Wed, 9 Dec 2015 13:08:21 +0000 Received: from sj-mail01.altera.com (137.57.1.6) by webmail.altera.com (66.35.236.227) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 9 Dec 2015 05:07:23 -0800 Received: from ubuntu (pg-lftan-440b.altera.priv.altera.com [137.57.93.25]) by sj-mail01.altera.com (8.13.7+Sun/8.13.7) with SMTP id tB9D8GPo028320; Wed, 9 Dec 2015 05:08:17 -0800 (PST) Received: by ubuntu (sSMTP sendmail emulation); Wed, 09 Dec 2015 21:08:10 +0800 From: Ley Foon Tan To: Date: Wed, 9 Dec 2015 21:07:25 +0800 Message-ID: <1449666448-31276-5-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449666448-31276-1-git-send-email-lftan@altera.com> References: <1449666448-31276-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD045; 1:mMPbM5U1R4YobF0KMWjm1eKDxPsXRoPSQ8zHTTVRO+YbMaYv4/immzSoJl5nMLhGwzEmPJ3qNpU6FB9gS8VmLVCx3qtoZadGf1fxJ7dP55x0OlfBHqAOA4RWjV6TZCR7PvqYtUh/lYBPEhVyQyrOnjvHJ984dgRcNinW2DThLBRIe/5PdoDqwCTh+T7MYM/gALqqVryzDymWyBWwWwkiX6VOgsQAjy86qGPcfmP4GdGDZWm1pFVfGsTUuzicviBMZ/KYdWs90E+FQkCWqevXtkaj/7GG2rT/Qtsu1Dwmag5HSF9aq9CDbTzydIALt9aogbQtYaoJmI5LIORwLsUaUpCWUMoNUU6XoIn6ADjq4KgZNLHDnHT0MIoEadTBxCmtPdzrUq/BEo1DPlmBFaBY8Q== X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(189002)(199003)(2950100001)(50986999)(110136002)(19580395003)(5003940100001)(50466002)(48376002)(87936001)(11100500001)(50226001)(105596002)(229853001)(2351001)(76176999)(42186005)(106466001)(36756003)(5008740100001)(5001960100002)(92566002)(189998001)(81156007)(1220700001)(586003)(1096002)(97736004)(6806005)(86362001)(47776003)(19580405001)(33646002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB2065; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2065; 2:QdZkXQMizHKCPKRFXYXbakntjHHHDw/23yXV7+KTx0W9aRy9nQHVfGXDYfcGL4sjQ+r1ZH2hkS6rRjNTq+1on96faFlPwx4aLUGkAqBwFHml2l2ss3m56QtNKmy0sz0fWEYF4HKJEhkPk7b8tEnUiQ==; 3:D1I6wSUUZ5GNq2d0+v/fL+2k+FF/CPWxZZwMYxOWmSijItAifbvjAl1nacpSeUgNJHNEnvUinHMXEp9ZTIROGOTpurbGqR2WBvWUQtnHUgUI2u5a/KdL3pl4j7UTjrGK2348vkIkhKi+6a1JBJW1tc+UoPVBjPF68V31jSUc6brTGnaeclgOUWB+4mzV0zpKXYvBMy+jyDuEw9tK93QtkpxrlIl4hGclXztaVCMk0GY=; 25:yKxKUObCLvYr846m0CT/yyJaK/fX6khEn/DUkSBFqzG++pXHbUndz44x8cG7GLD5brsa53oNZ7gl9dtaYAF/RV+Njyz5dklUwBcK+nqZAZSNR+1NLSvlchyroeCI1nlGLlXQe4+/U5tHreoGVuXAvuEJ3DPPgP8m3g7hpigq2SQfYe7bmTennZ45PokiNfm3QdD35ZemWu8kHpOLb+FQ116vQjYjFXzuI3I3iNhfTRjhZ3sjphXHhemjtVr9m/McDWaf5RyhSrHGI7QnU4xC+Q==; 20:Tv6UVKlj3ZzGN6G20FhQQ8BfP8+ls7kliPS9sYex5Ny8KjZvGrSzqHzx80UIXyfzoYfR6WeLWYHzYdK9uiXxrn3tWpZoJOJK480T155qY27VAtQU3XI8ZVSu6u4IJfpBm4PfIJmCT0EOZD/uFK4MO9n4JuViEYPyh1Wm0GM94LA= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2065; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:BLUPR0301MB2065; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB2065; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2065; 4:ht+N8arC6D3tIs5k1KZrKMFELIFg7vkItnsBsA7jrjk+x2G3TNrtZSpaGmn8H8tArYRNtLXrt5Yi18DxbSBJCRA5S4pbEx9dFXzztWwC6K8/9extURDRLYeVD6lxkPi1dmG6EyHiiMqu3IUtwrmOTDrdbR67FKSPI78Zr+tco7tz/qpQ4DuYRdDxJNt+eNX9zAZ+G9oGT62OfQIC3t5Wqfzxjuc2CI1eRDk9xQRs5UkTB5fRiECnE1LaOevWrsKB/HqEkUD6S5T9FPJXeUFPsU57zZEe/TENd2OCJ3zqtGGwGdR3ZNbrm6GbK5phDn0kfwETdMmyGZzPc0TrwAihHy1pgLkzLdn4fmi5o9KLxaDyBQQF7S1sTfFJg8L6FFM5e/SuvQZxlu+JmudVQUuczNMdj+1VCudCcXHK0/b3Q9ndGt7WqM3NDwU7b3mLmQ07gK8UNg0yJoKyUJTjbWBglA== X-Forefront-PRVS: 0785459C39 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB2065; 23:4IeFhP/HVEgOw35VP0vJChOuYHbcC30wPsCo5LW?= =?us-ascii?Q?kA5UT/v3ioS796rTLGhxwvJCTGEy80Hlcc9fqhCKEkzHUjin2zA7AiW9XGTZ?= =?us-ascii?Q?ZQaoUVEc75mvPwcxKEBMyKhnSwCzzQ2FcJnQu+GIgRCUsXv0sVGRxY1PpaUD?= =?us-ascii?Q?tnQps24PrIpI49PDMd2MEZmdUVowotrIIvs5Djob0RbxsGShlLDEz7FBppNd?= =?us-ascii?Q?NBvo2K8iNeMsaCahcD5hTA600K2cLAq1FDT3ZPNro19fZEHPSMzCj+2TUgP4?= =?us-ascii?Q?/zhfonaIoGD5Ao9lrcaQS2Lwa8q4hoKoMGHAa+wEMON1FjdwmX7oT8gOlCsv?= =?us-ascii?Q?JFl31nxxX1BCcogcZf+o/O2dbs2bs37b09xrulzBL8AgflPHK2CMb7x/h0k1?= =?us-ascii?Q?FTR4s+XPLmRfZjhdXkHZkfYk7v7wflATfvxHHP8ruSQ+O8cCyQaPWX/iVKzl?= =?us-ascii?Q?Y9jT0aCwzLvkL4l+0nrjnszVC4yA6E5Se3RR7o4voE7YBWYga3b8gLYpjWMJ?= =?us-ascii?Q?tMXui0qd84sXVZogs98WtZj4ZlrfBSKDXwnfN7IIMXEyGTDTAaUT+J0emM84?= =?us-ascii?Q?HTZAEpWX5oIcX1ddnQ3Qq7keDa+xPur2ZOUHxfglBwIUtEHctTatzPMwMpJL?= =?us-ascii?Q?vJcJ0iztz3gzDrwdOyLBDxQb41fyMLDh9khdvZ9rhganBd/VFyhc+hxBGLiT?= =?us-ascii?Q?Vev/4fsj/TiqRvurIjbjeekb+wRlk/+v4n4OKefZVEhc96XRAwgP0CzHNQNY?= =?us-ascii?Q?8gjRRnAuNiL48gh8sWDs2mj7P8IkkD4s03RpOd37ZrCYG44Numz5ACtLv0DR?= =?us-ascii?Q?kV1iEzaut2QYzz7EyREVoZtUsRub+x6V2MP2hIymKBVN24Z+wNkjpIbKLLFl?= =?us-ascii?Q?eP29tICZqcggF4ForOHmuxtokZ1B6y9SJSijhVPW0WOQUbYdBtjEQ0ep93bh?= =?us-ascii?Q?qNnDQ5CH8a1ALUEmViMMQBkkaiYItCLdO7cEhRZM/yQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2065; 5:s4ylJ124fReSkQVYVjErbAQ0XyO0RJ9AYoqCAiWBuMlrDr0SbnbW5yksUagZt8T/ZQg48DcCop1IF3kS4wBWpmNyIg58q9t6bMATazeULyFVWMUuwfrSZvn0BrVJZ66vhYKRtkgVbEC1wyI7dyhN2g==; 24:FxvUiYeQHIBP9xneXE3ueKbUDDRgANCikDPNTFUGU0pxGUOGLU7KzDvBqF1Aa3R2gHmsI/7ieyRqRP2D/c1pHj7mPeTQIT0m0KI1IWLn6kk=; 20:gN1xEixAp5XbmnGpOq1+aQ+BNt3OoZ89HK8i6pVj7FyY9CwoLnNbozgh+b8RacwdLQUqab6kdkLZZibmEKdyx6JTHby+oeGogKRqsTXPLXIFgCCfazfTC57njPpOTvPnPgU6PyuO9306e46NSUQjPxAoOyxi6UNhCIOjwdKhn0M= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 13:08:21.2868 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a; Ip=[66.35.236.227]; Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB2065 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org Cc: ltsi-dev@lists.linuxfoundation.org, Dan Carpenter Subject: [LTSI-dev] [PATCH 4/7] PCI: altera: Fix loop in tlp_read_packet() X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Carpenter TLP_LOOP is 500 and the "loop" variable was a u8 so "loop < TLP_LOOP" is always true. We only need this condition to work if there is a problem so it would have been easy to miss this in testing. Make it a normal for loop with "int i" instead of over thinking things and making it complicated. Fixes: 6bb4dd154ae8 ("PCI: altera: Add Altera PCIe host controller driver") Signed-off-by: Dan Carpenter Signed-off-by: Bjorn Helgaas Acked-by: Ley Foon Tan --- drivers/pci/host/pcie-altera.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index 5d01809..0ff6b00 100644 --- a/drivers/pci/host/pcie-altera.c +++ b/drivers/pci/host/pcie-altera.c @@ -176,7 +176,7 @@ static bool altera_pcie_valid_config(struct altera_pcie *pcie, static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) { - u8 loop; + int i; bool sop = 0; u32 ctrl; u32 reg0, reg1; @@ -185,7 +185,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) * Minimum 2 loops to read TLP headers and 1 loop to read data * payload. */ - for (loop = 0; loop < TLP_LOOP; loop++) { + for (i = 0; i < TLP_LOOP; i++) { ctrl = cra_readl(pcie, RP_RXCPL_STATUS); if ((ctrl & RP_RXCPL_SOP) || (ctrl & RP_RXCPL_EOP) || sop) { reg0 = cra_readl(pcie, RP_RXCPL_REG0);