]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
misc: tegra-throughput: move fps node to sysfs
authorIlan Aelion <iaelion@nvidia.com>
Mon, 6 May 2013 23:06:29 +0000 (17:06 -0600)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:12:59 +0000 (13:12 -0700)
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
(cherry picked from commit 7ec9674a81cda32c888f35d9d7fbb3ec99d43b4b)
Reviewed-on: http://git-master/r/227496
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/misc/tegra-throughput.c

index 2b5cf1447027e025f0fb4b691d92aea42444c9d2..2535dcb3b29e580c9c8878239fae8947b7092a04 100644 (file)
@@ -193,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;
 
@@ -213,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;
-}
-
-static int fps_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, fps_show, inode->i_private);
+       return sprintf(buf, "%d\n", fps);
 }
 
-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)
 {
@@ -245,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);
 
@@ -262,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);
 }