From patchwork Mon Aug 22 18:18:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 74457 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1701662qga; Mon, 22 Aug 2016 11:19:30 -0700 (PDT) X-Received: by 10.66.189.199 with SMTP id gk7mr45596861pac.158.1471889965840; Mon, 22 Aug 2016 11:19:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 141si23797026pfw.92.2016.08.22.11.19.25; Mon, 22 Aug 2016 11:19:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754719AbcHVSTG (ORCPT + 27 others); Mon, 22 Aug 2016 14:19:06 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:33840 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753509AbcHVSSl (ORCPT ); Mon, 22 Aug 2016 14:18:41 -0400 Received: by mail-lf0-f50.google.com with SMTP id l89so84046859lfi.1 for ; Mon, 22 Aug 2016 11:18:40 -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=z/xnK6AH4tuy+JhCKTlCebRhs0DLiVkaPdILAv5xnqY=; b=kxkqz7XPTPn4EGJWQYbXqVaTZhNMjtgucO5KdFruc5Mf51Z33rr8p38OJYiQwIzO/y ZqLI9nXxRO/Y7NxUiYcLBxzl9psovhyGXMP6EF87bY59nfAx5IQZ/rn8qjcXOib1jjD8 CYwd6Jke5Ttg1BKv8n8iFGd5GqvvtYQPcA690= 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=z/xnK6AH4tuy+JhCKTlCebRhs0DLiVkaPdILAv5xnqY=; b=MgVwAmo96z6O2/rEf5iEc+7KMEAvambeu9vLoTJUyqPvEsOo8hj39bhg5xtwb3hIU1 aJHlGsgc0IOBNI+JLpmP3/5iS40Eftuxd/FtK1T2eQfY2sGVnK+LhW9spPv8JfzYZrqt 2ttwcWImZKNwpfd8tzEANhwZwO12xnoK4dz950SHUXTWW2TAJZh3lKk+DSP3lgo2peEi KarmkGCqz3RFL2D3vB8z1DeisthSQnb2mv5XODAMnLf0rXSogEBPgKJOKJkpJjS2e6ti pJF2RSQU2fkqbmV+Th4YXwlCrtTpzH8V8tiMN8qXRJ5/f1E2rriAVifLGOaFJFguTdj7 1/rQ== X-Gm-Message-State: AEkoouuHoaObOFVRexivhDF3TK7y3Iz13qhJDRNULs9eUk4PfqUHstBXrhfsWd9t4IzS5K5C X-Received: by 10.46.9.216 with SMTP id 207mr5330848ljj.62.1471889919398; Mon, 22 Aug 2016 11:18:39 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id 206sm3969101ljj.4.2016.08.22.11.18.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Aug 2016 11:18:38 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, netdev@vger.kernel.org, mugunthanvnm@ti.com, grygorii.strashko@ti.com Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, nsekhar@ti.com, dlide@ti.com, Ivan Khoronzhuk Subject: [PATCH v4 4/5] net: ethernet: ti: davinci_cpdma: move cpdma channel struct macroses to internals Date: Mon, 22 Aug 2016 21:18:27 +0300 Message-Id: <1471889908-29983-5-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471889908-29983-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1471889908-29983-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Keep the driver internals in 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. Reviewed-by: Mugunthan V N Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 7 ++----- 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(+), 19 deletions(-) -- 1.9.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 28cc716..1fbb50f 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2535,11 +2535,8 @@ static int cpsw_probe(struct platform_device *pdev) goto clean_runtime_disable_ret; } - cpsw->txch[0] = cpdma_chan_create(cpsw->dma, tx_chan_num(0), - cpsw_tx_handler); - cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, rx_chan_num(0), - cpsw_rx_handler); - + cpsw->txch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); + cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1); if (WARN_ON(!cpsw->rxch[0] || !cpsw->txch[0])) { dev_err(priv->dev, "error initializing dma channels\n"); ret = -ENOMEM; diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 4b578b1..c3f35f1 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -124,6 +124,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 @@ -441,12 +448,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 070f1d0..a07b22b 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 @@ -79,7 +72,7 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr); int cpdma_ctlr_stop(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 2d6fc9a..2fd94a5 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1870,10 +1870,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;