drivers: net: xgene: Get channel number from device binding
authorIyappan Subramanian <isubramanian@apm.com>
Fri, 29 Apr 2016 18:10:13 +0000 (11:10 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 May 2016 20:47:54 +0000 (16:47 -0400)
This patch gets ethernet to CPU channel (prefetch buffer number) from
the newly added 'channel' property, thus decoupling Linux driver from
resource management.

Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/apm/xgene/xgene_enet_main.c

index 8d4c1ad2fc6051f66ffc059456927511e9dd2fe3..409152b211915ca81d4883a3730a46d0894b9c82 100644 (file)
@@ -973,6 +973,17 @@ static enum xgene_ring_owner xgene_derive_ring_owner(struct xgene_enet_pdata *p)
        return owner;
 }
 
+static u8 xgene_start_cpu_bufnum(struct xgene_enet_pdata *pdata)
+{
+       struct device *dev = &pdata->pdev->dev;
+       u32 cpu_bufnum;
+       int ret;
+
+       ret = device_property_read_u32(dev, "channel", &cpu_bufnum);
+
+       return (!ret) ? cpu_bufnum : pdata->cpu_bufnum;
+}
+
 static int xgene_enet_create_desc_rings(struct net_device *ndev)
 {
        struct xgene_enet_pdata *pdata = netdev_priv(ndev);
@@ -981,13 +992,15 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev)
        struct xgene_enet_desc_ring *buf_pool = NULL;
        enum xgene_ring_owner owner;
        dma_addr_t dma_exp_bufs;
-       u8 cpu_bufnum = pdata->cpu_bufnum;
+       u8 cpu_bufnum;
        u8 eth_bufnum = pdata->eth_bufnum;
        u8 bp_bufnum = pdata->bp_bufnum;
        u16 ring_num = pdata->ring_num;
        u16 ring_id;
        int i, ret, size;
 
+       cpu_bufnum = xgene_start_cpu_bufnum(pdata);
+
        for (i = 0; i < pdata->rxq_cnt; i++) {
                /* allocate rx descriptor ring */
                owner = xgene_derive_ring_owner(pdata);