[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230327-tegra-pmic-reboot-v7-3-18699d5dcd76@skidata.com>
Date: Sat, 15 Jul 2023 09:53:25 +0200
From: Benjamin Bara <bbara93@...il.com>
To: Wolfram Sang <wsa@...nel.org>, Lee Jones <lee@...nel.org>,
rafael.j.wysocki@...el.com,
Wolfram Sang <wsa+renesas@...g-engineering.com>
Cc: dmitry.osipenko@...labora.com, peterz@...radead.org,
jonathanh@...dia.com, richard.leitner@...ux.dev,
treding@...dia.com, linux-kernel@...r.kernel.org,
linux-i2c@...r.kernel.org, linux-tegra@...r.kernel.org,
Benjamin Bara <benjamin.bara@...data.com>
Subject: [PATCH v7 3/5] kernel/reboot: add device to sys_off_handler
From: Benjamin Bara <benjamin.bara@...data.com>
If the dev is known (e.g. a devm-based sys_off_handler is used), it can
be passed to the handler's callback to have it available there.
Otherwise, cb_data might be set to the dev in most of the cases.
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>
Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
---
include/linux/reboot.h | 3 +++
kernel/reboot.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 2b6bb593be5b..c4cc3b89ced1 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -129,11 +129,14 @@ enum sys_off_mode {
* @cb_data: User's callback data.
* @cmd: Command string. Currently used only by the sys-off restart mode,
* NULL otherwise.
+ * @dev: Device of the sys-off handler. Only if known (devm_register_*),
+ * NULL otherwise.
*/
struct sys_off_data {
int mode;
void *cb_data;
const char *cmd;
+ struct device *dev;
};
struct sys_off_handler *
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 6ebef11c8876..395a0ea3c7a8 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -55,6 +55,7 @@ struct sys_off_handler {
enum sys_off_mode mode;
bool blocking;
void *list;
+ struct device *dev;
};
/*
@@ -324,6 +325,7 @@ static int sys_off_notify(struct notifier_block *nb,
data.cb_data = handler->cb_data;
data.mode = mode;
data.cmd = cmd;
+ data.dev = handler->dev;
return handler->sys_off_cb(&data);
}
@@ -511,6 +513,7 @@ int devm_register_sys_off_handler(struct device *dev,
handler = register_sys_off_handler(mode, priority, callback, cb_data);
if (IS_ERR(handler))
return PTR_ERR(handler);
+ handler->dev = dev;
return devm_add_action_or_reset(dev, devm_unregister_sys_off_handler,
handler);
--
2.34.1
Powered by blists - more mailing lists