@@ -432,16 +432,19 @@ static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb,
432432
433433/* helper function to register a CPU clock */
434434static int __init exynos_register_cpu_clock (struct samsung_clk_provider * ctx ,
435- unsigned int lookup_id , const char * name ,
436- const struct clk_hw * parent , const struct clk_hw * alt_parent ,
437- unsigned long offset , const struct exynos_cpuclk_cfg_data * cfg ,
438- unsigned long num_cfgs , unsigned long flags )
435+ const struct samsung_cpu_clock * clk_data )
439436{
437+ const struct clk_hw * parent , * alt_parent ;
438+ struct clk_hw * * hws ;
440439 struct exynos_cpuclk * cpuclk ;
441440 struct clk_init_data init ;
442441 const char * parent_name ;
442+ unsigned int num_cfgs ;
443443 int ret = 0 ;
444444
445+ hws = ctx -> clk_data .hws ;
446+ parent = hws [clk_data -> parent_id ];
447+ alt_parent = hws [clk_data -> alt_parent_id ];
445448 if (IS_ERR (parent ) || IS_ERR (alt_parent )) {
446449 pr_err ("%s: invalid parent clock(s)\n" , __func__ );
447450 return - EINVAL ;
@@ -453,42 +456,48 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
453456
454457 parent_name = clk_hw_get_name (parent );
455458
456- init .name = name ;
459+ init .name = clk_data -> name ;
457460 init .flags = CLK_SET_RATE_PARENT ;
458461 init .parent_names = & parent_name ;
459462 init .num_parents = 1 ;
460463 init .ops = & exynos_cpuclk_clk_ops ;
461464
462465 cpuclk -> alt_parent = alt_parent ;
463466 cpuclk -> hw .init = & init ;
464- cpuclk -> ctrl_base = ctx -> reg_base + offset ;
467+ cpuclk -> ctrl_base = ctx -> reg_base + clk_data -> offset ;
465468 cpuclk -> lock = & ctx -> lock ;
466- cpuclk -> flags = flags ;
467- if (flags & CLK_CPU_HAS_E5433_REGS_LAYOUT )
469+ cpuclk -> flags = clk_data -> flags ;
470+ if (clk_data -> flags & CLK_CPU_HAS_E5433_REGS_LAYOUT )
468471 cpuclk -> clk_nb .notifier_call = exynos5433_cpuclk_notifier_cb ;
469472 else
470473 cpuclk -> clk_nb .notifier_call = exynos_cpuclk_notifier_cb ;
471474
472475 ret = clk_notifier_register (parent -> clk , & cpuclk -> clk_nb );
473476 if (ret ) {
474477 pr_err ("%s: failed to register clock notifier for %s\n" ,
475- __func__ , name );
478+ __func__ , clk_data -> name );
476479 goto free_cpuclk ;
477480 }
478481
479- cpuclk -> cfg = kmemdup (cfg , sizeof (* cfg ) * num_cfgs , GFP_KERNEL );
482+ /* Find count of configuration rates in cfg */
483+ for (num_cfgs = 0 ; clk_data -> cfg [num_cfgs ].prate != 0 ; )
484+ num_cfgs ++ ;
485+
486+ cpuclk -> cfg = kmemdup (clk_data -> cfg , sizeof (* clk_data -> cfg ) * num_cfgs ,
487+ GFP_KERNEL );
480488 if (!cpuclk -> cfg ) {
481489 ret = - ENOMEM ;
482490 goto unregister_clk_nb ;
483491 }
484492
485493 ret = clk_hw_register (NULL , & cpuclk -> hw );
486494 if (ret ) {
487- pr_err ("%s: could not register cpuclk %s\n" , __func__ , name );
495+ pr_err ("%s: could not register cpuclk %s\n" , __func__ ,
496+ clk_data -> name );
488497 goto free_cpuclk_data ;
489498 }
490499
491- samsung_clk_add_lookup (ctx , & cpuclk -> hw , lookup_id );
500+ samsung_clk_add_lookup (ctx , & cpuclk -> hw , clk_data -> id );
492501 return 0 ;
493502
494503free_cpuclk_data :
@@ -504,16 +513,7 @@ void __init samsung_clk_register_cpu(struct samsung_clk_provider *ctx,
504513 const struct samsung_cpu_clock * list , unsigned int nr_clk )
505514{
506515 unsigned int idx ;
507- unsigned int num_cfgs ;
508- struct clk_hw * * hws = ctx -> clk_data .hws ;
509516
510- for (idx = 0 ; idx < nr_clk ; idx ++ , list ++ ) {
511- /* find count of configuration rates in cfg */
512- for (num_cfgs = 0 ; list -> cfg [num_cfgs ].prate != 0 ; )
513- num_cfgs ++ ;
514-
515- exynos_register_cpu_clock (ctx , list -> id , list -> name ,
516- hws [list -> parent_id ], hws [list -> alt_parent_id ],
517- list -> offset , list -> cfg , num_cfgs , list -> flags );
518- }
517+ for (idx = 0 ; idx < nr_clk ; idx ++ )
518+ exynos_register_cpu_clock (ctx , & list [idx ]);
519519}
0 commit comments