diff mbox series

clk: qcom: common: use parent_hws in _qcom_cc_register_board_clk()

Message ID 20220620080117.1571807-1-dmitry.baryshkov@linaro.org
State New
Headers show
Series clk: qcom: common: use parent_hws in _qcom_cc_register_board_clk() | expand

Commit Message

Dmitry Baryshkov June 20, 2022, 8:01 a.m. UTC
Switch _qcom_cc_register_board_clk() to use parent_hws.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/clk/qcom/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Carpenter June 21, 2022, 6:45 a.m. UTC | #1
Hi Dmitry,

url:    https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/clk-qcom-common-use-parent_hws-in-_qcom_cc_register_board_clk/20220620-160242 
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git  clk-next
config: parisc-randconfig-m031-20220619 (https://download.01.org/0day-ci/archive/20220621/202206210257.lD0x1WPz-lkp@intel.com/config )
compiler: hppa-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/clk/qcom/common.c:172 _qcom_cc_register_board_clk() error: uninitialized symbol 'fixed'.

vim +/fixed +172 drivers/clk/qcom/common.c

ee15faffef1130 Stephen Boyd     2015-10-26  129  static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
ee15faffef1130 Stephen Boyd     2015-10-26  130  				       const char *name, unsigned long rate,
ee15faffef1130 Stephen Boyd     2015-10-26  131  				       bool add_factor)
ee15faffef1130 Stephen Boyd     2015-10-26  132  {
ee15faffef1130 Stephen Boyd     2015-10-26  133  	struct device_node *node = NULL;
ee15faffef1130 Stephen Boyd     2015-10-26  134  	struct device_node *clocks_node;
ee15faffef1130 Stephen Boyd     2015-10-26  135  	struct clk_fixed_factor *factor;
ee15faffef1130 Stephen Boyd     2015-10-26  136  	struct clk_fixed_rate *fixed;
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ee15faffef1130 Stephen Boyd     2015-10-26  137  	struct clk_init_data init_data = { };
120c1552839036 Stephen Boyd     2016-08-16  138  	int ret;
ee15faffef1130 Stephen Boyd     2015-10-26  139  
ee15faffef1130 Stephen Boyd     2015-10-26  140  	clocks_node = of_find_node_by_path("/clocks");
43a51019cc8ff1 Johan Hovold     2017-11-11  141  	if (clocks_node) {
43a51019cc8ff1 Johan Hovold     2017-11-11  142  		node = of_get_child_by_name(clocks_node, path);
43a51019cc8ff1 Johan Hovold     2017-11-11  143  		of_node_put(clocks_node);
43a51019cc8ff1 Johan Hovold     2017-11-11  144  	}
ee15faffef1130 Stephen Boyd     2015-10-26  145  
ee15faffef1130 Stephen Boyd     2015-10-26  146  	if (!node) {
ee15faffef1130 Stephen Boyd     2015-10-26  147  		fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
ee15faffef1130 Stephen Boyd     2015-10-26  148  		if (!fixed)
ee15faffef1130 Stephen Boyd     2015-10-26  149  			return -EINVAL;
ee15faffef1130 Stephen Boyd     2015-10-26  150  
ee15faffef1130 Stephen Boyd     2015-10-26  151  		fixed->fixed_rate = rate;
ee15faffef1130 Stephen Boyd     2015-10-26  152  		fixed->hw.init = &init_data;
ee15faffef1130 Stephen Boyd     2015-10-26  153  
ee15faffef1130 Stephen Boyd     2015-10-26  154  		init_data.name = path;
ee15faffef1130 Stephen Boyd     2015-10-26  155  		init_data.ops = &clk_fixed_rate_ops;
ee15faffef1130 Stephen Boyd     2015-10-26  156  
120c1552839036 Stephen Boyd     2016-08-16  157  		ret = devm_clk_hw_register(dev, &fixed->hw);
120c1552839036 Stephen Boyd     2016-08-16  158  		if (ret)
120c1552839036 Stephen Boyd     2016-08-16  159  			return ret;
ee15faffef1130 Stephen Boyd     2015-10-26  160  	}

"fixed" is not set on else path.

ee15faffef1130 Stephen Boyd     2015-10-26  161  	of_node_put(node);
ee15faffef1130 Stephen Boyd     2015-10-26  162  
ee15faffef1130 Stephen Boyd     2015-10-26  163  	if (add_factor) {
ee15faffef1130 Stephen Boyd     2015-10-26  164  		factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL);
ee15faffef1130 Stephen Boyd     2015-10-26  165  		if (!factor)
ee15faffef1130 Stephen Boyd     2015-10-26  166  			return -EINVAL;
ee15faffef1130 Stephen Boyd     2015-10-26  167  
ee15faffef1130 Stephen Boyd     2015-10-26  168  		factor->mult = factor->div = 1;
ee15faffef1130 Stephen Boyd     2015-10-26  169  		factor->hw.init = &init_data;
ee15faffef1130 Stephen Boyd     2015-10-26  170  
ee15faffef1130 Stephen Boyd     2015-10-26  171  		init_data.name = name;
daa853a735065a Dmitry Baryshkov 2022-06-20 @172  		init_data.parent_hws = (const struct clk_hw*[]){ &fixed->hw };
                                                                                                                  ^^^^^
Used here.  This would work if fixed were set to NULL at the start but
I kind of hate that it requires us to know that ->hw is the first member
of fixed struct.

ee15faffef1130 Stephen Boyd     2015-10-26  173  		init_data.num_parents = 1;
ee15faffef1130 Stephen Boyd     2015-10-26  174  		init_data.flags = 0;
ee15faffef1130 Stephen Boyd     2015-10-26  175  		init_data.ops = &clk_fixed_factor_ops;
ee15faffef1130 Stephen Boyd     2015-10-26  176  
120c1552839036 Stephen Boyd     2016-08-16  177  		ret = devm_clk_hw_register(dev, &factor->hw);
120c1552839036 Stephen Boyd     2016-08-16  178  		if (ret)
120c1552839036 Stephen Boyd     2016-08-16  179  			return ret;
ee15faffef1130 Stephen Boyd     2015-10-26  180  	}
ee15faffef1130 Stephen Boyd     2015-10-26  181  
ee15faffef1130 Stephen Boyd     2015-10-26  182  	return 0;
ee15faffef1130 Stephen Boyd     2015-10-26  183  }
Dmitry Baryshkov June 21, 2022, 6:54 a.m. UTC | #2
On Tue, 21 Jun 2022 at 09:46, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Hi Dmitry,
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/clk-qcom-common-use-parent_hws-in-_qcom_cc_register_board_clk/20220620-160242
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git  clk-next
> config: parisc-randconfig-m031-20220619 (https://download.01.org/0day-ci/archive/20220621/202206210257.lD0x1WPz-lkp@intel.com/config )
> compiler: hppa-linux-gcc (GCC) 11.3.0
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> smatch warnings:
> drivers/clk/qcom/common.c:172 _qcom_cc_register_board_clk() error: uninitialized symbol 'fixed'.
>
> vim +/fixed +172 drivers/clk/qcom/common.c
>
> ee15faffef1130 Stephen Boyd     2015-10-26  129  static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
> ee15faffef1130 Stephen Boyd     2015-10-26  130                                        const char *name, unsigned long rate,
> ee15faffef1130 Stephen Boyd     2015-10-26  131                                        bool add_factor)
> ee15faffef1130 Stephen Boyd     2015-10-26  132  {
> ee15faffef1130 Stephen Boyd     2015-10-26  133         struct device_node *node = NULL;
> ee15faffef1130 Stephen Boyd     2015-10-26  134         struct device_node *clocks_node;
> ee15faffef1130 Stephen Boyd     2015-10-26  135         struct clk_fixed_factor *factor;
> ee15faffef1130 Stephen Boyd     2015-10-26  136         struct clk_fixed_rate *fixed;
>                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> ee15faffef1130 Stephen Boyd     2015-10-26  137         struct clk_init_data init_data = { };
> 120c1552839036 Stephen Boyd     2016-08-16  138         int ret;
> ee15faffef1130 Stephen Boyd     2015-10-26  139
> ee15faffef1130 Stephen Boyd     2015-10-26  140         clocks_node = of_find_node_by_path("/clocks");
> 43a51019cc8ff1 Johan Hovold     2017-11-11  141         if (clocks_node) {
> 43a51019cc8ff1 Johan Hovold     2017-11-11  142                 node = of_get_child_by_name(clocks_node, path);
> 43a51019cc8ff1 Johan Hovold     2017-11-11  143                 of_node_put(clocks_node);
> 43a51019cc8ff1 Johan Hovold     2017-11-11  144         }
> ee15faffef1130 Stephen Boyd     2015-10-26  145
> ee15faffef1130 Stephen Boyd     2015-10-26  146         if (!node) {
> ee15faffef1130 Stephen Boyd     2015-10-26  147                 fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
> ee15faffef1130 Stephen Boyd     2015-10-26  148                 if (!fixed)
> ee15faffef1130 Stephen Boyd     2015-10-26  149                         return -EINVAL;
> ee15faffef1130 Stephen Boyd     2015-10-26  150
> ee15faffef1130 Stephen Boyd     2015-10-26  151                 fixed->fixed_rate = rate;
> ee15faffef1130 Stephen Boyd     2015-10-26  152                 fixed->hw.init = &init_data;
> ee15faffef1130 Stephen Boyd     2015-10-26  153
> ee15faffef1130 Stephen Boyd     2015-10-26  154                 init_data.name = path;
> ee15faffef1130 Stephen Boyd     2015-10-26  155                 init_data.ops = &clk_fixed_rate_ops;
> ee15faffef1130 Stephen Boyd     2015-10-26  156
> 120c1552839036 Stephen Boyd     2016-08-16  157                 ret = devm_clk_hw_register(dev, &fixed->hw);
> 120c1552839036 Stephen Boyd     2016-08-16  158                 if (ret)
> 120c1552839036 Stephen Boyd     2016-08-16  159                         return ret;
> ee15faffef1130 Stephen Boyd     2015-10-26  160         }
>
> "fixed" is not set on else path.
>
> ee15faffef1130 Stephen Boyd     2015-10-26  161         of_node_put(node);
> ee15faffef1130 Stephen Boyd     2015-10-26  162
> ee15faffef1130 Stephen Boyd     2015-10-26  163         if (add_factor) {
> ee15faffef1130 Stephen Boyd     2015-10-26  164                 factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL);
> ee15faffef1130 Stephen Boyd     2015-10-26  165                 if (!factor)
> ee15faffef1130 Stephen Boyd     2015-10-26  166                         return -EINVAL;
> ee15faffef1130 Stephen Boyd     2015-10-26  167
> ee15faffef1130 Stephen Boyd     2015-10-26  168                 factor->mult = factor->div = 1;
> ee15faffef1130 Stephen Boyd     2015-10-26  169                 factor->hw.init = &init_data;
> ee15faffef1130 Stephen Boyd     2015-10-26  170
> ee15faffef1130 Stephen Boyd     2015-10-26  171                 init_data.name = name;
> daa853a735065a Dmitry Baryshkov 2022-06-20 @172                 init_data.parent_hws = (const struct clk_hw*[]){ &fixed->hw };
>                                                                                                                   ^^^^^
> Used here.  This would work if fixed were set to NULL at the start but
> I kind of hate that it requires us to know that ->hw is the first member
> of fixed struct.

Thanks for reporting this. The problem is a bit worse. If the node
exists, we are expected to use the existing global clock here instead
of the newly created 'fixed' clock.

>
> ee15faffef1130 Stephen Boyd     2015-10-26  173                 init_data.num_parents = 1;
> ee15faffef1130 Stephen Boyd     2015-10-26  174                 init_data.flags = 0;
> ee15faffef1130 Stephen Boyd     2015-10-26  175                 init_data.ops = &clk_fixed_factor_ops;
> ee15faffef1130 Stephen Boyd     2015-10-26  176
> 120c1552839036 Stephen Boyd     2016-08-16  177                 ret = devm_clk_hw_register(dev, &factor->hw);
> 120c1552839036 Stephen Boyd     2016-08-16  178                 if (ret)
> 120c1552839036 Stephen Boyd     2016-08-16  179                         return ret;
> ee15faffef1130 Stephen Boyd     2015-10-26  180         }
> ee15faffef1130 Stephen Boyd     2015-10-26  181
> ee15faffef1130 Stephen Boyd     2015-10-26  182         return 0;
> ee15faffef1130 Stephen Boyd     2015-10-26  183  }
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp
> _______________________________________________
> kbuild mailing list -- kbuild@lists.01.org
> To unsubscribe send an email to kbuild-leave@lists.01.org
>
diff mbox series

Patch

diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index 75f09e6e057e..2014484fc66d 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -169,7 +169,7 @@  static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
 		factor->hw.init = &init_data;
 
 		init_data.name = name;
-		init_data.parent_names = &path;
+		init_data.parent_hws = (const struct clk_hw*[]){ &fixed->hw };
 		init_data.num_parents = 1;
 		init_data.flags = 0;
 		init_data.ops = &clk_fixed_factor_ops;