Skip to content

Commit db2d603

Browse files
benjamin-bara-skidatalag-linaro
authored andcommitted
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: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com> Link: https://lore.kernel.org/r/20230327-tegra-pmic-reboot-v7-3-18699d5dcd76@skidata.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent aa49c90 commit db2d603

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

include/linux/reboot.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,14 @@ enum sys_off_mode {
129129
* @cb_data: User's callback data.
130130
* @cmd: Command string. Currently used only by the sys-off restart mode,
131131
* NULL otherwise.
132+
* @dev: Device of the sys-off handler. Only if known (devm_register_*),
133+
* NULL otherwise.
132134
*/
133135
struct sys_off_data {
134136
int mode;
135137
void *cb_data;
136138
const char *cmd;
139+
struct device *dev;
137140
};
138141

139142
struct sys_off_handler *

kernel/reboot.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct sys_off_handler {
5555
enum sys_off_mode mode;
5656
bool blocking;
5757
void *list;
58+
struct device *dev;
5859
};
5960

6061
/*
@@ -324,6 +325,7 @@ static int sys_off_notify(struct notifier_block *nb,
324325
data.cb_data = handler->cb_data;
325326
data.mode = mode;
326327
data.cmd = cmd;
328+
data.dev = handler->dev;
327329

328330
return handler->sys_off_cb(&data);
329331
}
@@ -511,6 +513,7 @@ int devm_register_sys_off_handler(struct device *dev,
511513
handler = register_sys_off_handler(mode, priority, callback, cb_data);
512514
if (IS_ERR(handler))
513515
return PTR_ERR(handler);
516+
handler->dev = dev;
514517

515518
return devm_add_action_or_reset(dev, devm_unregister_sys_off_handler,
516519
handler);

0 commit comments

Comments
 (0)