From patchwork Fri Dec 30 18:03:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francois Romieu X-Patchwork-Id: 133688 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 37BD2B6FBE for ; Sat, 31 Dec 2011 05:13:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681Ab1L3SNG (ORCPT ); Fri, 30 Dec 2011 13:13:06 -0500 Received: from violet.fr.zoreil.com ([92.243.8.30]:47053 "EHLO violet.fr.zoreil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632Ab1L3SMk (ORCPT ); Fri, 30 Dec 2011 13:12:40 -0500 Received: from violet.fr.zoreil.com (localhost [127.0.0.1]) by violet.fr.zoreil.com (8.13.8/8.13.8) with ESMTP id pBUI3veg003684; Fri, 30 Dec 2011 19:03:57 +0100 Received: (from romieu@localhost) by violet.fr.zoreil.com (8.13.8/8.13.8/Submit) id pBUI3vm3003683; Fri, 30 Dec 2011 19:03:57 +0100 Date: Fri, 30 Dec 2011 19:03:57 +0100 From: Francois Romieu To: Bjarke Istrup Pedersen Cc: David Miller , shemminger@vyatta.com, bhutchings@solarflare.com, netdev@vger.kernel.org, rl@hellgate.ch Subject: [PATCH net-next 1/3] via-rhine: factor out tx_thresh handling Message-ID: <20111230180357.GB3647@electric-eye.fr.zoreil.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i X-Organisation: Land of Sunshine Inc. Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Francois Romieu --- drivers/net/ethernet/via/via-rhine.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index 5c4983b..93987e8 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -657,6 +657,16 @@ static void rhine_poll(struct net_device *dev) } #endif +static void rhine_kick_tx_threshold(struct rhine_private *rp) +{ + if (rp->tx_thresh < 0xe0) { + void __iomem *ioaddr = rp->base; + + rp->tx_thresh += 0x20; + BYTE_REG_BITS_SET(rp->tx_thresh, 0x80, ioaddr + TxConfig); + } +} + static int rhine_napipoll(struct napi_struct *napi, int budget) { struct rhine_private *rp = container_of(napi, struct rhine_private, napi); @@ -1910,8 +1920,7 @@ static void rhine_error(struct net_device *dev, int intr_status) intr_status); } if (intr_status & IntrTxUnderrun) { - if (rp->tx_thresh < 0xE0) - BYTE_REG_BITS_SET((rp->tx_thresh += 0x20), 0x80, ioaddr + TxConfig); + rhine_kick_tx_threshold(rp); if (debug > 1) netdev_info(dev, "Transmitter underrun, Tx threshold now %02x\n", rp->tx_thresh); @@ -1923,9 +1932,7 @@ static void rhine_error(struct net_device *dev, int intr_status) if ((intr_status & IntrTxError) && (intr_status & (IntrTxAborted | IntrTxUnderrun | IntrTxDescRace)) == 0) { - if (rp->tx_thresh < 0xE0) { - BYTE_REG_BITS_SET((rp->tx_thresh += 0x20), 0x80, ioaddr + TxConfig); - } + rhine_kick_tx_threshold(rp); if (debug > 1) netdev_info(dev, "Unspecified error. Tx threshold now %02x\n", rp->tx_thresh);