* [patch] PCI: altera: fix loop in tlp_read_packet()
@ 2015-11-04 13:39 Dan Carpenter
2015-11-05 1:56 ` Ley Foon Tan
2015-11-25 18:03 ` Bjorn Helgaas
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2015-11-04 13:39 UTC (permalink / raw)
To: Ley Foon Tan; +Cc: Bjorn Helgaas, rfi, linux-pci, kernel-janitors
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] PCI: altera: fix loop in tlp_read_packet()
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-25 18:03 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Ley Foon Tan @ 2015-11-05 1:56 UTC (permalink / raw)
To: Dan Carpenter
Cc: Bjorn Helgaas, Rocketboard Maillist, linux-pci, kernel-janitors
On Wed, Nov 4, 2015 at 9:39 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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>
>
Acked-by: Ley Foon Tan <lftan@altera.com>
Thanks for the fix.
Regards
Ley Foon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] PCI: altera: fix loop in tlp_read_packet()
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-25 18:03 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2015-11-25 18:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ley Foon Tan, Bjorn Helgaas, rfi, linux-pci, kernel-janitors
On Wed, Nov 04, 2015 at 04:39:36PM +0300, Dan Carpenter wrote:
> 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>
Applied with Ley Foon's ack to pci/host-altera for v4.5, thanks!
>
> 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);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-25 18:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-25 18:03 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).