Commit 1ffa8a7a authored by Iyappan Subramanian's avatar Iyappan Subramanian Committed by David S. Miller

drivers: net: xgene-v2: misc fixes

Fixed review comments from the previous patch-set.

- changed return value check of platform_get_irq() to < 0
- replaced devm_request(free)_irq() calls by request(free)_irq() since
  they are called from open() and close()
- changed sizeof(struct mystruct) to sizeof(*mystruct)
- reduced indentation on tx_timeout()
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b2180a8f
...@@ -66,9 +66,8 @@ static int xge_get_resources(struct xge_pdata *pdata) ...@@ -66,9 +66,8 @@ static int xge_get_resources(struct xge_pdata *pdata)
} }
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret <= 0) { if (ret < 0) {
dev_err(dev, "Unable to get ENET IRQ\n"); dev_err(dev, "Unable to get irq\n");
ret = ret ? : -ENXIO;
return ret; return ret;
} }
pdata->resources.irq = ret; pdata->resources.irq = ret;
...@@ -156,13 +155,12 @@ static irqreturn_t xge_irq(const int irq, void *data) ...@@ -156,13 +155,12 @@ static irqreturn_t xge_irq(const int irq, void *data)
static int xge_request_irq(struct net_device *ndev) static int xge_request_irq(struct net_device *ndev)
{ {
struct xge_pdata *pdata = netdev_priv(ndev); struct xge_pdata *pdata = netdev_priv(ndev);
struct device *dev = &pdata->pdev->dev;
int ret; int ret;
snprintf(pdata->irq_name, IRQ_ID_SIZE, "%s", ndev->name); snprintf(pdata->irq_name, IRQ_ID_SIZE, "%s", ndev->name);
ret = devm_request_irq(dev, pdata->resources.irq, xge_irq, ret = request_irq(pdata->resources.irq, xge_irq, 0, pdata->irq_name,
0, pdata->irq_name, pdata); pdata);
if (ret) if (ret)
netdev_err(ndev, "Failed to request irq %s\n", pdata->irq_name); netdev_err(ndev, "Failed to request irq %s\n", pdata->irq_name);
...@@ -172,9 +170,8 @@ static int xge_request_irq(struct net_device *ndev) ...@@ -172,9 +170,8 @@ static int xge_request_irq(struct net_device *ndev)
static void xge_free_irq(struct net_device *ndev) static void xge_free_irq(struct net_device *ndev)
{ {
struct xge_pdata *pdata = netdev_priv(ndev); struct xge_pdata *pdata = netdev_priv(ndev);
struct device *dev = &pdata->pdev->dev;
devm_free_irq(dev, pdata->resources.irq, pdata); free_irq(pdata->resources.irq, pdata);
} }
static bool is_tx_slot_available(struct xge_raw_desc *raw_desc) static bool is_tx_slot_available(struct xge_raw_desc *raw_desc)
...@@ -424,7 +421,7 @@ static struct xge_desc_ring *xge_create_desc_ring(struct net_device *ndev) ...@@ -424,7 +421,7 @@ static struct xge_desc_ring *xge_create_desc_ring(struct net_device *ndev)
struct xge_desc_ring *ring; struct xge_desc_ring *ring;
u16 size; u16 size;
ring = kzalloc(sizeof(struct xge_desc_ring), GFP_KERNEL); ring = kzalloc(sizeof(*ring), GFP_KERNEL);
if (!ring) if (!ring)
return NULL; return NULL;
...@@ -436,7 +433,7 @@ static struct xge_desc_ring *xge_create_desc_ring(struct net_device *ndev) ...@@ -436,7 +433,7 @@ static struct xge_desc_ring *xge_create_desc_ring(struct net_device *ndev)
if (!ring->desc_addr) if (!ring->desc_addr)
goto err; goto err;
ring->pkt_info = kcalloc(XGENE_ENET_NUM_DESC, sizeof(struct pkt_info), ring->pkt_info = kcalloc(XGENE_ENET_NUM_DESC, sizeof(*ring->pkt_info),
GFP_KERNEL); GFP_KERNEL);
if (!ring->pkt_info) if (!ring->pkt_info)
goto err; goto err;
...@@ -598,28 +595,28 @@ static void xge_timeout(struct net_device *ndev) ...@@ -598,28 +595,28 @@ static void xge_timeout(struct net_device *ndev)
rtnl_lock(); rtnl_lock();
if (netif_running(ndev)) { if (!netif_running(ndev))
netif_carrier_off(ndev); goto out;
netif_stop_queue(ndev);
xge_intr_disable(pdata);
napi_disable(&pdata->napi);
xge_wr_csr(pdata, DMATXCTRL, 0); netif_stop_queue(ndev);
xge_txc_poll(ndev); xge_intr_disable(pdata);
xge_free_pending_skb(ndev); napi_disable(&pdata->napi);
xge_wr_csr(pdata, DMATXSTATUS, ~0U);
xge_setup_desc(pdata->tx_ring); xge_wr_csr(pdata, DMATXCTRL, 0);
xge_update_tx_desc_addr(pdata); xge_txc_poll(ndev);
xge_mac_init(pdata); xge_free_pending_skb(ndev);
xge_wr_csr(pdata, DMATXSTATUS, ~0U);
napi_enable(&pdata->napi); xge_setup_desc(pdata->tx_ring);
xge_intr_enable(pdata); xge_update_tx_desc_addr(pdata);
xge_mac_enable(pdata); xge_mac_init(pdata);
netif_start_queue(ndev);
netif_carrier_on(ndev); napi_enable(&pdata->napi);
} xge_intr_enable(pdata);
xge_mac_enable(pdata);
netif_start_queue(ndev);
out:
rtnl_unlock(); rtnl_unlock();
} }
...@@ -653,7 +650,7 @@ static int xge_probe(struct platform_device *pdev) ...@@ -653,7 +650,7 @@ static int xge_probe(struct platform_device *pdev)
struct xge_pdata *pdata; struct xge_pdata *pdata;
int ret; int ret;
ndev = alloc_etherdev(sizeof(struct xge_pdata)); ndev = alloc_etherdev(sizeof(*pdata));
if (!ndev) if (!ndev)
return -ENOMEM; return -ENOMEM;
......
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