Commit f4820661 authored by David S. Miller's avatar David S. Miller

Merge branch 'marvell-static-code-analysis'

Markus Elfring says:

====================
Ethernet-Marvell: Fine-tuning for several function implementations

Several update suggestions were taken into account
from static source code analysis.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5f8ddeab a0c51cf1
...@@ -1107,7 +1107,7 @@ static void mvneta_port_up(struct mvneta_port *pp) ...@@ -1107,7 +1107,7 @@ static void mvneta_port_up(struct mvneta_port *pp)
q_map = 0; q_map = 0;
for (queue = 0; queue < txq_number; queue++) { for (queue = 0; queue < txq_number; queue++) {
struct mvneta_tx_queue *txq = &pp->txqs[queue]; struct mvneta_tx_queue *txq = &pp->txqs[queue];
if (txq->descs != NULL) if (txq->descs)
q_map |= (1 << queue); q_map |= (1 << queue);
} }
mvreg_write(pp, MVNETA_TXQ_CMD, q_map); mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
...@@ -1116,7 +1116,7 @@ static void mvneta_port_up(struct mvneta_port *pp) ...@@ -1116,7 +1116,7 @@ static void mvneta_port_up(struct mvneta_port *pp)
for (queue = 0; queue < rxq_number; queue++) { for (queue = 0; queue < rxq_number; queue++) {
struct mvneta_rx_queue *rxq = &pp->rxqs[queue]; struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
if (rxq->descs != NULL) if (rxq->descs)
q_map |= (1 << queue); q_map |= (1 << queue);
} }
mvreg_write(pp, MVNETA_RXQ_CMD, q_map); mvreg_write(pp, MVNETA_RXQ_CMD, q_map);
...@@ -2850,7 +2850,7 @@ static int mvneta_rxq_init(struct mvneta_port *pp, ...@@ -2850,7 +2850,7 @@ static int mvneta_rxq_init(struct mvneta_port *pp,
rxq->descs = dma_alloc_coherent(pp->dev->dev.parent, rxq->descs = dma_alloc_coherent(pp->dev->dev.parent,
rxq->size * MVNETA_DESC_ALIGNED_SIZE, rxq->size * MVNETA_DESC_ALIGNED_SIZE,
&rxq->descs_phys, GFP_KERNEL); &rxq->descs_phys, GFP_KERNEL);
if (rxq->descs == NULL) if (!rxq->descs)
return -ENOMEM; return -ENOMEM;
rxq->last_desc = rxq->size - 1; rxq->last_desc = rxq->size - 1;
...@@ -2920,7 +2920,7 @@ static int mvneta_txq_init(struct mvneta_port *pp, ...@@ -2920,7 +2920,7 @@ static int mvneta_txq_init(struct mvneta_port *pp,
txq->descs = dma_alloc_coherent(pp->dev->dev.parent, txq->descs = dma_alloc_coherent(pp->dev->dev.parent,
txq->size * MVNETA_DESC_ALIGNED_SIZE, txq->size * MVNETA_DESC_ALIGNED_SIZE,
&txq->descs_phys, GFP_KERNEL); &txq->descs_phys, GFP_KERNEL);
if (txq->descs == NULL) if (!txq->descs)
return -ENOMEM; return -ENOMEM;
txq->last_desc = txq->size - 1; txq->last_desc = txq->size - 1;
...@@ -2933,8 +2933,9 @@ static int mvneta_txq_init(struct mvneta_port *pp, ...@@ -2933,8 +2933,9 @@ static int mvneta_txq_init(struct mvneta_port *pp,
mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys); mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size); mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
txq->tx_skb = kmalloc(txq->size * sizeof(*txq->tx_skb), GFP_KERNEL); txq->tx_skb = kmalloc_array(txq->size, sizeof(*txq->tx_skb),
if (txq->tx_skb == NULL) { GFP_KERNEL);
if (!txq->tx_skb) {
dma_free_coherent(pp->dev->dev.parent, dma_free_coherent(pp->dev->dev.parent,
txq->size * MVNETA_DESC_ALIGNED_SIZE, txq->size * MVNETA_DESC_ALIGNED_SIZE,
txq->descs, txq->descs_phys); txq->descs, txq->descs_phys);
...@@ -2945,7 +2946,7 @@ static int mvneta_txq_init(struct mvneta_port *pp, ...@@ -2945,7 +2946,7 @@ static int mvneta_txq_init(struct mvneta_port *pp,
txq->tso_hdrs = dma_alloc_coherent(pp->dev->dev.parent, txq->tso_hdrs = dma_alloc_coherent(pp->dev->dev.parent,
txq->size * TSO_HEADER_SIZE, txq->size * TSO_HEADER_SIZE,
&txq->tso_hdrs_phys, GFP_KERNEL); &txq->tso_hdrs_phys, GFP_KERNEL);
if (txq->tso_hdrs == NULL) { if (!txq->tso_hdrs) {
kfree(txq->tx_skb); kfree(txq->tx_skb);
dma_free_coherent(pp->dev->dev.parent, dma_free_coherent(pp->dev->dev.parent,
txq->size * MVNETA_DESC_ALIGNED_SIZE, txq->size * MVNETA_DESC_ALIGNED_SIZE,
...@@ -4002,8 +4003,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp) ...@@ -4002,8 +4003,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
/* Set port default values */ /* Set port default values */
mvneta_defaults_set(pp); mvneta_defaults_set(pp);
pp->txqs = devm_kcalloc(dev, txq_number, sizeof(struct mvneta_tx_queue), pp->txqs = devm_kcalloc(dev, txq_number, sizeof(*pp->txqs), GFP_KERNEL);
GFP_KERNEL);
if (!pp->txqs) if (!pp->txqs)
return -ENOMEM; return -ENOMEM;
...@@ -4015,8 +4015,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp) ...@@ -4015,8 +4015,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS; txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS;
} }
pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(struct mvneta_rx_queue), pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(*pp->rxqs), GFP_KERNEL);
GFP_KERNEL);
if (!pp->rxqs) if (!pp->rxqs)
return -ENOMEM; return -ENOMEM;
...@@ -4027,9 +4026,11 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp) ...@@ -4027,9 +4026,11 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
rxq->size = pp->rx_ring_size; rxq->size = pp->rx_ring_size;
rxq->pkts_coal = MVNETA_RX_COAL_PKTS; rxq->pkts_coal = MVNETA_RX_COAL_PKTS;
rxq->time_coal = MVNETA_RX_COAL_USEC; rxq->time_coal = MVNETA_RX_COAL_USEC;
rxq->buf_virt_addr = devm_kmalloc(pp->dev->dev.parent, rxq->buf_virt_addr
rxq->size * sizeof(void *), = devm_kmalloc_array(pp->dev->dev.parent,
GFP_KERNEL); rxq->size,
sizeof(*rxq->buf_virt_addr),
GFP_KERNEL);
if (!rxq->buf_virt_addr) if (!rxq->buf_virt_addr)
return -ENOMEM; return -ENOMEM;
} }
......
This diff is collapsed.
...@@ -556,11 +556,11 @@ static int init_hash_table(struct pxa168_eth_private *pep) ...@@ -556,11 +556,11 @@ static int init_hash_table(struct pxa168_eth_private *pep)
* function.Driver can dynamically switch to them if the 1/2kB hash * function.Driver can dynamically switch to them if the 1/2kB hash
* table is full. * table is full.
*/ */
if (pep->htpr == NULL) { if (!pep->htpr) {
pep->htpr = dma_zalloc_coherent(pep->dev->dev.parent, pep->htpr = dma_zalloc_coherent(pep->dev->dev.parent,
HASH_ADDR_TABLE_SIZE, HASH_ADDR_TABLE_SIZE,
&pep->htpr_dma, GFP_KERNEL); &pep->htpr_dma, GFP_KERNEL);
if (pep->htpr == NULL) if (!pep->htpr)
return -ENOMEM; return -ENOMEM;
} else { } else {
memset(pep->htpr, 0, HASH_ADDR_TABLE_SIZE); memset(pep->htpr, 0, HASH_ADDR_TABLE_SIZE);
...@@ -1036,8 +1036,7 @@ static int rxq_init(struct net_device *dev) ...@@ -1036,8 +1036,7 @@ static int rxq_init(struct net_device *dev)
int rx_desc_num = pep->rx_ring_size; int rx_desc_num = pep->rx_ring_size;
/* Allocate RX skb rings */ /* Allocate RX skb rings */
pep->rx_skb = kzalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size, pep->rx_skb = kcalloc(rx_desc_num, sizeof(*pep->rx_skb), GFP_KERNEL);
GFP_KERNEL);
if (!pep->rx_skb) if (!pep->rx_skb)
return -ENOMEM; return -ENOMEM;
...@@ -1096,8 +1095,7 @@ static int txq_init(struct net_device *dev) ...@@ -1096,8 +1095,7 @@ static int txq_init(struct net_device *dev)
int size = 0, i = 0; int size = 0, i = 0;
int tx_desc_num = pep->tx_ring_size; int tx_desc_num = pep->tx_ring_size;
pep->tx_skb = kzalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size, pep->tx_skb = kcalloc(tx_desc_num, sizeof(*pep->tx_skb), GFP_KERNEL);
GFP_KERNEL);
if (!pep->tx_skb) if (!pep->tx_skb)
return -ENOMEM; return -ENOMEM;
...@@ -1358,7 +1356,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum, ...@@ -1358,7 +1356,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum,
static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr,
int cmd) int cmd)
{ {
if (dev->phydev != NULL) if (dev->phydev)
return phy_mii_ioctl(dev->phydev, ifr, cmd); return phy_mii_ioctl(dev->phydev, ifr, cmd);
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1503,7 +1501,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) ...@@ -1503,7 +1501,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
pep->timeout.data = (unsigned long)pep; pep->timeout.data = (unsigned long)pep;
pep->smi_bus = mdiobus_alloc(); pep->smi_bus = mdiobus_alloc();
if (pep->smi_bus == NULL) { if (!pep->smi_bus) {
err = -ENOMEM; err = -ENOMEM;
goto err_netdev; goto err_netdev;
} }
......
...@@ -2657,7 +2657,7 @@ static int skge_down(struct net_device *dev) ...@@ -2657,7 +2657,7 @@ static int skge_down(struct net_device *dev)
struct skge_hw *hw = skge->hw; struct skge_hw *hw = skge->hw;
int port = skge->port; int port = skge->port;
if (skge->mem == NULL) if (!skge->mem)
return 0; return 0;
netif_info(skge, ifdown, skge->netdev, "disabling interface\n"); netif_info(skge, ifdown, skge->netdev, "disabling interface\n");
...@@ -3718,7 +3718,7 @@ static int skge_debug_show(struct seq_file *seq, void *v) ...@@ -3718,7 +3718,7 @@ static int skge_debug_show(struct seq_file *seq, void *v)
t->csum_offs, t->csum_write, t->csum_start); t->csum_offs, t->csum_write, t->csum_start);
} }
seq_printf(seq, "\nRx Ring:\n"); seq_puts(seq, "\nRx Ring:\n");
for (e = skge->rx_ring.to_clean; ; e = e->next) { for (e = skge->rx_ring.to_clean; ; e = e->next) {
const struct skge_rx_desc *r = e->desc; const struct skge_rx_desc *r = e->desc;
......
...@@ -4544,7 +4544,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v) ...@@ -4544,7 +4544,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
sky2_read32(hw, B0_Y2_SP_ICR)); sky2_read32(hw, B0_Y2_SP_ICR));
if (!netif_running(dev)) { if (!netif_running(dev)) {
seq_printf(seq, "network not running\n"); seq_puts(seq, "network not running\n");
return 0; return 0;
} }
......
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