From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Warren Date: Sun, 04 Apr 2010 22:44:40 -0700 Subject: [U-Boot] [PATCH] fix lockup in mcfmii/mii_discover_phy() in case communication fails In-Reply-To: <1269969591-15664-1-git-send-email-w.wegner@astro-kom.de> References: <20100326161912.GA23389@leila.ping.de> <1269969591-15664-1-git-send-email-w.wegner@astro-kom.de> Message-ID: <4BB978C8.1080705@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, On 3/30/2010 10:19 AM, Wolfgang Wegner wrote: > Signed-off-by: Wolfgang Wegner > --- > drivers/net/mcfmii.c | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c > index 4acc29e..83c0873 100644 > --- a/drivers/net/mcfmii.c > +++ b/drivers/net/mcfmii.c > @@ -185,7 +185,11 @@ int mii_discover_phy(struct eth_device *dev) > printf("PHY @ 0x%x pass %d\n", phyno, pass); > #endif > > - for (i = 0; i< (sizeof(phyinfo) / sizeof(phy_info_t)); i++) { > + for (i = 0; > + (i< (sizeof(phyinfo) > + / sizeof(phy_info_t))) > + && (phyinfo[i].phyid != 0); > + i++) { > if (phyinfo[i].phyid == phytype) { > #ifdef ET_DEBUG > printf("phyid %x - %s\n", > This is brutal. Using 8-space tabs really does a good job of highlighting deep nesting of conditionals. If you're unable to make the driver easier to read (and I understand if that's the case), my preference would be to keep the sizeof()s on one line and combine the second && term and the i++ on another. This makes lines > 80 chars, but it was already that way. regards, Ben