From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Benjamin Bara <bbara93@gmail.com>, Wolfram Sang <wsa@kernel.org>,
Lee Jones <lee@kernel.org>,
rafael.j.wysocki@intel.com
Cc: peterz@infradead.org, jonathanh@nvidia.com,
richard.leitner@linux.dev, treding@nvidia.com,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-tegra@vger.kernel.org,
Benjamin Bara <benjamin.bara@skidata.com>
Subject: Re: [PATCH v6 3/5] kernel/reboot: add device to sys_off_handler
Date: Thu, 18 May 2023 14:39:26 +0300 [thread overview]
Message-ID: <2c8980d9-4ef9-d1d7-d93b-cac97837c80b@collabora.com> (raw)
In-Reply-To: <20230327-tegra-pmic-reboot-v6-3-af44a4cd82e9@skidata.com>
On 5/9/23 22:03, Benjamin Bara wrote:
> From: Benjamin Bara <benjamin.bara@skidata.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.
>
> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.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);
>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
next prev parent reply other threads:[~2023-05-18 11:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 19:02 [PATCH v6 0/5] mfd: tps6586x: register restart handler Benjamin Bara
2023-05-09 19:02 ` [PATCH v6 1/5] kernel/reboot: emergency_restart: set correct system_state Benjamin Bara
2023-05-18 11:34 ` Dmitry Osipenko
2023-06-15 0:06 ` Nishanth Menon
2023-06-15 13:21 ` Francesco Dolcini
2023-06-15 14:39 ` Nishanth Menon
2023-05-09 19:03 ` [PATCH v6 2/5] i2c: core: run atomic i2c xfer when !preemptible Benjamin Bara
2023-05-18 11:34 ` Dmitry Osipenko
2023-06-15 0:05 ` Nishanth Menon
2023-05-09 19:03 ` [PATCH v6 3/5] kernel/reboot: add device to sys_off_handler Benjamin Bara
2023-05-18 11:39 ` Dmitry Osipenko [this message]
2023-05-09 19:03 ` [PATCH v6 4/5] mfd: tps6586x: use devm-based power off handler Benjamin Bara
2023-05-18 9:43 ` Lee Jones
2023-05-18 11:15 ` Benjamin Bara
2023-05-18 11:40 ` Dmitry Osipenko
2023-05-09 19:03 ` [PATCH v6 5/5] mfd: tps6586x: register restart handler Benjamin Bara
2023-05-18 9:44 ` Lee Jones
2023-05-18 11:48 ` Dmitry Osipenko
2023-07-12 3:40 ` Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c8980d9-4ef9-d1d7-d93b-cac97837c80b@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=bbara93@gmail.com \
--cc=benjamin.bara@skidata.com \
--cc=jonathanh@nvidia.com \
--cc=lee@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=richard.leitner@linux.dev \
--cc=treding@nvidia.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox