From c9458239ab7b0103ff1d94958eb1b9a97968f938 Mon Sep 17 00:00:00 2001 From: Junghoon Kim Date: Mon, 21 Aug 2017 11:04:32 +0900 Subject: [PATCH] misc: add Tizen reboot notifier for passing reboot parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To determine booting mode (e.g, fota or recovery) in u-boot side, reboot parameter should be passed through inform partition. Add Tizen reboot notifier for passing reboot parameter. Signed-off-by: Junghoon Kim Signed-off-by: Łukasz Stelmach Signed-off-by: Dongwoo Lee Signed-off-by: Hoegeun Kwon Signed-off-by: Jaehoon Chung [mszyprow: this is a squashed set of the following patches from platform/kernel/linux-rpi 'tizen' (c4f85fdcd893) branch: misc: add Tizen reboot notifier for passing reboot parameter misc: make sure Tizen notifier is executed before reset misc: tizen-inform-reboot: resolve sync failure about reboot parameter misc: tizen-inform-reboot: Add support for download mode misc: tizen-inform-reboot: Use ksys_open() and ksys_close() wrappers misc: tizen-inform-reboot: Fix to use filp_open. misc: tizen-inform-reboot: Fix build error misc: tizen-inform-reboot: fix a potential NULL pointer dereference misc: tizen-inform-reboot: Remove force_uaccess begin and end func misc: tizen-inform_reboot: Fix to use kernel_write function ported to v6.6 kernel] Signed-off-by: Marek Szyprowski Change-Id: Ic3cd55cd95cec07a8b3eb34ea3e75f1156c33423 --- drivers/misc/Kconfig | 16 +++++++++ drivers/misc/Makefile | 1 + drivers/misc/tizen-inform-reboot.c | 71 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 drivers/misc/tizen-inform-reboot.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a76c6c9..75cdf21 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -570,6 +570,22 @@ config TPS6594_PFSM This driver can also be built as a module. If so, the module will be called tps6594-pfsm. +config TIZEN_INFORM_REBOOT + bool "Tizen reboot parameter passing support" + default "n" + help + This enables support for passing reboot parameter through inform + partition. It is required to determine booting mode (e.g., fota or + normal). After passing reboot parameter, u-boot checks the contents + of inform file and then determines proper booting mode. + +config TIZEN_INFORM_PATH + depends on TIZEN_INFORM_REBOOT + string "Absolute path of inform file for passing reboot parameter" + help + This option determines the absolute path of inform file for passing + reboot parameter. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 02bc566..777161c 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -68,3 +68,4 @@ obj-$(CONFIG_TMR_MANAGER) += xilinx_tmr_manager.o obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o +obj-$(CONFIG_TIZEN_INFORM_REBOOT) += tizen-inform-reboot.o diff --git a/drivers/misc/tizen-inform-reboot.c b/drivers/misc/tizen-inform-reboot.c new file mode 100644 index 0000000..f85386e --- /dev/null +++ b/drivers/misc/tizen-inform-reboot.c @@ -0,0 +1,71 @@ +/* + * Tizen reboot parameter passing notifier + * + * Written by: Junghoon Kim + * + * Copyright (C) 2017 Samsung Electronics Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +static int inform_reboot_notifier(struct notifier_block *nb, + unsigned long val, void *buf) +{ + char *cmd = buf; + char *filename = CONFIG_TIZEN_INFORM_PATH; + struct file *file; + loff_t pos = 0; + + file = filp_open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644); + if (!IS_ERR(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"; + + kernel_write(file, cmd, strlen(cmd), &pos); + + down_read(&sb->s_umount); + sync_filesystem(sb); + up_read(&sb->s_umount); + + fput(file); + } else { + pr_err("Reboot parameter passing is failed.\n" + "Inform file path should be described correctly in config.\n"); + } + + return NOTIFY_DONE; +} + +static struct notifier_block nb_inform_reboot_block = { + .notifier_call = inform_reboot_notifier, + .priority = 256, +}; + +static int __init inform_reboot_init(void) +{ + /* to support reboot parameter passing */ + register_reboot_notifier(&nb_inform_reboot_block); + return 0; +} + +subsys_initcall(inform_reboot_init); -- 2.7.4