From patchwork Mon Sep 5 16:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12966306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DED38ECAAD3 for ; Mon, 5 Sep 2022 16:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiIEQPJ (ORCPT ); Mon, 5 Sep 2022 12:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbiIEQPJ (ORCPT ); Mon, 5 Sep 2022 12:15:09 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432F91EC78; Mon, 5 Sep 2022 09:15:06 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso4080490pjd.4; Mon, 05 Sep 2022 09:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=GSz8QcnAF3KVd+oYRHdCdNqyO/6sC9qiC/oawbq6vX0=; b=TZlspr0pqC2LgAzFjuWe4hTt2KUJ4JXaZhVc97pt14ru5A7+owVex9/HAE7cIKz5Jz UMOivxgzlnQ+1ldJyqEJ2EZCqbC15900NmBQKqE4mor/fPRtzZ4t4vGm4PsRQVb9mD27 nPpg6eqkGVGT4kJX0t6Bo4JKFoWRFzmHN3naf7v5LIDEKD83UVYJP/e70P27NYnf5UpU gfqp4uyhs8Y6EPUSYszMQxSRmxVyurTGqqEeX83PVQFSU13neePKB3MjxYFuOix57JD+ aIbbA8cMHFT7NUE9Qo0nioOQD4G/Qp5THv624d9YDb76JfcRT0uPwt+Q5FJH/b9ZicLM +Bwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=GSz8QcnAF3KVd+oYRHdCdNqyO/6sC9qiC/oawbq6vX0=; b=syKEUbrKZsbnWAnpwMuAqlRnNJwCBW8JyGFSOGWapqU5iOZB5iXTSQH4vrLlU9KYHu jK1cAuW+huyzjWc5N145+Sn1mLLWF7Ww0IkPyERBGIKerw2NTShGuKcd6tHmMqMZe3k9 sUfMGg9H2NhlpwcPCq5tdLFcOi1O8C4UMNcsL0jGXurugtrongsvC3d2zBGQps6URHge os9TxHBGTbP0AfTOmoXwHj/Ma5t+TskJpWW04NxM/dKSCrxp76PHSeHWBB931LrYrQur PlHUKPEtKFq2TAvJrsfL6jpg6BksLjrzJfgTzw+vQQLJhUvWvTlfAMXDFHnzXAwQhxuj 8f5w== X-Gm-Message-State: ACgBeo1NEJrF568ZIEDk2SOoG5VENXejeRW8ANDfE4dniqebwj6/bG3S v+B0RF3RqAMN+ilsyCzEnNR5SLPPl8A= X-Google-Smtp-Source: AA6agR6pRp+Oljy6r7Avsn/FovLn/AmM5J1ds+hM+Vy7Ewdg2DvGlA3YA4fF/rJfyRId1YnjOJ0oyQ== X-Received: by 2002:a17:902:f787:b0:172:f321:2fd1 with SMTP id q7-20020a170902f78700b00172f3212fd1mr48939853pln.121.1662394505225; Mon, 05 Sep 2022 09:15:05 -0700 (PDT) Received: from 7YHHR73.igp.broadcom.net (ip72-194-116-95.oc.oc.cox.net. [72.194.116.95]) by smtp.gmail.com with ESMTPSA id t12-20020a170902e84c00b0016d5b7fb02esm7817622plg.60.2022.09.05.09.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 09:15:04 -0700 (PDT) From: Florian Fainelli To: linux-clk@vger.kernel.org Cc: Florian Fainelli , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Michael Turquette , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Allison Randal , Thomas Gleixner , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM IPROC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] clk: iproc: Do not rely on node name for correct PLL setup Date: Mon, 5 Sep 2022 09:15:03 -0700 Message-Id: <20220905161504.1526-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block description") a warning from clk-iproc-pll.c was generated due to a duplicate PLL name as well as the console stopped working. Upon closer inspection it became clear that iproc_pll_clk_setup() used the Device Tree node unit name as an unique identifier as well as a parent name to parent all clocks under the PLL. BCM5301X was the first platform on which that got noticed because of the DT node unit name renaming but the same assumptions hold true for any user of the iproc_pll_clk_setup() function. The first 'clock-output-names' property is always guaranteed to be unique as well as providing the actual desired PLL clock name, so we utilize that to register the PLL and as a parent name of all children clock. Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support") Signed-off-by: Florian Fainelli Acked-by: Rafał Miłecki --- Changes in v2: - added Acked-by - remove empty newline drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c index 1a098db12062..680f9d8d357c 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -726,6 +726,7 @@ void iproc_pll_clk_setup(struct device_node *node, const char *parent_name; struct iproc_clk *iclk_array; struct clk_hw_onecell_data *clk_data; + const char *clk_name; if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) return; @@ -773,7 +774,12 @@ void iproc_pll_clk_setup(struct device_node *node, iclk = &iclk_array[0]; iclk->pll = pll; - init.name = node->name; + ret = of_property_read_string_index(node, "clock-output-names", + 0, &clk_name); + if (WARN_ON(ret)) + goto err_pll_register; + + init.name = clk_name; init.ops = &iproc_pll_ops; init.flags = 0; parent_name = of_clk_get_parent_name(node, 0); @@ -793,13 +799,11 @@ void iproc_pll_clk_setup(struct device_node *node, goto err_pll_register; clk_data->hws[0] = &iclk->hw; + parent_name = clk_name; /* now initialize and register all leaf clocks */ for (i = 1; i < num_clks; i++) { - const char *clk_name; - memset(&init, 0, sizeof(init)); - parent_name = node->name; ret = of_property_read_string_index(node, "clock-output-names", i, &clk_name);