Commit 31168a6d authored by Chuhong Yuan's avatar Chuhong Yuan Committed by David S. Miller

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: default avatarChuhong Yuan <hslester96@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b3a598eb
...@@ -485,7 +485,7 @@ static struct dpaa_bp *dpaa_bpid2pool(int bpid) ...@@ -485,7 +485,7 @@ static struct dpaa_bp *dpaa_bpid2pool(int bpid)
static bool dpaa_bpid2pool_use(int bpid) static bool dpaa_bpid2pool_use(int bpid)
{ {
if (dpaa_bpid2pool(bpid)) { if (dpaa_bpid2pool(bpid)) {
atomic_inc(&dpaa_bp_array[bpid]->refs); refcount_inc(&dpaa_bp_array[bpid]->refs);
return true; return true;
} }
...@@ -496,7 +496,7 @@ static bool dpaa_bpid2pool_use(int bpid) ...@@ -496,7 +496,7 @@ static bool dpaa_bpid2pool_use(int bpid)
static void dpaa_bpid2pool_map(int bpid, struct dpaa_bp *dpaa_bp) static void dpaa_bpid2pool_map(int bpid, struct dpaa_bp *dpaa_bp)
{ {
dpaa_bp_array[bpid] = dpaa_bp; dpaa_bp_array[bpid] = dpaa_bp;
atomic_set(&dpaa_bp->refs, 1); refcount_set(&dpaa_bp->refs, 1);
} }
static int dpaa_bp_alloc_pool(struct dpaa_bp *dpaa_bp) 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) ...@@ -584,7 +584,7 @@ static void dpaa_bp_free(struct dpaa_bp *dpaa_bp)
if (!bp) if (!bp)
return; return;
if (!atomic_dec_and_test(&bp->refs)) if (!refcount_dec_and_test(&bp->refs))
return; return;
if (bp->free_buf_cb) if (bp->free_buf_cb)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define __DPAA_H #define __DPAA_H
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/refcount.h>
#include <soc/fsl/qman.h> #include <soc/fsl/qman.h>
#include <soc/fsl/bman.h> #include <soc/fsl/bman.h>
...@@ -99,7 +100,7 @@ struct dpaa_bp { ...@@ -99,7 +100,7 @@ struct dpaa_bp {
int (*seed_cb)(struct dpaa_bp *); int (*seed_cb)(struct dpaa_bp *);
/* bpool can be emptied before freeing by this cb */ /* bpool can be emptied before freeing by this cb */
void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *); void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *);
atomic_t refs; refcount_t refs;
}; };
struct dpaa_rx_errors { struct dpaa_rx_errors {
......
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