diff options
author | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> | 2016-08-22 14:18:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-23 03:13:11 -0400 |
commit | 925d65e6d8a4c84c54fbad060f32385b57e210ed (patch) | |
tree | 4ba55e7cdf9103b459399fe1e6604d1b9e9be8c1 /drivers/net | |
parent | e05107e6b74700762e2feda0abd2e74984c24227 (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')
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/davinci_cpdma.c | 13 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/davinci_cpdma.h | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 8 |
4 files changed, 18 insertions, 19 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 28cc716f22c9..1fbb50f25603 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) | |||
2535 | goto clean_runtime_disable_ret; | 2535 | goto clean_runtime_disable_ret; |
2536 | } | 2536 | } |
2537 | 2537 | ||
2538 | cpsw->txch[0] = cpdma_chan_create(cpsw->dma, tx_chan_num(0), | 2538 | cpsw->txch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); |
2539 | cpsw_tx_handler); | 2539 | cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1); |
2540 | cpsw->rxch[0] = cpdma_chan_create(cpsw->dma, rx_chan_num(0), | ||
2541 | cpsw_rx_handler); | ||
2542 | |||
2543 | if (WARN_ON(!cpsw->rxch[0] || !cpsw->txch[0])) { | 2540 | if (WARN_ON(!cpsw->rxch[0] || !cpsw->txch[0])) { |
2544 | dev_err(priv->dev, "error initializing dma channels\n"); | 2541 | dev_err(priv->dev, "error initializing dma channels\n"); |
2545 | ret = -ENOMEM; | 2542 | ret = -ENOMEM; |
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 | ||
443 | struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, | 450 | struct 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 | ||
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 070f1d0ea848..a07b22b12bc1 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h | |||
@@ -17,13 +17,6 @@ | |||
17 | 17 | ||
18 | #define CPDMA_MAX_CHANNELS BITS_PER_LONG | 18 | #define CPDMA_MAX_CHANNELS BITS_PER_LONG |
19 | 19 | ||
20 | #define tx_chan_num(chan) (chan) | ||
21 | #define rx_chan_num(chan) ((chan) + CPDMA_MAX_CHANNELS) | ||
22 | #define is_rx_chan(chan) ((chan)->chan_num >= CPDMA_MAX_CHANNELS) | ||
23 | #define is_tx_chan(chan) (!is_rx_chan(chan)) | ||
24 | #define __chan_linear(chan_num) ((chan_num) & (CPDMA_MAX_CHANNELS - 1)) | ||
25 | #define chan_linear(chan) __chan_linear((chan)->chan_num) | ||
26 | |||
27 | #define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7) | 20 | #define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7) |
28 | 21 | ||
29 | #define CPDMA_EOI_RX_THRESH 0x0 | 22 | #define CPDMA_EOI_RX_THRESH 0x0 |
@@ -79,7 +72,7 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr); | |||
79 | int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr); | 72 | int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr); |
80 | 73 | ||
81 | struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, | 74 | struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, |
82 | cpdma_handler_fn handler); | 75 | cpdma_handler_fn handler, int rx_type); |
83 | int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan); | 76 | int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan); |
84 | int cpdma_chan_destroy(struct cpdma_chan *chan); | 77 | int cpdma_chan_destroy(struct cpdma_chan *chan); |
85 | int cpdma_chan_start(struct cpdma_chan *chan); | 78 | 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 2d6fc9a0fb21..2fd94a5bc1f3 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) | |||
1870 | goto no_pdata; | 1870 | goto no_pdata; |
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | priv->txchan = cpdma_chan_create(priv->dma, tx_chan_num(EMAC_DEF_TX_CH), | 1873 | priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH, |
1874 | emac_tx_handler); | 1874 | emac_tx_handler, 0); |
1875 | priv->rxchan = cpdma_chan_create(priv->dma, rx_chan_num(EMAC_DEF_RX_CH), | 1875 | priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH, |
1876 | emac_rx_handler); | 1876 | emac_rx_handler, 1); |
1877 | if (WARN_ON(!priv->txchan || !priv->rxchan)) { | 1877 | if (WARN_ON(!priv->txchan || !priv->rxchan)) { |
1878 | rc = -ENOMEM; | 1878 | rc = -ENOMEM; |
1879 | goto no_cpdma_chan; | 1879 | goto no_cpdma_chan; |