From: Marek Vasut <marex@denx.de>
To: "Alice Guo (OSS)" <alice.guo@oss.nxp.com>,
"Tom Rini" <trini@konsulko.com>,
"Lukasz Majewski" <lukma@denx.de>,
"Sean Anderson" <seanga2@gmail.com>,
"Simon Glass" <sjg@chromium.org>,
"Stefano Babic" <sbabic@denx.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
"Alper Nebi Yasak" <alpernebiyasak@gmail.com>,
"Alice Guo" <alice.guo@nxp.com>,
"Lothar Waßmann" <LW@KARO-electronics.de>
Cc: u-boot@lists.denx.de, Ye Li <ye.li@nxp.com>
Subject: Re: [PATCH v8 09/19] scmi_protocols: update struct scmi_base_discover_list_protocols_out
Date: Sat, 22 Mar 2025 03:10:25 +0100 [thread overview]
Message-ID: <559a8550-5f36-46bb-a593-bab3c47c4758@denx.de> (raw)
In-Reply-To: <20250321-imx95-v1-9-f2c8ba815f89@oss.nxp.com>
On 3/21/25 8:15 AM, Alice Guo (OSS) wrote:
[...]
> @@ -276,22 +276,31 @@ static int scmi_base_discover_list_protocols_int(struct udevice *dev,
> if (ret)
> return ret;
>
This math here could really use a code comment to explain what is going
on here.
I assume there is 1 byte per protocol in the struct
scmi_base_discover_list_protocols_out { .protocols[] } member, right ?
If so, why not simply change u32 protocols[] to u8 protocols[] and use some:
out_size = sizeof(*out) + roundup(num_protocols, sizeof(u32))
?
That might make the whole parsing using for (i = 0; i <
out->num_protocols; i++, cur++) simpler too ?
> + out_size = sizeof(*out) + sizeof(u32) * (1 + (num_protocols - 1) / 4);
> + out = calloc(1, out_size);
> + if (!out)
> + return -ENOMEM;
> + msg.out_msg = (u8 *)out;
> + msg.out_msg_sz = out_size;
> +
> buf = calloc(sizeof(u8), num_protocols);
> - if (!buf)
> + if (!buf) {
> + free(out);
> return -ENOMEM;
> + }
>
> cur = 0;
> do {
> ret = devm_scmi_process_msg(dev, &msg);
> if (ret)
> goto err;
> - if (out.status) {
> - ret = scmi_to_linux_errno(out.status);
> + if (out->status) {
> + ret = scmi_to_linux_errno(out->status);
> goto err;
> }
>
> - for (i = 0; i < out.num_protocols; i++, cur++)
> - buf[cur] = out.protocols[i / 4] >> ((i % 4) * 8);
> + for (i = 0; i < out->num_protocols; i++, cur++)
> + buf[cur] = out->protocols[i / 4] >> ((i % 4) * 8);
> } while (cur < num_protocols);
>
> *protocols = buf;
> @@ -299,6 +308,7 @@ static int scmi_base_discover_list_protocols_int(struct udevice *dev,
> return num_protocols;
> err:
> free(buf);
> + free(out);
>
> return ret;
> }
> diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
> index 519b906b4ce..9046de7e3e7 100644
> --- a/include/scmi_protocols.h
> +++ b/include/scmi_protocols.h
> @@ -145,7 +145,7 @@ struct scmi_base_discover_impl_version_out {
> struct scmi_base_discover_list_protocols_out {
> s32 status;
> u32 num_protocols;
> - u32 protocols[3];
> + u32 protocols[];
> };
[...]
next prev parent reply other threads:[~2025-03-22 2:51 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 7:15 [PATCH v8 00/19] imx: add i.MX95 support Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 01/19] firmware: scmi: smt: Interrupt communication enable Alice Guo (OSS)
2025-03-22 0:38 ` Marek Vasut
2025-04-01 8:02 ` 回复: " Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 02/19] pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol Alice Guo (OSS)
2025-03-22 0:46 ` Marek Vasut
2025-03-25 8:06 ` Peng Fan
2025-03-26 1:24 ` Marek Vasut
2025-03-26 1:52 ` Peng Fan
2025-03-26 3:00 ` Marek Vasut
2025-03-26 6:42 ` Peng Fan
2025-03-27 13:18 ` Marek Vasut
2025-04-01 10:57 ` 回复: " Alice Guo (OSS)
2025-04-01 12:53 ` Marek Vasut
2025-04-01 13:22 ` 回复: " Alice Guo (OSS)
2025-04-01 13:27 ` Fabio Estevam
2025-04-01 8:17 ` Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 03/19] firmware: scmi_agent: add SCMI pin control protocol support Alice Guo (OSS)
2025-03-22 1:55 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 04/19] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data Alice Guo (OSS)
2025-03-22 1:55 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 05/19] scmi_protocols: add SCMI Performance domain management protocol message IDs Alice Guo (OSS)
2025-03-22 1:55 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 06/19] clk: scmi: add the command CLOCK_PARENT_SET Alice Guo (OSS)
2025-03-22 1:57 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 07/19] clk: scmi: check the clock state/parent/rate control permissions Alice Guo (OSS)
2025-03-22 2:02 ` Marek Vasut
2025-03-28 10:26 ` 回复: " Alice Guo (OSS)
2025-03-30 21:05 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 08/19] sandbox: add SCMI clock control permissions to sandbox Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 09/19] scmi_protocols: update struct scmi_base_discover_list_protocols_out Alice Guo (OSS)
2025-03-22 2:10 ` Marek Vasut [this message]
2025-03-21 7:15 ` [PATCH v8 10/19] imx9: scmi: add i.MX95 SoC and clock related code Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 11/19] spl: imx: use trampoline buffer to load images to secure region Alice Guo (OSS)
2025-03-22 2:14 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 12/19] imx9: add i.MX95 Kconfig and Makefile Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 13/19] imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95 Alice Guo (OSS)
2025-03-22 2:15 ` Marek Vasut
2025-03-21 7:15 ` [PATCH v8 14/19] binman: add a new entry type for packing DDR PHY firmware images Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 15/19] tools: imx8image: add i.MX95 support Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 16/19] imx: container: add V2X container support for i.MX95 Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 17/19] doc: imx: add document for i.MX95 Image Container Format Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 18/19] imx95_evk: add i.MX95 19x19 EVK board basic support Alice Guo (OSS)
2025-03-21 7:15 ` [PATCH v8 19/19] Makefile: add some files to CLEAN_FILES Alice Guo (OSS)
2025-03-22 2:20 ` [PATCH v8 00/19] imx: add i.MX95 support Marek Vasut
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=559a8550-5f36-46bb-a593-bab3c47c4758@denx.de \
--to=marex@denx.de \
--cc=LW@KARO-electronics.de \
--cc=alice.guo@nxp.com \
--cc=alice.guo@oss.nxp.com \
--cc=alpernebiyasak@gmail.com \
--cc=festevam@gmail.com \
--cc=lukma@denx.de \
--cc=sbabic@denx.de \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
--cc=ye.li@nxp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.