diff options
| author | Tudor Ambarus <tudor.ambarus@linaro.org> | 2026-05-15 12:32:26 +0300 |
|---|---|---|
| committer | Krzysztof Kozlowski <krzk@kernel.org> | 2026-05-29 17:02:20 +0300 |
| commit | 447f406568c153819d6bfce994e422db4e95bb6f (patch) | |
| tree | 55afa1f6f8b442eb080bbfe901f12ecaf24416b3 | |
| parent | d5cfe2a96d723b6962c5e38bc81cc9994347d326 (diff) | |
| download | linux-447f406568c153819d6bfce994e422db4e95bb6f.tar.xz | |
firmware: samsung: acpm: Annotate rx_data->cmd with __counted_by_ptr
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>
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://patch.msgid.link/20260515-acpm-tmu-helpers-v2-2-8ca011d5a965@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
| -rw-r--r-- | drivers/firmware/samsung/exynos-acpm.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/firmware/samsung/exynos-acpm.c b/drivers/firmware/samsung/exynos-acpm.c index ec0929882b74..69bb1008d1c0 100644 --- a/drivers/firmware/samsung/exynos-acpm.c +++ b/drivers/firmware/samsung/exynos-acpm.c @@ -104,14 +104,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; }; @@ -428,7 +428,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; @@ -580,19 +580,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; } |
