Merge tag 'dma-mapping-5.1' of git://git.infradead.org/users/hch/dma-mapping
[linux-2.6-microblaze.git] / kernel / kcov.c
index c2277db..2ee3872 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/kcov.h>
+#include <linux/refcount.h>
 #include <asm/setup.h>
 
 /* Number of 64-bit words written per one comparison: */
@@ -44,7 +45,7 @@ struct kcov {
         *  - opened file descriptor
         *  - task with enabled coverage (we can't unwire it from another task)
         */
-       atomic_t                refcount;
+       refcount_t              refcount;
        /* The lock protects mode, size, area and t. */
        spinlock_t              lock;
        enum kcov_mode          mode;
@@ -228,12 +229,12 @@ EXPORT_SYMBOL(__sanitizer_cov_trace_switch);
 
 static void kcov_get(struct kcov *kcov)
 {
-       atomic_inc(&kcov->refcount);
+       refcount_inc(&kcov->refcount);
 }
 
 static void kcov_put(struct kcov *kcov)
 {
-       if (atomic_dec_and_test(&kcov->refcount)) {
+       if (refcount_dec_and_test(&kcov->refcount)) {
                vfree(kcov->area);
                kfree(kcov);
        }
@@ -312,7 +313,7 @@ static int kcov_open(struct inode *inode, struct file *filep)
        if (!kcov)
                return -ENOMEM;
        kcov->mode = KCOV_MODE_DISABLED;
-       atomic_set(&kcov->refcount, 1);
+       refcount_set(&kcov->refcount, 1);
        spin_lock_init(&kcov->lock);
        filep->private_data = kcov;
        return nonseekable_open(inode, filep);
@@ -444,10 +445,8 @@ static int __init kcov_init(void)
         * there is no need to protect it against removal races. The
         * use of debugfs_create_file_unsafe() is actually safe here.
         */
-       if (!debugfs_create_file_unsafe("kcov", 0600, NULL, NULL, &kcov_fops)) {
-               pr_err("failed to create kcov in debugfs\n");
-               return -ENOMEM;
-       }
+       debugfs_create_file_unsafe("kcov", 0600, NULL, NULL, &kcov_fops);
+
        return 0;
 }