From patchwork Thu Jun 30 19:04:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 71269 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp546771qgy; Thu, 30 Jun 2016 12:05:22 -0700 (PDT) X-Received: by 10.98.6.132 with SMTP id 126mr24228881pfg.109.1467313519387; Thu, 30 Jun 2016 12:05:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si5643643pal.39.2016.06.30.12.05.19; Thu, 30 Jun 2016 12:05:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752245AbcF3TEy (ORCPT + 3 others); Thu, 30 Jun 2016 15:04:54 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:36513 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752138AbcF3TEw (ORCPT ); Thu, 30 Jun 2016 15:04:52 -0400 Received: by mail-lf0-f43.google.com with SMTP id q132so62142150lfe.3 for ; Thu, 30 Jun 2016 12:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AWfi9N4EYHt2fxriwI31BrsyNnR+L+ZJJPmZ1XoJRgo=; b=bg65brf68q8X6glhXLpl5oJSj3Xr9kKMhjgGriOKeI7+Hsq6wfbPSXOy70CDj9uUCd meb1kvWvw7M4tMnmjyFHssvKTmodSSGoRAVOdIZ3uYBDmXDEIYM7tThWQYi1B6WiICx0 AIWSAE/bXWj6WEGafWNd1gso4HFACDKpC5Hd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AWfi9N4EYHt2fxriwI31BrsyNnR+L+ZJJPmZ1XoJRgo=; b=ZMBe7h1/OsZizyESv9K2szvQf+hIj4dL/h9XH0F1ZdcffB2uRQFf7Awzf2HtA+lbVN v2ouB9V/TZeKYkwvc6NdIkwSNJmM4Km/SbvoHeqePVCcFfM0I/3EfL2pFQUArNSLIKjy bLQu9BLCjq4iAW03Mdu5mtvFImBll8Ye8vcECfn9bGqtGUpdhWVTop4LeHws2+EN8In5 kGtAXya35M/gyu7cj87YYaRUWCrV4/k+DpPLl+W8Megve6nL+nrbOu9xieZkzZ91EY/P 0BtXoOw/QNM+RLKYExoKfgqHSL+Og4BkugA0a8/jg8GRrej1pHNjyqKQzDT4CK9K6wau 9bmw== X-Gm-Message-State: ALyK8tL8tZqWIVGzbbLOIk5LVTWOe7U2rC7wL0uz/ghd4uXgVyZ6TyRTeCeW40Zuxa78jRGv X-Received: by 10.25.215.196 with SMTP id q65mr4681531lfi.98.1467313490142; Thu, 30 Jun 2016 12:04:50 -0700 (PDT) Received: from localhost.localdomain ([212.90.63.58]) by smtp.gmail.com with ESMTPSA id 195sm1745215ljf.40.2016.06.30.12.04.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 12:04:49 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, netdev@vger.kernel.org, mugunthanvnm@ti.com Cc: grygorii.strashko@ti.com, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, nsekhar@ti.com, Ivan Khoronzhuk Subject: [PATCH 3/4] net: ethernet: ti: davinci_cpdma: move cpdma channel struct macroses to internals Date: Thu, 30 Jun 2016 22:04:37 +0300 Message-Id: <1467313478-22919-4-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467313478-22919-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1467313478-22919-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Better to move functions that works with channel internals to C file. Currently it's not required for drivers to know rx or tx a channel is, except create function. So correct "channel create" function, and use all channel struct macroses only for internal use. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 6 ++---- drivers/net/ethernet/ti/davinci_cpdma.c | 13 +++++++++++-- drivers/net/ethernet/ti/davinci_cpdma.h | 9 +-------- drivers/net/ethernet/ti/davinci_emac.c | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 14d53eb..595ed56 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2575,10 +2575,8 @@ static int cpsw_probe(struct platform_device *pdev) goto clean_runtime_disable_ret; } - priv->txch[0] = cpdma_chan_create(priv->dma, tx_chan_num(0), - cpsw_tx_handler); - priv->rxch[0] = cpdma_chan_create(priv->dma, rx_chan_num(0), - cpsw_rx_handler); + priv->txch[0] = cpdma_chan_create(priv->dma, 0, cpsw_tx_handler, 0); + priv->rxch[0] = cpdma_chan_create(priv->dma, 0, cpsw_rx_handler, 1); if (WARN_ON(!priv->rxch[0] || !priv->txch[0])) { dev_err(priv->dev, "error initializing dma channels\n"); diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index a4b299d..d6c4967 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -126,6 +126,13 @@ struct cpdma_chan { int int_set, int_clear, td; }; +#define tx_chan_num(chan) (chan) +#define rx_chan_num(chan) ((chan) + CPDMA_MAX_CHANNELS) +#define is_rx_chan(chan) ((chan)->chan_num >= CPDMA_MAX_CHANNELS) +#define is_tx_chan(chan) (!is_rx_chan(chan)) +#define __chan_linear(chan_num) ((chan_num) & (CPDMA_MAX_CHANNELS - 1)) +#define chan_linear(chan) __chan_linear((chan)->chan_num) + /* The following make access to common cpdma_ctlr params more readable */ #define dmaregs params.dmaregs #define num_chan params.num_chan @@ -520,12 +527,14 @@ static void cpdma_chan_split_pool(struct cpdma_ctlr *ctlr) } struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, - cpdma_handler_fn handler) + cpdma_handler_fn handler, int rx_type) { + int offset = chan_num * 4; struct cpdma_chan *chan; - int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4; unsigned long flags; + chan_num = rx_type ? rx_chan_num(chan_num) : tx_chan_num(chan_num); + if (__chan_linear(chan_num) >= ctlr->num_chan) return NULL; diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 3ce91a1..52db03a 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -17,13 +17,6 @@ #define CPDMA_MAX_CHANNELS BITS_PER_LONG -#define tx_chan_num(chan) (chan) -#define rx_chan_num(chan) ((chan) + CPDMA_MAX_CHANNELS) -#define is_rx_chan(chan) ((chan)->chan_num >= CPDMA_MAX_CHANNELS) -#define is_tx_chan(chan) (!is_rx_chan(chan)) -#define __chan_linear(chan_num) ((chan_num) & (CPDMA_MAX_CHANNELS - 1)) -#define chan_linear(chan) __chan_linear((chan)->chan_num) - #define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7) #define CPDMA_EOI_RX_THRESH 0x0 @@ -80,7 +73,7 @@ int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr); int cpdma_ctlr_dump(struct cpdma_ctlr *ctlr); struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, - cpdma_handler_fn handler); + cpdma_handler_fn handler, int rx_type); int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan); int cpdma_chan_destroy(struct cpdma_chan *chan); int cpdma_chan_start(struct cpdma_chan *chan); diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index f56d66e..1df0c89 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -2008,10 +2008,10 @@ static int davinci_emac_probe(struct platform_device *pdev) goto no_pdata; } - priv->txchan = cpdma_chan_create(priv->dma, tx_chan_num(EMAC_DEF_TX_CH), - emac_tx_handler); - priv->rxchan = cpdma_chan_create(priv->dma, rx_chan_num(EMAC_DEF_RX_CH), - emac_rx_handler); + priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH, + emac_tx_handler, 0); + priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH, + emac_rx_handler, 1); if (WARN_ON(!priv->txchan || !priv->rxchan)) { rc = -ENOMEM; goto no_cpdma_chan;