misc: tizen-inform-reboot: Fix to use filp_open.
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Tue, 19 Jan 2021 07:28:41 +0000 (16:28 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Mon, 7 Feb 2022 08:01:41 +0000 (17:01 +0900)
Modify to use filp_open instead of ksys_open.

Change-Id: I49c8e883d8fd0d76b9ca6c7449303f2859f756b5
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/misc/tizen-inform-reboot.c

index 6cd7ce2..386c1f6 100644 (file)
@@ -23,39 +23,34 @@ static int inform_reboot_notifier(struct notifier_block *nb,
        char *cmd = buf;
        char *filename = CONFIG_TIZEN_INFORM_PATH;
        struct file *file;
-       int fd;
        loff_t pos = 0;
        mm_segment_t old_fs = get_fs();
 
        set_fs(KERNEL_DS);
 
-       fd = ksys_open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
-       if (fd >= 0) {
-               file = fget(fd);
-               if (file) {
-                       struct super_block *sb = file->f_path.dentry->d_sb;
+       file = filp_open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
+       if (file) {
+               struct super_block *sb = file->f_path.dentry->d_sb;
 
-                       if (cmd) {
-                               if (!strncmp(cmd, "fota", 4))
-                                       cmd = "upgr";
-                               else if (!strncmp(cmd, "recovery", 8))
-                                       cmd = "rcvr";
-                               else if (!strncmp(cmd, "download", 8))
-                                       cmd = "dwnl";
-                               else
-                                       cmd = "ndef";
-                       } else
-                               cmd = "norm";
+               if (cmd) {
+                       if (!strncmp(cmd, "fota", 4))
+                               cmd = "upgr";
+                       else if (!strncmp(cmd, "recovery", 8))
+                               cmd = "rcvr";
+                       else if (!strncmp(cmd, "download", 8))
+                               cmd = "dwnl";
+                       else
+                               cmd = "ndef";
+               } else
+                       cmd = "norm";
 
-                       vfs_write(file, cmd, strlen(cmd), &pos);
+               vfs_write(file, cmd, strlen(cmd), &pos);
 
-                       down_read(&sb->s_umount);
-                       sync_filesystem(sb);
-                       up_read(&sb->s_umount);
+               down_read(&sb->s_umount);
+               sync_filesystem(sb);
+               up_read(&sb->s_umount);
 
-                       fput(file);
-               }
-               ksys_close(fd);
+               fput(file);
        } else {
                pr_err("Reboot parameter passing is failed.\n"
                                "Inform file path should be described correctly in config.\n");