Merge tag 'leds_for_4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewsk...
[deliverable/linux.git] / drivers / staging / android / sync_debug.c
index 5f57499c98bfc9beff5d62d90d7b00765dc1593f..4c5a85595a85b7d6339804d20a80a42b0aa5eabf 100644 (file)
  */
 
 #include <linux/debugfs.h>
-#include <linux/export.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/seq_file.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/anon_inodes.h>
-#include <linux/time64.h>
-#include <linux/sync_file.h>
-#include "sw_sync.h"
-
-#ifdef CONFIG_DEBUG_FS
+#include "sync_debug.h"
 
 static struct dentry *dbgfs;
 
@@ -105,7 +91,7 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show)
                seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec);
        }
 
-       if ((!fence || fence->ops->timeline_value_str) &&
+       if (fence->ops->timeline_value_str &&
                fence->ops->fence_value_str) {
                char value[64];
                bool success;
@@ -113,10 +99,9 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show)
                fence->ops->fence_value_str(fence, value, sizeof(value));
                success = strlen(value);
 
-               if (success)
+               if (success) {
                        seq_printf(s, ": %s", value);
 
-               if (success && fence) {
                        fence->ops->timeline_value_str(fence, value,
                                                       sizeof(value));
 
@@ -133,22 +118,13 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
        struct list_head *pos;
        unsigned long flags;
 
-       seq_printf(s, "%s %s", obj->name, obj->ops->driver_name);
-
-       if (obj->ops->timeline_value_str) {
-               char value[64];
-
-               obj->ops->timeline_value_str(obj, value, sizeof(value));
-               seq_printf(s, ": %s", value);
-       }
-
-       seq_puts(s, "\n");
+       seq_printf(s, "%s: %d\n", obj->name, obj->value);
 
        spin_lock_irqsave(&obj->child_list_lock, flags);
        list_for_each(pos, &obj->child_list_head) {
-               struct fence *fence =
-                       container_of(pos, struct fence, child_list);
-               sync_print_fence(s, fence, false);
+               struct sync_pt *pt =
+                       container_of(pos, struct sync_pt, child_list);
+               sync_print_fence(s, &pt->base, false);
        }
        spin_unlock_irqrestore(&obj->child_list_lock, flags);
 }
@@ -209,126 +185,19 @@ static const struct file_operations sync_info_debugfs_fops = {
        .release        = single_release,
 };
 
-/*
- * *WARNING*
- *
- * improper use of this can result in deadlocking kernel drivers from userspace.
- */
-
-/* opening sw_sync create a new sync obj */
-static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
-{
-       struct sw_sync_timeline *obj;
-       char task_comm[TASK_COMM_LEN];
-
-       get_task_comm(task_comm, current);
-
-       obj = sw_sync_timeline_create(task_comm);
-       if (!obj)
-               return -ENOMEM;
-
-       file->private_data = obj;
-
-       return 0;
-}
-
-static int sw_sync_debugfs_release(struct inode *inode, struct file *file)
-{
-       struct sw_sync_timeline *obj = file->private_data;
-
-       sync_timeline_destroy(&obj->obj);
-       return 0;
-}
-
-static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
-                                      unsigned long arg)
-{
-       int fd = get_unused_fd_flags(O_CLOEXEC);
-       int err;
-       struct fence *fence;
-       struct sync_file *sync_file;
-       struct sw_sync_create_fence_data data;
-
-       if (fd < 0)
-               return fd;
-
-       if (copy_from_user(&data, (void __user *)arg, sizeof(data))) {
-               err = -EFAULT;
-               goto err;
-       }
-
-       fence = sw_sync_pt_create(obj, data.value);
-       if (!fence) {
-               err = -ENOMEM;
-               goto err;
-       }
-
-       sync_file = sync_file_create(fence);
-       if (!sync_file) {
-               fence_put(fence);
-               err = -ENOMEM;
-               goto err;
-       }
-
-       data.fence = fd;
-       if (copy_to_user((void __user *)arg, &data, sizeof(data))) {
-               fput(sync_file->file);
-               err = -EFAULT;
-               goto err;
-       }
-
-       fd_install(fd, sync_file->file);
-
-       return 0;
-
-err:
-       put_unused_fd(fd);
-       return err;
-}
-
-static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg)
-{
-       u32 value;
-
-       if (copy_from_user(&value, (void __user *)arg, sizeof(value)))
-               return -EFAULT;
-
-       sw_sync_timeline_inc(obj, value);
-
-       return 0;
-}
-
-static long sw_sync_ioctl(struct file *file, unsigned int cmd,
-                         unsigned long arg)
-{
-       struct sw_sync_timeline *obj = file->private_data;
-
-       switch (cmd) {
-       case SW_SYNC_IOC_CREATE_FENCE:
-               return sw_sync_ioctl_create_fence(obj, arg);
-
-       case SW_SYNC_IOC_INC:
-               return sw_sync_ioctl_inc(obj, arg);
-
-       default:
-               return -ENOTTY;
-       }
-}
-
-static const struct file_operations sw_sync_debugfs_fops = {
-       .open           = sw_sync_debugfs_open,
-       .release        = sw_sync_debugfs_release,
-       .unlocked_ioctl = sw_sync_ioctl,
-       .compat_ioctl = sw_sync_ioctl,
-};
-
 static __init int sync_debugfs_init(void)
 {
        dbgfs = debugfs_create_dir("sync", NULL);
 
-       debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops);
-       debugfs_create_file("sw_sync", 0644, dbgfs, NULL,
-                           &sw_sync_debugfs_fops);
+       /*
+        * The debugfs files won't ever get removed and thus, there is
+        * no need to protect it against removal races. The use of
+        * debugfs_create_file_unsafe() is actually safe here.
+        */
+       debugfs_create_file_unsafe("info", 0444, dbgfs, NULL,
+                                  &sync_info_debugfs_fops);
+       debugfs_create_file_unsafe("sw_sync", 0644, dbgfs, NULL,
+                                  &sw_sync_debugfs_fops);
 
        return 0;
 }
@@ -359,5 +228,3 @@ void sync_dump(void)
                }
        }
 }
-
-#endif
This page took 0.044044 seconds and 5 git commands to generate.