Skip to content

Commit aa1609f

Browse files
AngeloGioacchino Del RegnoJassi Brar
authored andcommitted
mailbox: mtk-cmdq: Dynamically allocate clk_bulk_data structure
Now that the clock probing code uses devm_kasprintf(), there is no more restriction on the number of GCEs: dynamically allocate the clk_bulk_data clocks array to improve flexibility and also to get a slight memory saving on platforms featuring only one CMDQ mailbox (and consequently only one Global Command Engine). Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 0af932c commit aa1609f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/mailbox/mtk-cmdq-mailbox.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#define CMDQ_OP_CODE_MASK (0xff << CMDQ_OP_CODE_SHIFT)
2424
#define CMDQ_NUM_CMD(t) (t->cmd_buf_size / CMDQ_INST_SIZE)
25-
#define CMDQ_GCE_NUM_MAX (2)
2625

2726
#define CMDQ_CURR_IRQ_STATUS 0x10
2827
#define CMDQ_SYNC_TOKEN_UPDATE 0x68
@@ -81,7 +80,7 @@ struct cmdq {
8180
u32 irq_mask;
8281
const struct gce_plat *pdata;
8382
struct cmdq_thread *thread;
84-
struct clk_bulk_data clocks[CMDQ_GCE_NUM_MAX];
83+
struct clk_bulk_data *clocks;
8584
bool suspended;
8685
};
8786

@@ -584,6 +583,11 @@ static int cmdq_get_clocks(struct device *dev, struct cmdq *cmdq)
584583
struct device_node *node, *parent = dev->of_node->parent;
585584
struct clk_bulk_data *clks;
586585

586+
cmdq->clocks = devm_kcalloc(dev, cmdq->pdata->gce_num,
587+
sizeof(cmdq->clocks), GFP_KERNEL);
588+
if (!cmdq->clocks)
589+
return -ENOMEM;
590+
587591
if (cmdq->pdata->gce_num == 1) {
588592
clks = &cmdq->clocks[0];
589593

0 commit comments

Comments
 (0)