diff options
author | Chuhong Yuan <hslester96@gmail.com> | 2019-08-02 12:48:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-08-08 20:58:40 -0400 |
commit | 4b4de39850474350bfc2f3df33ee1c23d0475c59 (patch) | |
tree | fcd84345e0df1e14c8d32b371661b7467ce597d3 | |
parent | 31168a6d129aebc02f92d4b7cc9946c0b6364c2b (diff) |
mkiss: 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 <hslester96@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/hamradio/mkiss.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 442018ccd65e..c5bfa19ddb93 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/skbuff.h> | 25 | #include <linux/skbuff.h> |
26 | #include <linux/if_arp.h> | 26 | #include <linux/if_arp.h> |
27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
28 | #include <linux/refcount.h> | ||
28 | 29 | ||
29 | #include <net/ax25.h> | 30 | #include <net/ax25.h> |
30 | 31 | ||
@@ -70,7 +71,7 @@ struct mkiss { | |||
70 | #define CRC_MODE_FLEX_TEST 3 | 71 | #define CRC_MODE_FLEX_TEST 3 |
71 | #define CRC_MODE_SMACK_TEST 4 | 72 | #define CRC_MODE_SMACK_TEST 4 |
72 | 73 | ||
73 | atomic_t refcnt; | 74 | refcount_t refcnt; |
74 | struct completion dead; | 75 | struct completion dead; |
75 | }; | 76 | }; |
76 | 77 | ||
@@ -668,7 +669,7 @@ static struct mkiss *mkiss_get(struct tty_struct *tty) | |||
668 | read_lock(&disc_data_lock); | 669 | read_lock(&disc_data_lock); |
669 | ax = tty->disc_data; | 670 | ax = tty->disc_data; |
670 | if (ax) | 671 | if (ax) |
671 | atomic_inc(&ax->refcnt); | 672 | refcount_inc(&ax->refcnt); |
672 | read_unlock(&disc_data_lock); | 673 | read_unlock(&disc_data_lock); |
673 | 674 | ||
674 | return ax; | 675 | return ax; |
@@ -676,7 +677,7 @@ static struct mkiss *mkiss_get(struct tty_struct *tty) | |||
676 | 677 | ||
677 | static void mkiss_put(struct mkiss *ax) | 678 | static void mkiss_put(struct mkiss *ax) |
678 | { | 679 | { |
679 | if (atomic_dec_and_test(&ax->refcnt)) | 680 | if (refcount_dec_and_test(&ax->refcnt)) |
680 | complete(&ax->dead); | 681 | complete(&ax->dead); |
681 | } | 682 | } |
682 | 683 | ||
@@ -704,7 +705,7 @@ static int mkiss_open(struct tty_struct *tty) | |||
704 | ax->dev = dev; | 705 | ax->dev = dev; |
705 | 706 | ||
706 | spin_lock_init(&ax->buflock); | 707 | spin_lock_init(&ax->buflock); |
707 | atomic_set(&ax->refcnt, 1); | 708 | refcount_set(&ax->refcnt, 1); |
708 | init_completion(&ax->dead); | 709 | init_completion(&ax->dead); |
709 | 710 | ||
710 | ax->tty = tty; | 711 | ax->tty = tty; |
@@ -784,7 +785,7 @@ static void mkiss_close(struct tty_struct *tty) | |||
784 | * We have now ensured that nobody can start using ap from now on, but | 785 | * We have now ensured that nobody can start using ap from now on, but |
785 | * we have to wait for all existing users to finish. | 786 | * we have to wait for all existing users to finish. |
786 | */ | 787 | */ |
787 | if (!atomic_dec_and_test(&ax->refcnt)) | 788 | if (!refcount_dec_and_test(&ax->refcnt)) |
788 | wait_for_completion(&ax->dead); | 789 | wait_for_completion(&ax->dead); |
789 | /* | 790 | /* |
790 | * Halt the transmit queue so that a new transmit cannot scribble | 791 | * Halt the transmit queue so that a new transmit cannot scribble |