From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Tudor Ambarus <tudor.ambarus@linaro.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Lee Jones <lee@kernel.org>
Cc: "Alim Akhtar" <alim.akhtar@samsung.com>,
"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
"Chanwoo Choi" <cw00.choi@samsung.com>,
"André Draszik" <andre.draszik@linaro.org>,
linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
peter.griffin@linaro.org, andre.draszik@linaro.org,
jyescas@google.com, kernel-team@android.com
Subject: [PATCH 2/6] firmware: samsung: acpm: Annotate rx_data->cmd with __counted_by_ptr
Date: Wed, 06 May 2026 11:39:04 +0000 [thread overview]
Message-ID: <20260506-acpm-tmu-helpers-v1-2-a9cd5daf8355@linaro.org> (raw)
In-Reply-To: <20260506-acpm-tmu-helpers-v1-0-a9cd5daf8355@linaro.org>
Rename the `n_cmd` member of `struct acpm_rx_data` to `cmdcnt` to
maintain consistent nomenclature across the driver (aligning with
`txcnt`, `rxcnt`, and transfer helpers).
With the member renamed, annotate the dynamically allocated `cmd`
pointer with the `__counted_by_ptr(cmdcnt)` macro to improve runtime
bounds checking.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/firmware/samsung/exynos-acpm.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/samsung/exynos-acpm.c b/drivers/firmware/samsung/exynos-acpm.c
index 88a06842753d..fac88c427d2a 100644
--- a/drivers/firmware/samsung/exynos-acpm.c
+++ b/drivers/firmware/samsung/exynos-acpm.c
@@ -105,14 +105,14 @@ struct acpm_queue {
* struct acpm_rx_data - RX queue data.
*
* @cmd: pointer to where the data shall be saved.
- * @n_cmd: number of 32-bit commands.
+ * @cmdcnt: allocated capacity of the @cmd buffer in 32-bit words.
* @rxcnt: expected length of the response in 32-bit words.
* @completed: flag indicating if the firmware response has been fully
* processed.
*/
struct acpm_rx_data {
- u32 *cmd;
- size_t n_cmd;
+ u32 *cmd __counted_by_ptr(cmdcnt);
+ size_t cmdcnt;
size_t rxcnt;
bool completed;
};
@@ -432,7 +432,7 @@ static int acpm_prepare_xfer(struct acpm_chan *achan,
/* Clear data for upcoming responses */
rx_data = &achan->rx_data[bit];
rx_data->completed = false;
- memset(rx_data->cmd, 0, sizeof(*rx_data->cmd) * rx_data->n_cmd);
+ memset(rx_data->cmd, 0, sizeof(*rx_data->cmd) * rx_data->cmdcnt);
/* zero means no response expected */
rx_data->rxcnt = xfer->rxcnt;
@@ -584,19 +584,19 @@ static int acpm_achan_alloc_cmds(struct acpm_chan *achan)
{
struct device *dev = achan->acpm->dev;
struct acpm_rx_data *rx_data;
- size_t cmd_size, n_cmd;
+ size_t cmd_size, cmdcnt;
int i;
if (achan->mlen == 0)
return 0;
cmd_size = sizeof(*(achan->rx_data[0].cmd));
- n_cmd = DIV_ROUND_UP_ULL(achan->mlen, cmd_size);
+ cmdcnt = DIV_ROUND_UP_ULL(achan->mlen, cmd_size);
for (i = 0; i < ACPM_SEQNUM_MAX; i++) {
rx_data = &achan->rx_data[i];
- rx_data->n_cmd = n_cmd;
- rx_data->cmd = devm_kcalloc(dev, n_cmd, cmd_size, GFP_KERNEL);
+ rx_data->cmdcnt = cmdcnt;
+ rx_data->cmd = devm_kcalloc(dev, cmdcnt, cmd_size, GFP_KERNEL);
if (!rx_data->cmd)
return -ENOMEM;
}
--
2.54.0.545.g6539524ca2-goog
next prev parent reply other threads:[~2026-05-06 12:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 11:39 [PATCH 0/6] firmware: samsung: acpm: TMU support and cleanups Tudor Ambarus
2026-05-06 11:39 ` [PATCH 1/6] firmware: samsung: acpm: Consolidate transfer initialization helper Tudor Ambarus
2026-05-08 21:06 ` Peter Griffin
2026-05-06 11:39 ` Tudor Ambarus [this message]
2026-05-08 21:15 ` [PATCH 2/6] firmware: samsung: acpm: Annotate rx_data->cmd with __counted_by_ptr Peter Griffin
2026-05-06 11:39 ` [PATCH 3/6] firmware: samsung: acpm: Drop redundant _ops suffix in acpm_ops members Tudor Ambarus
2026-05-08 21:23 ` Peter Griffin
2026-05-06 11:39 ` [PATCH 4/6] firmware: samsung: acpm: Make acpm_ops const and access via pointer Tudor Ambarus
2026-05-08 21:27 ` Peter Griffin
2026-05-06 11:39 ` [PATCH 5/6] firmware: samsung: acpm: Add TMU protocol support Tudor Ambarus
2026-05-06 15:13 ` Alexey Klimov
2026-05-07 8:31 ` Tudor Ambarus
2026-05-08 21:47 ` Peter Griffin
2026-05-06 11:39 ` [PATCH 6/6] firmware: samsung: acpm: Add devm_acpm_get_by_phandle helper Tudor Ambarus
2026-05-08 21:36 ` Peter Griffin
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=20260506-acpm-tmu-helpers-v1-2-a9cd5daf8355@linaro.org \
--to=tudor.ambarus@linaro.org \
--cc=alim.akhtar@samsung.com \
--cc=andre.draszik@linaro.org \
--cc=cw00.choi@samsung.com \
--cc=jyescas@google.com \
--cc=kernel-team@android.com \
--cc=krzk@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=peter.griffin@linaro.org \
--cc=s.nawrocki@samsung.com \
--cc=sboyd@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