aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti/davinci_cpdma.c
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-08-22 14:18:27 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-23 03:13:11 -0400
commit925d65e6d8a4c84c54fbad060f32385b57e210ed (patch)
tree4ba55e7cdf9103b459399fe1e6604d1b9e9be8c1 /drivers/net/ethernet/ti/davinci_cpdma.c
parente05107e6b74700762e2feda0abd2e74984c24227 (diff)
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: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti/davinci_cpdma.c')
-rw-r--r--drivers/net/ethernet/ti/davinci_cpdma.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 4b578b17ec2d..c3f35f11a8fd 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -124,6 +124,13 @@ struct cpdma_chan {
124 int int_set, int_clear, td; 124 int int_set, int_clear, td;
125}; 125};
126 126
127#define tx_chan_num(chan) (chan)
128#define rx_chan_num(chan) ((chan) + CPDMA_MAX_CHANNELS)
129#define is_rx_chan(chan) ((chan)->chan_num >= CPDMA_MAX_CHANNELS)
130#define is_tx_chan(chan) (!is_rx_chan(chan))
131#define __chan_linear(chan_num) ((chan_num) & (CPDMA_MAX_CHANNELS - 1))
132#define chan_linear(chan) __chan_linear((chan)->chan_num)
133
127/* The following make access to common cpdma_ctlr params more readable */ 134/* The following make access to common cpdma_ctlr params more readable */
128#define dmaregs params.dmaregs 135#define dmaregs params.dmaregs
129#define num_chan params.num_chan 136#define num_chan params.num_chan
@@ -441,12 +448,14 @@ static void cpdma_chan_split_pool(struct cpdma_ctlr *ctlr)
441} 448}
442 449
443struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, 450struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
444 cpdma_handler_fn handler) 451 cpdma_handler_fn handler, int rx_type)
445{ 452{
453 int offset = chan_num * 4;
446 struct cpdma_chan *chan; 454 struct cpdma_chan *chan;
447 int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4;
448 unsigned long flags; 455 unsigned long flags;
449 456
457 chan_num = rx_type ? rx_chan_num(chan_num) : tx_chan_num(chan_num);
458
450 if (__chan_linear(chan_num) >= ctlr->num_chan) 459 if (__chan_linear(chan_num) >= ctlr->num_chan)
451 return NULL; 460 return NULL;
452 461