From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Tinghan Shen <tinghan.shen@mediatek.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Mark Brown <broonie@kernel.org>, YC Hung <yc.hung@mediatek.com>,
Curtis Malainey <cujomalainey@chromium.org>,
Allen-KH Cheng <allen-kh.cheng@mediatek.com>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Project_Global_Chrome_Upstream_Group@mediatek.com
Subject: Re: [PATCH v2 2/3] firmware: mediatek: Use meaningful names for mbox
Date: Mon, 13 Jun 2022 14:37:19 +0200 [thread overview]
Message-ID: <d3f718fa-c773-4bc7-506b-d109bf72aa3b@collabora.com> (raw)
In-Reply-To: <20220609083101.24195-3-tinghan.shen@mediatek.com>
Il 09/06/22 10:31, Tinghan Shen ha scritto:
> Rename mbox according to action instead of 'mbox0' and 'mbox1'
>
> Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
> ---
> drivers/firmware/mtk-adsp-ipc.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/mtk-adsp-ipc.c b/drivers/firmware/mtk-adsp-ipc.c
> index cb255a99170c..3de94765d659 100644
> --- a/drivers/firmware/mtk-adsp-ipc.c
> +++ b/drivers/firmware/mtk-adsp-ipc.c
> @@ -83,7 +83,11 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
> - chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
> + if (i < MTK_ADSP_MBOX_NUM / 2)
> + chan_name = kasprintf(GFP_KERNEL, "rep");
> + else
> + chan_name = kasprintf(GFP_KERNEL, "req");
> +
> if (!chan_name) {
> ret = -ENOMEM;
> goto out;
At this point, just call them "reply" and "request", as that simply provides a
perfectly clear explanation.
Besides, I'm sorry but I really don't like this code, it's really too much
fragile and will have to be changed entirely if a third mbox is introduced.
I can suggest a cooler way:
static const char * const adsp_mbox_ch_names[MTK_ADSP_MBOX_NUM] = { "rep", "req" };
for (i = 0; i < ARRAY_SIZE(adsp_mbox_ch_names); i++) {
/* we can delete chan_name and also avoid a kfree if we do... */
.... code ....
adsp_chan->ch = mbox_request_channel_byname(cl, adsp_mbox_ch_names[i]);
... etc etc ...
}
Cheers,
Angelo
next prev parent reply other threads:[~2022-06-13 17:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 8:30 [PATCH v2 0/3] Add MT8186 ADSP dt-binding Tinghan Shen
2022-06-09 8:30 ` [PATCH v2 1/3] dt-bindings: dsp: mediatek: Use meaningful names for mbox Tinghan Shen
2022-06-13 12:41 ` AngeloGioacchino Del Regno
2022-06-15 17:30 ` Krzysztof Kozlowski
2022-06-09 8:31 ` [PATCH v2 2/3] firmware: " Tinghan Shen
2022-06-13 12:37 ` AngeloGioacchino Del Regno [this message]
2022-06-15 3:22 ` Tinghan Shen
2022-06-09 8:31 ` [PATCH v2 3/3] dt-bindings: dsp: mediatek: add mt8186 dsp document Tinghan Shen
2022-06-15 17:32 ` Krzysztof Kozlowski
2022-06-16 7:34 ` Tinghan Shen
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=d3f718fa-c773-4bc7-506b-d109bf72aa3b@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=allen-kh.cheng@mediatek.com \
--cc=broonie@kernel.org \
--cc=cujomalainey@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=tinghan.shen@mediatek.com \
--cc=yc.hung@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).