All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Murray <andrew.murray@arm.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org,
	Stuart Hayes <stuart.w.hayes@gmail.com>,
	Alexandru Gagniuc <mr.nuke.me@gmail.com>
Subject: Re: [PATCH v1] PCI: pciehp: Refactor infinite loop in pcie_poll_cmd()
Date: Fri, 8 Nov 2019 10:18:16 +0000	[thread overview]
Message-ID: <20191108101815.GE43905@e119886-lin.cambridge.arm.com> (raw)
In-Reply-To: <20191107223726.GA23651@redsun51.ssa.fujisawa.hgst.com>

On Fri, Nov 08, 2019 at 07:37:26AM +0900, Keith Busch wrote:
> On Fri, Oct 11, 2019 at 12:02:30PM +0300, Andy Shevchenko wrote:
> > No functional changes implied.
> 
> [snip] 
> 
> > -	while (true) {
> > +	do {
> >  		pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
> >  		if (slot_status == (u16) ~0) {
> >  			ctrl_info(ctrl, "%s: no response from device\n",
> > @@ -81,11 +81,9 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
> >  						   PCI_EXP_SLTSTA_CC);
> >  			return 1;
> >  		}
> > -		if (timeout < 0)
> > -			break;
> >  		msleep(10);
> >  		timeout -= 10;
> > -	}
> > +	} while (timeout > 0);
> >  	return 0;	/* timeout */
> >  }
> 
> If you really want to ensure no funcitonal change, I think the end of
> the loop needs to be 'while (timeout >= 0);'

With this suggested change, you can add:

Reviewed-by: Andrew Murray <andrew.murray@arm.com>

I can't get too excited by coding styles, however I find this more
readable now, due to the fact that the loop is clearly bounded.

  reply	other threads:[~2019-11-08 10:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  9:02 [PATCH v1] PCI: pciehp: Refactor infinite loop in pcie_poll_cmd() Andy Shevchenko
2019-11-07 15:15 ` Andy Shevchenko
2019-11-07 17:21   ` Alex G.
2019-11-08 11:08     ` Andy Shevchenko
2019-11-07 22:37 ` Keith Busch
2019-11-08 10:18   ` Andrew Murray [this message]
2019-11-08 11:10     ` Andy Shevchenko

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=20191108101815.GE43905@e119886-lin.cambridge.arm.com \
    --to=andrew.murray@arm.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=kbusch@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mr.nuke.me@gmail.com \
    --cc=stuart.w.hayes@gmail.com \
    /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.