All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ley Foon Tan <lftan@altera.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	rfi@lists.rocketboards.org, linux-pci@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [patch] PCI: altera: fix loop in tlp_read_packet()
Date: Wed, 04 Nov 2015 13:39:36 +0000	[thread overview]
Message-ID: <20151104133936.GI20966@mwanda> (raw)

The problem is that 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.  Anyway, lets just 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 <dan.carpenter@oracle.com>

diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index e5dda38..b05de63 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -166,16 +166,16 @@ static bool altera_pcie_valid_config(struct altera_pcie *pcie,
 
 static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
 {
-	u8 loop;
 	bool sop = 0;
 	u32 ctrl;
 	u32 reg0, reg1;
+	int i;
 
 	/*
 	 * 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);

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ley Foon Tan <lftan@altera.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	rfi@lists.rocketboards.org, linux-pci@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [patch] PCI: altera: fix loop in tlp_read_packet()
Date: Wed, 4 Nov 2015 16:39:36 +0300	[thread overview]
Message-ID: <20151104133936.GI20966@mwanda> (raw)

The problem is that 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.  Anyway, lets just 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 <dan.carpenter@oracle.com>

diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index e5dda38..b05de63 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -166,16 +166,16 @@ static bool altera_pcie_valid_config(struct altera_pcie *pcie,
 
 static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
 {
-	u8 loop;
 	bool sop = 0;
 	u32 ctrl;
 	u32 reg0, reg1;
+	int i;
 
 	/*
 	 * 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);

             reply	other threads:[~2015-11-04 13:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 13:39 Dan Carpenter [this message]
2015-11-04 13:39 ` [patch] PCI: altera: fix loop in tlp_read_packet() Dan Carpenter
2015-11-05  1:56 ` Ley Foon Tan
2015-11-05  1:56   ` Ley Foon Tan
2015-11-25 18:03 ` Bjorn Helgaas
2015-11-25 18:03   ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151104133936.GI20966@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=bhelgaas@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lftan@altera.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=rfi@lists.rocketboards.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.