[PATCH v2 2/2] mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of looking for gceX aliases across the entire devicetree and
getting clocks by then reading these nodes with of_clk_get(), since
the maximum number of GCEs is two, it is more convenient to simply
assign two clocks to both of the GCE nodes.

Luckily, as of now, there is no devicetree for any multi-gce device
upstream: remove the aforementioned mechanism in favor of getting
both "gce0" and "gce1" clocks with devm_clk_bulk_get() instead.

Compatibility with single-gce mailboxes is retained by assigning
only one id to the clk_bulk_data, as the number of clocks to handle
is already signaled by the "gce_num" member of struct cmdq.

While at it, also beautify the clocks get failure message.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 32 +++++++-----------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 2578e5aaa935..89a0fdde730c 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -527,11 +527,6 @@ static int cmdq_probe(struct platform_device *pdev)
 	struct cmdq *cmdq;
 	int err, i;
 	struct gce_plat *plat_data;
-	struct device_node *phandle = dev->of_node;
-	struct device_node *node;
-	int alias_id = 0;
-	static const char * const clk_name = "gce";
-	static const char * const clk_names[] = { "gce0", "gce1" };
 
 	cmdq = devm_kzalloc(dev, sizeof(*cmdq), GFP_KERNEL);
 	if (!cmdq)
@@ -567,29 +562,16 @@ static int cmdq_probe(struct platform_device *pdev)
 		dev, cmdq->base, cmdq->irq);
 
 	if (cmdq->gce_num > 1) {
-		for_each_child_of_node(phandle->parent, node) {
-			alias_id = of_alias_get_id(node, clk_name);
-			if (alias_id >= 0 && alias_id < cmdq->gce_num) {
-				cmdq->clocks[alias_id].id = clk_names[alias_id];
-				cmdq->clocks[alias_id].clk = of_clk_get(node, 0);
-				if (IS_ERR(cmdq->clocks[alias_id].clk)) {
-					of_node_put(node);
-					return dev_err_probe(dev,
-							     PTR_ERR(cmdq->clocks[alias_id].clk),
-							     "failed to get gce clk: %d\n",
-							     alias_id);
-				}
-			}
-		}
+		cmdq->clocks[0].id = "gce0";
+		cmdq->clocks[1].id = "gce1";
 	} else {
-		cmdq->clocks[alias_id].id = clk_name;
-		cmdq->clocks[alias_id].clk = devm_clk_get(&pdev->dev, clk_name);
-		if (IS_ERR(cmdq->clocks[alias_id].clk)) {
-			return dev_err_probe(dev, PTR_ERR(cmdq->clocks[alias_id].clk),
-					     "failed to get gce clk\n");
-		}
+		cmdq->clocks[0].id = "gce";
 	}
 
+	err = devm_clk_bulk_get(&pdev->dev, cmdq->gce_num, cmdq->clocks);
+	if (err)
+		return dev_err_probe(dev, err, "Failed to get GCE clocks\n");
+
 	cmdq->mbox.dev = dev;
 	cmdq->mbox.chans = devm_kcalloc(dev, cmdq->thread_nr,
 					sizeof(*cmdq->mbox.chans), GFP_KERNEL);
-- 
2.35.1




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux