@@ -79,41 +79,46 @@ static unsigned long ccu_mux_helper_unapply_prediv(struct ccu_common *common,
7979int ccu_mux_helper_determine_rate (struct ccu_common * common ,
8080 struct ccu_mux_internal * cm ,
8181 struct clk_rate_request * req ,
82- unsigned long (* round )(struct ccu_mux_internal * ,
83- struct clk_hw * ,
84- unsigned long * ,
85- unsigned long ,
86- void * ),
82+ int (* round )(struct ccu_mux_internal * ,
83+ struct clk_rate_request * ,
84+ void * ),
8785 void * data )
8886{
8987 unsigned long best_parent_rate = 0 , best_rate = 0 ;
9088 struct clk_hw * best_parent , * hw = & common -> hw ;
9189 unsigned int i ;
90+ int ret ;
9291
9392 if (clk_hw_get_flags (hw ) & CLK_SET_RATE_NO_REPARENT ) {
94- unsigned long adj_parent_rate ;
93+ struct clk_rate_request adj_req = * req ;
9594
9695 best_parent = clk_hw_get_parent (hw );
9796 best_parent_rate = clk_hw_get_rate (best_parent );
98- adj_parent_rate = ccu_mux_helper_apply_prediv (common , cm , -1 ,
99- best_parent_rate );
10097
101- best_rate = round (cm , best_parent , & adj_parent_rate ,
102- req -> rate , data );
98+ adj_req .best_parent_hw = best_parent ;
99+ adj_req .best_parent_rate = ccu_mux_helper_apply_prediv (common , cm , -1 ,
100+ best_parent_rate );
101+
102+ ret = round (cm , & adj_req , data );
103+ if (ret )
104+ return ret ;
105+
106+ best_rate = adj_req .rate ;
103107
104108 /*
105- * adj_parent_rate might have been modified by our clock.
109+ * best_parent_rate might have been modified by our clock.
106110 * Unapply the pre-divider if there's one, and give
107111 * the actual frequency the parent needs to run at.
108112 */
109113 best_parent_rate = ccu_mux_helper_unapply_prediv (common , cm , -1 ,
110- adj_parent_rate );
114+ adj_req . best_parent_rate );
111115
112116 goto out ;
113117 }
114118
115119 for (i = 0 ; i < clk_hw_get_num_parents (hw ); i ++ ) {
116- unsigned long tmp_rate , parent_rate ;
120+ struct clk_rate_request tmp_req = * req ;
121+ unsigned long parent_rate ;
117122 struct clk_hw * parent ;
118123
119124 parent = clk_hw_get_parent_by_index (hw , i );
@@ -123,24 +128,30 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
123128 parent_rate = ccu_mux_helper_apply_prediv (common , cm , i ,
124129 clk_hw_get_rate (parent ));
125130
126- tmp_rate = round (cm , parent , & parent_rate , req -> rate , data );
131+ tmp_req .best_parent_hw = parent ;
132+ tmp_req .best_parent_rate = parent_rate ;
133+
134+ ret = round (cm , & tmp_req , data );
135+ if (ret )
136+ continue ;
127137
128138 /*
129139 * parent_rate might have been modified by our clock.
130140 * Unapply the pre-divider if there's one, and give
131141 * the actual frequency the parent needs to run at.
132142 */
133143 parent_rate = ccu_mux_helper_unapply_prediv (common , cm , i ,
134- parent_rate );
135- if (tmp_rate == req -> rate ) {
144+ tmp_req .best_parent_rate );
145+
146+ if (tmp_req .rate == req -> rate ) {
136147 best_parent = parent ;
137148 best_parent_rate = parent_rate ;
138- best_rate = tmp_rate ;
149+ best_rate = tmp_req . rate ;
139150 goto out ;
140151 }
141152
142- if (ccu_is_better_rate (common , req -> rate , tmp_rate , best_rate )) {
143- best_rate = tmp_rate ;
153+ if (ccu_is_better_rate (common , req -> rate , tmp_req . rate , best_rate )) {
154+ best_rate = tmp_req . rate ;
144155 best_parent_rate = parent_rate ;
145156 best_parent = parent ;
146157 }
0 commit comments