[PATCH 1/4] restart: give poweroff_machine and restart_machine a flag parameter
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Apr 22 00:56:12 PDT 2025
From: Ahmad Fatoum <a.fatoum at barebox.org>
We currently do differentiate between warm and cold reset, but
restart_machine has no flag to choose between them and instead users
need to iterate over all registered handlers and choose a suitable one
and then call hat handler's action.
In preparation for making warm/cold reset and any other flags we may
require a feature an argument to the driver action, change all
poweroff_machine and restart_machine calls to take a flags parameter.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
arch/arm/boards/zii-common/board.c | 2 +-
arch/arm/cpu/psci.c | 2 +-
arch/arm/lib32/bootm.c | 4 ++--
arch/arm/mach-at91/bootstrap.c | 2 +-
arch/arm/mach-mvebu/kwbootimage.c | 2 +-
arch/arm/mach-tegra/tegra20-pmc.c | 2 +-
arch/mips/lib/bootm.c | 2 +-
arch/powerpc/lib/ppclinux.c | 2 +-
commands/poweroff.c | 2 +-
common/fastboot.c | 2 +-
common/misc.c | 4 ++--
common/poweroff.c | 2 +-
common/ratp/reset.c | 2 +-
common/restart.c | 2 +-
drivers/input/specialkeys.c | 4 ++--
include/poweroff.h | 2 +-
include/restart.h | 2 +-
17 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/arm/boards/zii-common/board.c b/arch/arm/boards/zii-common/board.c
index 96f9243591f2..29d9acb5ab07 100644
--- a/arch/arm/boards/zii-common/board.c
+++ b/arch/arm/boards/zii-common/board.c
@@ -122,7 +122,7 @@ static int rdu_i210_invm(void)
pwrite(fd, &val, sizeof(val), 0);
shutdown_barebox();
- restart_machine();
+ restart_machine(0);
return 0;
}
diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index 70c97e03a5ff..ed26a3138dfe 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -144,7 +144,7 @@ static unsigned long psci_system_reset(void)
if (psci_ops->system_reset)
psci_ops->system_reset();
- restart_machine();
+ restart_machine(0);
}
/* Avoid missing prototype warning, called from assembly */
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index 625091ece1e9..017e9b0edc4b 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -337,7 +337,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem,
start_linux((void *)kernel, swap, initrd_start, initrd_size,
fdt_load_address, state, tee);
- restart_machine();
+ restart_machine(0);
return -ERESTARTSYS;
}
@@ -695,7 +695,7 @@ static int do_bootm_aimage(struct image_data *data)
second();
- restart_machine();
+ restart_machine(0);
}
close(fd);
diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c
index fbf5fa78a157..0ccdef93477d 100644
--- a/arch/arm/mach-at91/bootstrap.c
+++ b/arch/arm/mach-at91/bootstrap.c
@@ -146,7 +146,7 @@ static void boot_mmc_disk_action(struct menu *m, struct menu_entry *me)
static void boot_reset_action(struct menu *m, struct menu_entry *me)
{
- restart_machine();
+ restart_machine(0);
}
static void at91_bootstrap_menu(void)
diff --git a/arch/arm/mach-mvebu/kwbootimage.c b/arch/arm/mach-mvebu/kwbootimage.c
index 2bcc42fe5749..e016941075e2 100644
--- a/arch/arm/mach-mvebu/kwbootimage.c
+++ b/arch/arm/mach-mvebu/kwbootimage.c
@@ -64,7 +64,7 @@ static int do_bootm_kwbimage_v0_v1(struct image_data *data)
barebox();
- restart_machine();
+ restart_machine(0);
out_free:
free(barebox);
diff --git a/arch/arm/mach-tegra/tegra20-pmc.c b/arch/arm/mach-tegra/tegra20-pmc.c
index 11fd8c28be59..d4c28ac54142 100644
--- a/arch/arm/mach-tegra/tegra20-pmc.c
+++ b/arch/arm/mach-tegra/tegra20-pmc.c
@@ -221,7 +221,7 @@ static int tegra20_pmc_probe(struct device *dev)
static int do_tegrarcm(int argc, char *argv[])
{
writel(2, pmc_base + PMC_SCRATCH(0));
- restart_machine();
+ restart_machine(0);
return 0;
}
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index a623b1c83b35..2bc8283f7d7b 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -40,7 +40,7 @@ static int do_bootm_barebox(struct image_data *data)
barebox(-2, fdt);
- restart_machine();
+ restart_machine(0);
}
static struct image_handler barebox_handler = {
diff --git a/arch/powerpc/lib/ppclinux.c b/arch/powerpc/lib/ppclinux.c
index 9b8404962cea..6b00c2ee5756 100644
--- a/arch/powerpc/lib/ppclinux.c
+++ b/arch/powerpc/lib/ppclinux.c
@@ -98,7 +98,7 @@ static int do_bootm_linux(struct image_data *data)
*/
kernel(fdt, kernel, 0, 0, 0);
- restart_machine();
+ restart_machine(0);
error:
return -1;
diff --git a/commands/poweroff.c b/commands/poweroff.c
index 9320c07a6c5f..5c793fc4e3ae 100644
--- a/commands/poweroff.c
+++ b/commands/poweroff.c
@@ -9,7 +9,7 @@
static int cmd_poweroff(int argc, char *argv[])
{
- poweroff_machine();
+ poweroff_machine(0);
/* Not reached */
return 1;
diff --git a/common/fastboot.c b/common/fastboot.c
index 60bef0ec776b..a444b81a7bec 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -284,7 +284,7 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
static void cb_reboot(struct fastboot *fb, const char *cmd)
{
fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
- restart_machine();
+ restart_machine(0);
}
static void cb_getvar(struct fastboot *fb, const char *cmd)
diff --git a/common/misc.c b/common/misc.c
index 375fbbb199c7..ce1fbc284f48 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -303,9 +303,9 @@ static void __noreturn do_panic(bool stacktrace, const char *fmt, va_list ap)
mdelay_non_interruptible(100); /* allow messages to go out */
if (IS_ENABLED(CONFIG_PANIC_POWEROFF))
- poweroff_machine();
+ poweroff_machine(0);
else
- restart_machine();
+ restart_machine(0);
}
void __noreturn panic(const char *fmt, ...)
diff --git a/common/poweroff.c b/common/poweroff.c
index 65909c614145..d453a9a98025 100644
--- a/common/poweroff.c
+++ b/common/poweroff.c
@@ -63,7 +63,7 @@ int poweroff_handler_register_fn(void (*poweroff_fn)(struct poweroff_handler *))
/**
* poweroff_machine() - power off the machine
*/
-void __noreturn poweroff_machine(void)
+void __noreturn poweroff_machine(unsigned long flags)
{
struct poweroff_handler *handler = NULL, *tmp;
unsigned int priority = 0;
diff --git a/common/ratp/reset.c b/common/ratp/reset.c
index 060475169ba3..c6453b094722 100644
--- a/common/ratp/reset.c
+++ b/common/ratp/reset.c
@@ -43,7 +43,7 @@ static int ratp_cmd_reset(const struct ratp_bb *req, int req_len,
if (!reset_req->force)
shutdown_barebox();
- restart_machine();
+ restart_machine(0);
/* Not reached */
return 1;
}
diff --git a/common/restart.c b/common/restart.c
index e54b4d7c5b82..2ab0196542d8 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -102,7 +102,7 @@ struct restart_handler *restart_handler_get_by_name(const char *name, int flags)
/**
* restart_machine() - reset the whole system
*/
-void __noreturn restart_machine(void)
+void __noreturn restart_machine(unsigned long flags)
{
struct restart_handler *rst;
diff --git a/drivers/input/specialkeys.c b/drivers/input/specialkeys.c
index f9693dc383c4..9db93804f82e 100644
--- a/drivers/input/specialkeys.c
+++ b/drivers/input/specialkeys.c
@@ -14,12 +14,12 @@ static void input_specialkeys_notify(struct input_notifier *in,
switch (ev->code) {
case KEY_RESTART:
pr_info("Triggering reset due to special key.\n");
- restart_machine();
+ restart_machine(0);
break;
case KEY_POWER:
pr_info("Triggering poweroff due to special key.\n");
- poweroff_machine();
+ poweroff_machine(0);
break;
}
diff --git a/include/poweroff.h b/include/poweroff.h
index 217b68cdf966..307097c01541 100644
--- a/include/poweroff.h
+++ b/include/poweroff.h
@@ -2,7 +2,7 @@
#ifndef __INCLUDE_POWEROFF_H
#define __INCLUDE_POWEROFF_H
-void __noreturn poweroff_machine(void);
+void __noreturn poweroff_machine(unsigned long poweroff_flags);
struct poweroff_handler {
void (*poweroff)(struct poweroff_handler *);
diff --git a/include/restart.h b/include/restart.h
index 02db7915075e..75d96111ea1b 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -9,7 +9,7 @@
struct device_node;
void restart_handlers_print(void);
-void __noreturn restart_machine(void);
+void __noreturn restart_machine(unsigned long restart_flags);
struct restart_handler *restart_handler_get_by_name(const char *name, int flags);
struct device_node;
--
2.39.5
More information about the barebox
mailing list