From: Matthias Brugger <matthias.bgg@gmail.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v1 1/3] soc: mediatek: mtk-cmdq: Move mask build and append to function
Date: Wed, 2 Oct 2024 14:33:36 +0200 [thread overview]
Message-ID: <c91c920b-ecc9-431e-9e35-36f243fb9cd1@gmail.com> (raw)
In-Reply-To: <20240918100620.103536-2-angelogioacchino.delregno@collabora.com>
On 18/09/2024 12:06, AngeloGioacchino Del Regno wrote:
> Move the CMDQ_CODE_MASK packet build and append logic to a new
> cmdq_pkt_mask() function; this reduces code duplication by 4x.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
> drivers/soc/mediatek/mtk-cmdq-helper.c | 31 ++++++++++++--------------
> 1 file changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
> index a8fccedba83f..620c371fd1fc 100644
> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c
> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
> @@ -180,6 +180,15 @@ static int cmdq_pkt_append_command(struct cmdq_pkt *pkt,
> return 0;
> }
>
> +static int cmdq_pkt_mask(struct cmdq_pkt *pkt, u32 mask)
> +{
> + struct cmdq_instruction inst = {
> + .op = CMDQ_CODE_MASK,
> + .mask = ~mask
> + };
> + return cmdq_pkt_append_command(pkt, inst);
> +}
> +
> int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value)
> {
> struct cmdq_instruction inst;
> @@ -196,14 +205,11 @@ EXPORT_SYMBOL(cmdq_pkt_write);
> int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
> u16 offset, u32 value, u32 mask)
> {
> - struct cmdq_instruction inst = { {0} };
> u16 offset_mask = offset;
> int err;
>
> if (mask != 0xffffffff) {
> - inst.op = CMDQ_CODE_MASK;
> - inst.mask = ~mask;
> - err = cmdq_pkt_append_command(pkt, inst);
> + err = cmdq_pkt_mask(pkt, mask);
> if (err < 0)
> return err;
>
> @@ -251,9 +257,7 @@ int cmdq_pkt_write_s_mask(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
> struct cmdq_instruction inst = {};
> int err;
>
> - inst.op = CMDQ_CODE_MASK;
> - inst.mask = ~mask;
> - err = cmdq_pkt_append_command(pkt, inst);
> + err = cmdq_pkt_mask(pkt, mask);
> if (err < 0)
> return err;
>
> @@ -288,9 +292,7 @@ int cmdq_pkt_write_s_mask_value(struct cmdq_pkt *pkt, u8 high_addr_reg_idx,
> struct cmdq_instruction inst = {};
> int err;
>
> - inst.op = CMDQ_CODE_MASK;
> - inst.mask = ~mask;
> - err = cmdq_pkt_append_command(pkt, inst);
> + err = cmdq_pkt_mask(pkt, mask);
> if (err < 0)
> return err;
>
> @@ -409,12 +411,9 @@ EXPORT_SYMBOL(cmdq_pkt_poll);
> int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
> u16 offset, u32 value, u32 mask)
> {
> - struct cmdq_instruction inst = { {0} };
> int err;
>
> - inst.op = CMDQ_CODE_MASK;
> - inst.mask = ~mask;
> - err = cmdq_pkt_append_command(pkt, inst);
> + err = cmdq_pkt_mask(pkt, mask);
> if (err < 0)
> return err;
>
> @@ -436,9 +435,7 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas
> * which enables use_mask bit.
> */
> if (mask != GENMASK(31, 0)) {
> - inst.op = CMDQ_CODE_MASK;
> - inst.mask = ~mask;
> - ret = cmdq_pkt_append_command(pkt, inst);
> + ret = cmdq_pkt_mask(pkt, mask);
> if (ret < 0)
> return ret;
> use_mask = CMDQ_POLL_ENABLE_MASK;
next prev parent reply other threads:[~2024-10-02 12:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-18 10:06 [PATCH v1 0/3] soc: mediatek: mtk-cmdq-helper: Various cleanups AngeloGioacchino Del Regno
2024-09-18 10:06 ` [PATCH v1 1/3] soc: mediatek: mtk-cmdq: Move mask build and append to function AngeloGioacchino Del Regno
2024-10-02 12:33 ` Matthias Brugger [this message]
2024-09-18 10:06 ` [PATCH v1 2/3] soc: mediatek: mtk-cmdq: Mark very unlikely branches as such AngeloGioacchino Del Regno
2024-10-02 12:41 ` Matthias Brugger
2024-10-02 12:43 ` AngeloGioacchino Del Regno
2024-10-02 12:58 ` Matthias Brugger
2024-10-02 13:02 ` AngeloGioacchino Del Regno
2024-09-18 10:06 ` [PATCH v1 3/3] soc: mediatek: mtk-cmdq: Move cmdq_instruction init to declaration AngeloGioacchino Del Regno
2024-09-19 22:43 ` kernel test robot
2024-10-02 12:52 ` Matthias Brugger
2024-10-02 9:08 ` [PATCH v1 0/3] soc: mediatek: mtk-cmdq-helper: Various cleanups AngeloGioacchino Del Regno
2024-10-02 13:00 ` Matthias Brugger
2024-10-03 8:08 ` AngeloGioacchino Del Regno
2024-10-07 14:33 ` Matthias Brugger
2024-10-07 14:36 ` AngeloGioacchino Del Regno
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=c91c920b-ecc9-431e-9e35-36f243fb9cd1@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).