Commit 925d65e6 authored by Ivan Khoronzhuk's avatar Ivan Khoronzhuk Committed by David S. Miller

net: ethernet: ti: davinci_cpdma: move cpdma channel struct macroses to internals

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: default avatarMugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e05107e6
...@@ -2535,11 +2535,8 @@ static int cpsw_probe(struct platform_device *pdev) ...@@ -2535,11 +2535,8 @@ static int cpsw_probe(struct platform_device *pdev)
goto clean_runtime_disable_ret; goto clean_runtime_disable_ret;
} }
cpsw->txch[0] = cpdma_chan_create(cpsw->dma, tx_chan_num(0), cpsw->txch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0);
cpsw_tx_handler); cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, rx_chan_num(0),
cpsw_rx_handler);
if (WARN_ON(!cpsw->rxch[0] || !cpsw->txch[0])) { if (WARN_ON(!cpsw->rxch[0] || !cpsw->txch[0])) {
dev_err(priv->dev, "error initializing dma channels\n"); dev_err(priv->dev, "error initializing dma channels\n");
ret = -ENOMEM; ret = -ENOMEM;
......
...@@ -124,6 +124,13 @@ struct cpdma_chan { ...@@ -124,6 +124,13 @@ struct cpdma_chan {
int int_set, int_clear, td; 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 */ /* The following make access to common cpdma_ctlr params more readable */
#define dmaregs params.dmaregs #define dmaregs params.dmaregs
#define num_chan params.num_chan #define num_chan params.num_chan
...@@ -441,12 +448,14 @@ static void cpdma_chan_split_pool(struct cpdma_ctlr *ctlr) ...@@ -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, 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; struct cpdma_chan *chan;
int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4;
unsigned long flags; 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) if (__chan_linear(chan_num) >= ctlr->num_chan)
return NULL; return NULL;
......
...@@ -17,13 +17,6 @@ ...@@ -17,13 +17,6 @@
#define CPDMA_MAX_CHANNELS BITS_PER_LONG #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_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7)
#define CPDMA_EOI_RX_THRESH 0x0 #define CPDMA_EOI_RX_THRESH 0x0
...@@ -79,7 +72,7 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr); ...@@ -79,7 +72,7 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr);
int cpdma_ctlr_stop(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, 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_get_rx_buf_num(struct cpdma_chan *chan);
int cpdma_chan_destroy(struct cpdma_chan *chan); int cpdma_chan_destroy(struct cpdma_chan *chan);
int cpdma_chan_start(struct cpdma_chan *chan); int cpdma_chan_start(struct cpdma_chan *chan);
......
...@@ -1870,10 +1870,10 @@ static int davinci_emac_probe(struct platform_device *pdev) ...@@ -1870,10 +1870,10 @@ static int davinci_emac_probe(struct platform_device *pdev)
goto no_pdata; goto no_pdata;
} }
priv->txchan = cpdma_chan_create(priv->dma, tx_chan_num(EMAC_DEF_TX_CH), priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH,
emac_tx_handler); emac_tx_handler, 0);
priv->rxchan = cpdma_chan_create(priv->dma, rx_chan_num(EMAC_DEF_RX_CH), priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
emac_rx_handler); emac_rx_handler, 1);
if (WARN_ON(!priv->txchan || !priv->rxchan)) { if (WARN_ON(!priv->txchan || !priv->rxchan)) {
rc = -ENOMEM; rc = -ENOMEM;
goto no_cpdma_chan; goto no_cpdma_chan;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment