From patchwork Wed Jan 9 02:05:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Grussling X-Patchwork-Id: 210601 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5A59D2C00DC for ; Wed, 9 Jan 2013 13:06:21 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756783Ab3AICGR (ORCPT ); Tue, 8 Jan 2013 21:06:17 -0500 Received: from mail-da0-f44.google.com ([209.85.210.44]:62086 "EHLO mail-da0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756723Ab3AICGQ (ORCPT ); Tue, 8 Jan 2013 21:06:16 -0500 Received: by mail-da0-f44.google.com with SMTP id z20so479840dae.31 for ; Tue, 08 Jan 2013 18:06:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=glKEGMxvZgK7l3m/h3LpRXE4pXYRrZQQ5CG+OImkx6Q=; b=UiqKwk9LL/kTRzA/9c+tEsyv9Q5lT4rP9zf6+AQI29KfOmb82TCzWXUw3cVOqU0cFs PY+aH6L7Fh4WCEbw84ZNYsdccJ+d+Mi+8bqG2iHqFo8Z+kOa2VDUOFGXOJ7GqJ09QfNk NmBnAwhTgBFD42nbq7S1vWxAOppKPZ/aGNvgEiOX+Ga7AEWWk1Lj8GXvZZllT99oXO2h Hi+o1BiXJVz6Z379KDaOW29VKosnMzXuXYsr9axFgzcZ1uVhbcDsco2R+Ud4m4/KMBb1 uV8cX/63EtqsNJyjghgmoC+K0as0MF/PFDmd+OyMjarn6I116QF3lk7+iVsQQqRKSTOv 0pqw== X-Received: by 10.68.219.36 with SMTP id pl4mr99364457pbc.124.1357697175599; Tue, 08 Jan 2013 18:06:15 -0800 (PST) Received: from trixie.pullman ([76.178.144.65]) by mx.google.com with ESMTPS id t5sm41772231paw.20.2013.01.08.18.06.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 18:06:14 -0800 (PST) From: Barry Grussling To: netdev@vger.kernel.org Cc: Barry Grussling Subject: [PATCH V2 2/4] DSA: Convert repeated msleep calls to timeouts Date: Tue, 8 Jan 2013 18:05:54 -0800 Message-Id: <1357697156-5767-3-git-send-email-barry@grussling.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357697156-5767-1-git-send-email-barry@grussling.com> References: <1357697156-5767-1-git-send-email-barry@grussling.com> X-Gm-Message-State: ALoCoQkV82jtcTnsI3D3UZAlyjMCkLO9lwCPVHE+T3IjTBzqCZcp5A1EUWuoZGzExnRm0455Qntu Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Barry Grussling Convert DSA msleep calls to timeout/usleep_range calls as reported by checkpatch.pl. Signed-off-by: Barry Grussling --- drivers/net/dsa/mv88e6060.c | 12 ++++++++---- drivers/net/dsa/mv88e6123_61_65.c | 12 ++++++++---- drivers/net/dsa/mv88e6131.c | 12 ++++++++---- drivers/net/dsa/mv88e6xxx.c | 16 ++++++++++------ 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c index 637373c..8548f8d 100644 --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c @@ -8,6 +8,8 @@ * (at your option) any later version. */ +#include +#include #include #include #include @@ -66,6 +68,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) { int i; int ret; + unsigned long timeout; /* Set all ports to the disabled state. */ for (i = 0; i < 6; i++) { @@ -74,20 +77,21 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) } /* Wait for transmit queues to drain. */ - msleep(2); + usleep_range(2000, 4000); /* Reset the switch. */ REG_WRITE(REG_GLOBAL, 0x0a, 0xa130); /* Wait up to one second for reset to complete. */ - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); if ((ret & 0x8000) == 0x0000) break; - msleep(1); + usleep_range(1000, 2000); } - if (i == 1000) + if (time_after(jiffies, timeout)) return -ETIMEDOUT; return 0; diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c index a644fc9..41ee5b6 100644 --- a/drivers/net/dsa/mv88e6123_61_65.c +++ b/drivers/net/dsa/mv88e6123_61_65.c @@ -8,6 +8,8 @@ * (at your option) any later version. */ +#include +#include #include #include #include @@ -50,6 +52,7 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) { int i; int ret; + unsigned long timeout; /* Set all ports to the disabled state. */ for (i = 0; i < 8; i++) { @@ -58,20 +61,21 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) } /* Wait for transmit queues to drain. */ - msleep(2); + usleep_range(2000, 4000); /* Reset the switch. */ REG_WRITE(REG_GLOBAL, 0x04, 0xc400); /* Wait up to one second for reset to complete. */ - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); if ((ret & 0xc800) == 0xc800) break; - msleep(1); + usleep_range(1000, 2000); } - if (i == 1000) + if (time_after(jiffies, timeout)) return -ETIMEDOUT; return 0; diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index b613818..dadfafb 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c @@ -8,6 +8,8 @@ * (at your option) any later version. */ +#include +#include #include #include #include @@ -42,6 +44,7 @@ static int mv88e6131_switch_reset(struct dsa_switch *ds) { int i; int ret; + unsigned long timeout; /* Set all ports to the disabled state. */ for (i = 0; i < 11; i++) { @@ -50,20 +53,21 @@ static int mv88e6131_switch_reset(struct dsa_switch *ds) } /* Wait for transmit queues to drain. */ - msleep(2); + usleep_range(2000, 4000); /* Reset the switch. */ REG_WRITE(REG_GLOBAL, 0x04, 0xc400); /* Wait up to one second for reset to complete. */ - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); if ((ret & 0xc800) == 0xc800) break; - msleep(1); + usleep_range(1000, 2000); } - if (i == 1000) + if (time_after(jiffies, timeout)) return -ETIMEDOUT; return 0; diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index d436668..afe7d80 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c @@ -8,6 +8,8 @@ * (at your option) any later version. */ +#include +#include #include #include #include @@ -196,14 +198,15 @@ int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val) static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) { int ret; - int i; + unsigned long timeout; ret = REG_READ(REG_GLOBAL, 0x04); REG_WRITE(REG_GLOBAL, 0x04, ret & ~0x4000); - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); - msleep(1); + usleep_range(1000, 2000); if ((ret & 0xc000) != 0xc000) return 0; } @@ -214,14 +217,15 @@ static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) static int mv88e6xxx_ppu_enable(struct dsa_switch *ds) { int ret; - int i; + unsigned long timeout; ret = REG_READ(REG_GLOBAL, 0x04); REG_WRITE(REG_GLOBAL, 0x04, ret | 0x4000); - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); - msleep(1); + usleep_range(1000, 2000); if ((ret & 0xc000) == 0xc000) return 0; }