From: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
To: Sudeep Holla <sudeep.holla@kernel.org>,
Cristian Marussi <cristian.marussi@arm.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>
Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Subject: [PATCH 3/4] firmware: arm_scmi: Use container_of_const() on scmi_handle
Date: Tue, 24 Feb 2026 11:43:41 +0100 [thread overview]
Message-ID: <20260224-handle-not-const-v1-3-90bf93b53e27@oss.qualcomm.com> (raw)
In-Reply-To: <20260224-handle-not-const-v1-0-90bf93b53e27@oss.qualcomm.com>
Functions receiving pointer to const scmi_handle and are not modifying
data in containing struct, can switch to safer container_of_const()
which does not drop the const while casting. This improves readability
because makes the code more obvious.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
drivers/firmware/arm_scmi/driver.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 951711aa7d33..cc6cdb7017cf 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -174,6 +174,7 @@ struct scmi_info {
};
#define handle_to_scmi_info(h) container_of(h, struct scmi_info, handle)
+#define handle_to_scmi_info_const(h) container_of_const(h, struct scmi_info, handle)
#define tx_minfo_to_scmi_info(h) container_of(h, struct scmi_info, tx_minfo)
#define bus_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, bus_nb)
#define req_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, dev_req_nb)
@@ -450,7 +451,7 @@ void scmi_notification_instance_data_set(struct scmi_handle *handle,
void *scmi_notification_instance_data_get(const struct scmi_handle *handle)
{
- struct scmi_info *info = handle_to_scmi_info(handle);
+ const struct scmi_info *info = handle_to_scmi_info_const(handle);
/* Ensure protocols_private_data has been updated */
smp_rmb();
@@ -866,7 +867,7 @@ static void scmi_bad_message_trace(struct scmi_chan_info *cinfo, u32 msg_hdr,
enum scmi_bad_msg err)
{
char *tag;
- struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
+ const struct scmi_info *info = handle_to_scmi_info_const(cinfo->handle);
switch (MSG_XTRACT_TYPE(msg_hdr)) {
case MSG_TYPE_COMMAND:
@@ -1062,7 +1063,7 @@ static inline void scmi_xfer_command_release(struct scmi_info *info,
__scmi_xfer_put(&info->tx_minfo, xfer);
}
-static inline void scmi_clear_channel(struct scmi_info *info,
+static inline void scmi_clear_channel(const struct scmi_info *info,
struct scmi_chan_info *cinfo)
{
if (!cinfo->is_p2a) {
@@ -1240,7 +1241,7 @@ static bool scmi_xfer_done_no_timeout(struct scmi_chan_info *cinfo,
struct scmi_xfer *xfer, ktime_t stop,
bool *ooo)
{
- struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
+ const struct scmi_info *info = handle_to_scmi_info_const(cinfo->handle);
/*
* Poll also on xfer->done so that polling can be forcibly terminated
@@ -3459,7 +3460,7 @@ static struct dentry *scmi_debugfs_init(void)
int scmi_inflight_count(const struct scmi_handle *handle)
{
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
- struct scmi_info *info = handle_to_scmi_info(handle);
+ const struct scmi_info *info = handle_to_scmi_info_const(handle);
if (!info->dbg)
return 0;
--
2.51.0
next prev parent reply other threads:[~2026-02-24 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 10:43 [PATCH 0/4] firmware: arm_scmi: Drop fake 'const' " Krzysztof Kozlowski
2026-02-24 10:43 ` [PATCH 1/4] " Krzysztof Kozlowski
2026-02-24 10:43 ` [PATCH 2/4] firmware: arm_scmi: Drop fake 'const' on scmi_protocol_handle Krzysztof Kozlowski
2026-02-24 10:43 ` Krzysztof Kozlowski [this message]
2026-02-24 10:43 ` [PATCH 4/4] firmware: arm_scmi: Use container_of_const() on scmi_protocol_instance Krzysztof Kozlowski
2026-02-24 12:31 ` [PATCH 0/4] firmware: arm_scmi: Drop fake 'const' on scmi_handle Cristian Marussi
2026-02-25 11:42 ` Krzysztof Kozlowski
2026-02-26 13:55 ` Cristian Marussi
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=20260224-handle-not-const-v1-3-90bf93b53e27@oss.qualcomm.com \
--to=krzysztof.kozlowski@oss.qualcomm.com \
--cc=Frank.Li@nxp.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=sudeep.holla@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
all inboxes | Powered by JetHome®