Commit db2d6038 authored by Benjamin Bara's avatar Benjamin Bara Committed by Lee Jones

kernel/reboot: Add device to sys_off_handler

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: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: default avatarBenjamin Bara <benjamin.bara@skidata.com>
Link: https://lore.kernel.org/r/20230327-tegra-pmic-reboot-v7-3-18699d5dcd76@skidata.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent aa49c908
...@@ -129,11 +129,14 @@ enum sys_off_mode { ...@@ -129,11 +129,14 @@ enum sys_off_mode {
* @cb_data: User's callback data. * @cb_data: User's callback data.
* @cmd: Command string. Currently used only by the sys-off restart mode, * @cmd: Command string. Currently used only by the sys-off restart mode,
* NULL otherwise. * NULL otherwise.
* @dev: Device of the sys-off handler. Only if known (devm_register_*),
* NULL otherwise.
*/ */
struct sys_off_data { struct sys_off_data {
int mode; int mode;
void *cb_data; void *cb_data;
const char *cmd; const char *cmd;
struct device *dev;
}; };
struct sys_off_handler * struct sys_off_handler *
......
...@@ -55,6 +55,7 @@ struct sys_off_handler { ...@@ -55,6 +55,7 @@ struct sys_off_handler {
enum sys_off_mode mode; enum sys_off_mode mode;
bool blocking; bool blocking;
void *list; void *list;
struct device *dev;
}; };
/* /*
...@@ -324,6 +325,7 @@ static int sys_off_notify(struct notifier_block *nb, ...@@ -324,6 +325,7 @@ static int sys_off_notify(struct notifier_block *nb,
data.cb_data = handler->cb_data; data.cb_data = handler->cb_data;
data.mode = mode; data.mode = mode;
data.cmd = cmd; data.cmd = cmd;
data.dev = handler->dev;
return handler->sys_off_cb(&data); return handler->sys_off_cb(&data);
} }
...@@ -511,6 +513,7 @@ int devm_register_sys_off_handler(struct device *dev, ...@@ -511,6 +513,7 @@ int devm_register_sys_off_handler(struct device *dev,
handler = register_sys_off_handler(mode, priority, callback, cb_data); handler = register_sys_off_handler(mode, priority, callback, cb_data);
if (IS_ERR(handler)) if (IS_ERR(handler))
return PTR_ERR(handler); return PTR_ERR(handler);
handler->dev = dev;
return devm_add_action_or_reset(dev, devm_unregister_sys_off_handler, return devm_add_action_or_reset(dev, devm_unregister_sys_off_handler,
handler); handler);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment