Skip to content

Commit 31168a6

Browse files
WillLesterdavem330
authored andcommitted
dpaa_eth: Use refcount_t for refcount
refcount_t is better for reference counters since its implementation can prevent overflows. So convert atomic_t ref counters to refcount_t. Signed-off-by: Chuhong Yuan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3a598e commit 31168a6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static struct dpaa_bp *dpaa_bpid2pool(int bpid)
485485
static bool dpaa_bpid2pool_use(int bpid)
486486
{
487487
if (dpaa_bpid2pool(bpid)) {
488-
atomic_inc(&dpaa_bp_array[bpid]->refs);
488+
refcount_inc(&dpaa_bp_array[bpid]->refs);
489489
return true;
490490
}
491491

@@ -496,7 +496,7 @@ static bool dpaa_bpid2pool_use(int bpid)
496496
static void dpaa_bpid2pool_map(int bpid, struct dpaa_bp *dpaa_bp)
497497
{
498498
dpaa_bp_array[bpid] = dpaa_bp;
499-
atomic_set(&dpaa_bp->refs, 1);
499+
refcount_set(&dpaa_bp->refs, 1);
500500
}
501501

502502
static int dpaa_bp_alloc_pool(struct dpaa_bp *dpaa_bp)
@@ -584,7 +584,7 @@ static void dpaa_bp_free(struct dpaa_bp *dpaa_bp)
584584
if (!bp)
585585
return;
586586

587-
if (!atomic_dec_and_test(&bp->refs))
587+
if (!refcount_dec_and_test(&bp->refs))
588588
return;
589589

590590
if (bp->free_buf_cb)

drivers/net/ethernet/freescale/dpaa/dpaa_eth.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define __DPAA_H
3333

3434
#include <linux/netdevice.h>
35+
#include <linux/refcount.h>
3536
#include <soc/fsl/qman.h>
3637
#include <soc/fsl/bman.h>
3738

@@ -99,7 +100,7 @@ struct dpaa_bp {
99100
int (*seed_cb)(struct dpaa_bp *);
100101
/* bpool can be emptied before freeing by this cb */
101102
void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *);
102-
atomic_t refs;
103+
refcount_t refs;
103104
};
104105

105106
struct dpaa_rx_errors {

0 commit comments

Comments
 (0)