misc: tegra-throughput: move fps node to sysfs
Ilan Aelion [Mon, 6 May 2013 23:06:29 +0000 (17:06 -0600)]
Move node from debugfs to

    /sys/devices/virtual/misc/tegra-throughput/fps

Bug 1276548

Change-Id: I1a73f99922712e59d46fddc76707934fdd944de6
Signed-off-by: Ilan Aelion <iaelion@nvidia.com>
Reviewed-on: http://git-master/r/225902
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/misc/tegra-throughput.c

index c3c666c..4079495 100644 (file)
@@ -86,8 +86,6 @@ static void throughput_flip_callback(void)
        }
 
        last_flip = now;
-
-       return NOTIFY_OK;
 }
 
 static void reset_target_frame_time(void)
@@ -195,14 +193,14 @@ static struct miscdevice throughput_miscdev = {
        .mode  = 0666,
 };
 
-static int fps_show(struct seq_file *s, void *unused)
+static ssize_t show_fps(struct kobject *kobj,
+       struct attribute *attr, char *buf)
 {
        int frame_time_avg;
-       int fps;
        ktime_t now;
        long timediff;
+       int fps = 0;
 
-       fps = 0;
        if (frame_time_sum_init)
                goto DONE;
 
@@ -215,21 +213,11 @@ static int fps_show(struct seq_file *s, void *unused)
        fps = frame_time_avg > 0 ? 1000000 / frame_time_avg : 0;
 
 DONE:
-       seq_printf(s, "%d\n", fps);
-       return 0;
+       return sprintf(buf, "%d\n", fps);
 }
 
-static int fps_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, fps_show, inode->i_private);
-}
-
-static const struct file_operations fps_fops = {
-       .open           = fps_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+static struct global_attr fps_attr = __ATTR(fps, 0444,
+               show_fps, NULL);
 
 int __init throughput_init_miscdev(void)
 {
@@ -247,7 +235,10 @@ int __init throughput_init_miscdev(void)
                return ret;
        }
 
-       debugfs_create_file("fps", 0444, NULL, NULL, &fps_fops);
+       ret = sysfs_create_file(&throughput_miscdev.this_device->kobj,
+               &fps_attr.attr);
+       if (ret)
+               pr_err("%s: error %d creating sysfs node\n", __func__, ret);
 
        tegra_dc_set_flip_callback(throughput_flip_callback);
 
@@ -264,6 +255,8 @@ void __exit throughput_exit_miscdev(void)
 
        cancel_work_sync(&work);
 
+       sysfs_remove_file(&throughput_miscdev.this_device->kobj, &fps_attr.attr);
+
        misc_deregister(&throughput_miscdev);
 }