Re: [PATCH v3 10/13] net; ethernet: ti: cpsw: move irq stuff under cpsw_common

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 04:52 AM, Ivan Khoronzhuk wrote:
> The irq data are common for net devs in dual_emac mode. So no need to
> hold these data in every priv struct, move them under cpsw_common.
> Also delete irq_num var, as after optimization it's not needed.
> Correct number of irqs to 2, as anyway, driver is using only 2,
> at least for now.
> 
> Signed-off-by: Ivan Khoronzhuk 

Reviewed-by: Mugunthan V N 

Regards
Mugunthan V N


[PATCH v3 10/13] net; ethernet: ti: cpsw: move irq stuff under cpsw_common

2016-08-09 Thread Ivan Khoronzhuk
The irq data are common for net devs in dual_emac mode. So no need to
hold these data in every priv struct, move them under cpsw_common.
Also delete irq_num var, as after optimization it's not needed.
Correct number of irqs to 2, as anyway, driver is using only 2,
at least for now.

Signed-off-by: Ivan Khoronzhuk 
---
 drivers/net/ethernet/ti/cpsw.c | 65 +++---
 1 file changed, 29 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 6d99d1e..b2482b6 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -143,6 +143,7 @@ do {
\
 #define cpsw_slave_index(priv) \
((priv->data.dual_emac) ? priv->emac_port : \
priv->data.active_slave)
+#define IRQ_NUM2
 
 static int debug_level;
 module_param(debug_level, int, 0);
@@ -371,6 +372,10 @@ struct cpsw_common {
struct cpsw_host_regs __iomem   *host_port_regs;
struct cpdma_ctlr   *dma;
struct cpdma_chan   *txch, *rxch;
+   boolquirk_irq;
+   boolrx_irq_disabled;
+   booltx_irq_disabled;
+   u32 irqs_table[IRQ_NUM];
 };
 
 struct cpsw_priv {
@@ -389,12 +394,6 @@ struct cpsw_priv {
struct cpsw_ale *ale;
boolrx_pause;
booltx_pause;
-   boolquirk_irq;
-   boolrx_irq_disabled;
-   booltx_irq_disabled;
-   /* snapshot of IRQ numbers */
-   u32 irqs_table[4];
-   u32 num_irqs;
struct cpts *cpts;
u32 emac_port;
struct cpsw_common *cpsw;
@@ -756,9 +755,9 @@ static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
writel(0, >wr_regs->tx_en);
cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_TX);
 
-   if (priv->quirk_irq) {
-   disable_irq_nosync(priv->irqs_table[1]);
-   priv->tx_irq_disabled = true;
+   if (cpsw->quirk_irq) {
+   disable_irq_nosync(cpsw->irqs_table[1]);
+   cpsw->tx_irq_disabled = true;
}
 
napi_schedule(>napi_tx);
@@ -773,9 +772,9 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
cpdma_ctlr_eoi(cpsw->dma, CPDMA_EOI_RX);
writel(0, >wr_regs->rx_en);
 
-   if (priv->quirk_irq) {
-   disable_irq_nosync(priv->irqs_table[0]);
-   priv->rx_irq_disabled = true;
+   if (cpsw->quirk_irq) {
+   disable_irq_nosync(cpsw->irqs_table[0]);
+   cpsw->rx_irq_disabled = true;
}
 
napi_schedule(>napi_rx);
@@ -792,9 +791,9 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int 
budget)
if (num_tx < budget) {
napi_complete(napi_tx);
writel(0xff, >wr_regs->tx_en);
-   if (priv->quirk_irq && priv->tx_irq_disabled) {
-   priv->tx_irq_disabled = false;
-   enable_irq(priv->irqs_table[1]);
+   if (cpsw->quirk_irq && cpsw->tx_irq_disabled) {
+   cpsw->tx_irq_disabled = false;
+   enable_irq(cpsw->irqs_table[1]);
}
}
 
@@ -811,9 +810,9 @@ static int cpsw_rx_poll(struct napi_struct *napi_rx, int 
budget)
if (num_rx < budget) {
napi_complete(napi_rx);
writel(0xff, >wr_regs->rx_en);
-   if (priv->quirk_irq && priv->rx_irq_disabled) {
-   priv->rx_irq_disabled = false;
-   enable_irq(priv->irqs_table[0]);
+   if (cpsw->quirk_irq && cpsw->rx_irq_disabled) {
+   cpsw->rx_irq_disabled = false;
+   enable_irq(cpsw->irqs_table[0]);
}
}
 
@@ -1299,14 +1298,14 @@ static int cpsw_ndo_open(struct net_device *ndev)
napi_enable(_sl0->napi_rx);
napi_enable(_sl0->napi_tx);
 
-   if (priv_sl0->tx_irq_disabled) {
-   priv_sl0->tx_irq_disabled = false;
-   enable_irq(priv->irqs_table[1]);
+   if (cpsw->tx_irq_disabled) {
+   cpsw->tx_irq_disabled = false;
+   enable_irq(cpsw->irqs_table[1]);
}
 
-   if (priv_sl0->rx_irq_disabled) {
-   priv_sl0->rx_irq_disabled = false;
-   enable_irq(priv->irqs_table[0]);
+   if (cpsw->rx_irq_disabled) {
+   cpsw->rx_irq_disabled = false;
+   enable_irq(cpsw->irqs_table[0]);
}
 
buf_num =