{"id":901,"url":"http://patchwork.ozlabs.org/api/1.0/patches/901/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<1222103036-27770-1-git-send-email-tpiepho@freescale.com>","date":"2008-09-22T17:03:56","name":"gianfar: Fix error in mdio reset timeout","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"de49a1869c885b185409fb4b65387499c3ff27cb","submitter":{"id":73,"url":"http://patchwork.ozlabs.org/api/1.0/people/73/?format=json","name":"Trent Piepho","email":"tpiepho@freescale.com"},"delegate":{"id":36,"url":"http://patchwork.ozlabs.org/api/1.0/users/36/?format=json","username":"jgarzik","first_name":"Jeff","last_name":"Garzik","email":"jgarzik@pobox.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1222103036-27770-1-git-send-email-tpiepho@freescale.com/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/901/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Received":["from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id 7C4E6DE50F\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 23 Sep 2008 03:05:17 +1000 (EST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751304AbYIVRFM (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 22 Sep 2008 13:05:12 -0400","(majordomo@vger.kernel.org) by vger.kernel.org id S1751350AbYIVRFL\n\t(ORCPT <rfc822; netdev-outgoing>); Mon, 22 Sep 2008 13:05:11 -0400","from az33egw01.freescale.net ([192.88.158.102]:58593 \"EHLO\n\taz33egw01.freescale.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751227AbYIVRFK (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 22 Sep 2008 13:05:10 -0400","from az33smr01.freescale.net (az33smr01.freescale.net\n\t[10.64.34.199])\n\tby az33egw01.freescale.net (8.12.11/az33egw01) with ESMTP id\n\tm8MH55id003215\n\tfor <netdev@vger.kernel.org>; Mon, 22 Sep 2008 10:05:06 -0700 (MST)","from localhost.localdomain (vpn-10-213-160-4.am.freescale.net\n\t[10.213.160.4])\n\tby az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id\n\tm8MH55TN013983; Mon, 22 Sep 2008 12:05:05 -0500 (CDT)"],"From":"Trent Piepho <tpiepho@freescale.com>","To":"netdev@vger.kernel.org","Cc":"Trent Piepho <tpiepho@freescale.com>","Subject":"[PATCH] gianfar: Fix error in mdio reset timeout","Date":"Mon, 22 Sep 2008 10:03:56 -0700","Message-Id":"<1222103036-27770-1-git-send-email-tpiepho@freescale.com>","X-Mailer":"git-send-email 1.5.4.1","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"The loop with the timeout used \"while (...  && timeout--)\", which means\nthan when the timeout occurs, \"timeout\" will be -1 after the loop has\nexited.  The code that checks if the looped exited because of a timeout\nused \"if (timeout <= 0)\".  Seems ok, except timeout is unsigned, and\n(unsigned)-1 isn't less than zero!\n\nUsing \"--timeout\" in the loop fixes this problem, as now \"timeout\" will be\n0 when the loop times out.\n\nThis also fixes a bug in the existing code, where it will erroneously think\na timeout occurred if the condition the loop was waiting for is satisfied\non the final iteration before a timeout.\n\nSigned-off-by: Trent Piepho <tpiepho@freescale.com>\nAcked-by: Andy Fleming <afleming@freescale.com>\n---\n drivers/net/gianfar_mii.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c\nindex ebcfb27..906aba2 100644\n--- a/drivers/net/gianfar_mii.c\n+++ b/drivers/net/gianfar_mii.c\n@@ -136,12 +136,12 @@ static int gfar_mdio_reset(struct mii_bus *bus)\n \n \t/* Wait until the bus is free */\n \twhile ((gfar_read(&regs->miimind) & MIIMIND_BUSY) &&\n-\t\t\ttimeout--)\n+\t\t\t--timeout)\n \t\tcpu_relax();\n \n \tmutex_unlock(&bus->mdio_lock);\n \n-\tif(timeout <= 0) {\n+\tif(timeout == 0) {\n \t\tprintk(KERN_ERR \"%s: The MII Bus is stuck!\\n\",\n \t\t\t\tbus->name);\n \t\treturn -EBUSY;\n","prefixes":[]}