diff mbox series

[v2,1/2] clk: qcom: rpmh: skip undefined clocks when registering

Message ID 1578305923-29125-2-git-send-email-tdas@codeaurora.org (mailing list archive)
State Accepted, archived
Headers show
Series Add support for IPA clock for SC7180 | expand

Commit Message

Taniya Das Jan. 6, 2020, 10:18 a.m. UTC
When iterating over a platform's available clocks in clk_rpmh_probe(),
check for undefined (null) entries in the clocks array.  Not all
clock indexes necessarily have clocks defined.

Signed-off-by: Taniya Das <tdas@codeaurora.org>
---
 drivers/clk/qcom/clk-rpmh.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.

Comments

kernel test robot Jan. 6, 2020, 3:05 p.m. UTC | #1
Hi Taniya,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on v5.5-rc5 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Taniya-Das/Add-support-for-IPA-clock-for-SC7180/20200106-201629
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/clk//qcom/clk-rpmh.c: In function 'clk_rpmh_probe':
>> drivers/clk//qcom/clk-rpmh.c:441:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
      const char *name = hw_clks[i]->init->name;
      ^~~~~

vim +441 drivers/clk//qcom/clk-rpmh.c

   419	
   420	static int clk_rpmh_probe(struct platform_device *pdev)
   421	{
   422		struct clk_hw **hw_clks;
   423		struct clk_rpmh *rpmh_clk;
   424		const struct clk_rpmh_desc *desc;
   425		int ret, i;
   426	
   427		desc = of_device_get_match_data(&pdev->dev);
   428		if (!desc)
   429			return -ENODEV;
   430	
   431		hw_clks = desc->clks;
   432	
   433		for (i = 0; i < desc->num_clks; i++) {
   434			u32 res_addr;
   435			size_t aux_data_len;
   436			const struct bcm_db *data;
   437	
   438			if (!hw_clks[i])
   439				continue;
   440	
 > 441			const char *name = hw_clks[i]->init->name;
   442	
   443			rpmh_clk = to_clk_rpmh(hw_clks[i]);
   444			res_addr = cmd_db_read_addr(rpmh_clk->res_name);
   445			if (!res_addr) {
   446				dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
   447					rpmh_clk->res_name);
   448				return -ENODEV;
   449			}
   450	
   451			data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
   452			if (IS_ERR(data)) {
   453				ret = PTR_ERR(data);
   454				dev_err(&pdev->dev,
   455					"error reading RPMh aux data for %s (%d)\n",
   456					rpmh_clk->res_name, ret);
   457				return ret;
   458			}
   459	
   460			/* Convert unit from Khz to Hz */
   461			if (aux_data_len == sizeof(*data))
   462				rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
   463	
   464			rpmh_clk->res_addr += res_addr;
   465			rpmh_clk->dev = &pdev->dev;
   466	
   467			ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
   468			if (ret) {
   469				dev_err(&pdev->dev, "failed to register %s\n", name);
   470				return ret;
   471			}
   472		}
   473	
   474		/* typecast to silence compiler warning */
   475		ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_rpmh_hw_get,
   476						  (void *)desc);
   477		if (ret) {
   478			dev_err(&pdev->dev, "Failed to add clock provider\n");
   479			return ret;
   480		}
   481	
   482		dev_dbg(&pdev->dev, "Registered RPMh clocks\n");
   483	
   484		return 0;
   485	}
   486	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Stephen Boyd Jan. 6, 2020, 4:54 p.m. UTC | #2
Quoting Taniya Das (2020-01-06 02:18:42)
> When iterating over a platform's available clocks in clk_rpmh_probe(),
> check for undefined (null) entries in the clocks array.  Not all
> clock indexes necessarily have clocks defined.
> 
> Signed-off-by: Taniya Das <tdas@codeaurora.org>
> ---

Applied to clk-next + added the fix for type declaration.
diff mbox series

Patch

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index 7ed313a..075cc43 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -431,11 +431,15 @@  static int clk_rpmh_probe(struct platform_device *pdev)
 	hw_clks = desc->clks;

 	for (i = 0; i < desc->num_clks; i++) {
-		const char *name = hw_clks[i]->init->name;
 		u32 res_addr;
 		size_t aux_data_len;
 		const struct bcm_db *data;

+		if (!hw_clks[i])
+			continue;
+
+		const char *name = hw_clks[i]->init->name;
+
 		rpmh_clk = to_clk_rpmh(hw_clks[i]);
 		res_addr = cmd_db_read_addr(rpmh_clk->res_name);
 		if (!res_addr) {