Skip to content

Commit

Permalink
mvpp2: refactor BM pool init percpu code
Browse files Browse the repository at this point in the history
In mvpp2_swf_bm_pool_init_percpu(), a reference to a struct
mvpp2_bm_pool is obtained traversing multiple structs, when a
local variable already points to the same object.

Fix it and, while at it, give the variable a meaningful name.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Matteo Croce authored and David S. Miller committed Jul 3, 2020
1 parent b0d754e commit 136bcd8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,28 +907,27 @@ static int mvpp2_swf_bm_pool_init_shared(struct mvpp2_port *port)
/* Initialize pools for swf, percpu buffers variant */
static int mvpp2_swf_bm_pool_init_percpu(struct mvpp2_port *port)
{
struct mvpp2_bm_pool *p;
struct mvpp2_bm_pool *bm_pool;
int i;

for (i = 0; i < port->nrxqs; i++) {
p = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_SHORT, i,
mvpp2_pools[MVPP2_BM_SHORT].pkt_size);
if (!p)
bm_pool = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_SHORT, i,
mvpp2_pools[MVPP2_BM_SHORT].pkt_size);
if (!bm_pool)
return -ENOMEM;

port->priv->bm_pools[i].port_map |= BIT(port->id);
mvpp2_rxq_short_pool_set(port, i, port->priv->bm_pools[i].id);
bm_pool->port_map |= BIT(port->id);
mvpp2_rxq_short_pool_set(port, i, bm_pool->id);
}

for (i = 0; i < port->nrxqs; i++) {
p = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_LONG, i + port->nrxqs,
mvpp2_pools[MVPP2_BM_LONG].pkt_size);
if (!p)
bm_pool = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_LONG, i + port->nrxqs,
mvpp2_pools[MVPP2_BM_LONG].pkt_size);
if (!bm_pool)
return -ENOMEM;

port->priv->bm_pools[i + port->nrxqs].port_map |= BIT(port->id);
mvpp2_rxq_long_pool_set(port, i,
port->priv->bm_pools[i + port->nrxqs].id);
bm_pool->port_map |= BIT(port->id);
mvpp2_rxq_long_pool_set(port, i, bm_pool->id);
}

port->pool_long = NULL;
Expand Down

0 comments on commit 136bcd8

Please sign in to comment.