switch: add timestamps to switch driver
authorErik Gilling <konkers@android.com>
Mon, 2 Apr 2012 22:46:24 +0000 (15:46 -0700)
committerErik Gilling <konkers@android.com>
Mon, 2 Apr 2012 23:33:57 +0000 (16:33 -0700)
Change-Id: Iac5b5279f45fcc6e506d801cb5e9d6d2f6f6f9fa
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/switch/switch_class.c

index e05fc25911474b244b57e3c20907e6d15f53f950..cd2456a3cbd824165358b93b3afbe26b559f3e76 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/fs.h>
 #include <linux/err.h>
 #include <linux/switch.h>
+#include <linux/hrtimer.h>
 
 struct class *switch_class;
 static atomic_t device_count;
@@ -61,8 +62,9 @@ void switch_set_state(struct switch_dev *sdev, int state)
 {
        char name_buf[120];
        char state_buf[120];
+       char timestamp_buf[120];
        char *prop_buf;
-       char *envp[3];
+       char *envp[4];
        int env_offset = 0;
        int length;
 
@@ -87,6 +89,9 @@ void switch_set_state(struct switch_dev *sdev, int state)
                                        "SWITCH_STATE=%s", prop_buf);
                                envp[env_offset++] = state_buf;
                        }
+                       snprintf(timestamp_buf, sizeof(timestamp_buf),
+                                "SWITCH_TIME=%llu", ktime_to_ns(ktime_get()));
+                       envp[env_offset++] = timestamp_buf;
                        envp[env_offset] = NULL;
                        kobject_uevent_env(&sdev->dev->kobj, KOBJ_CHANGE, envp);
                        free_page((unsigned long)prop_buf);