@@ -296,46 +296,51 @@ void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp)
296
296
of_node_put (opp -> np );
297
297
}
298
298
299
+ static int _link_required_opps (struct dev_pm_opp * opp ,
300
+ struct opp_table * required_table , int index )
301
+ {
302
+ struct device_node * np ;
303
+
304
+ np = of_parse_required_opp (opp -> np , index );
305
+ if (unlikely (!np ))
306
+ return - ENODEV ;
307
+
308
+ opp -> required_opps [index ] = _find_opp_of_np (required_table , np );
309
+ of_node_put (np );
310
+
311
+ if (!opp -> required_opps [index ]) {
312
+ pr_err ("%s: Unable to find required OPP node: %pOF (%d)\n" ,
313
+ __func__ , opp -> np , index );
314
+ return - ENODEV ;
315
+ }
316
+
317
+ return 0 ;
318
+ }
319
+
299
320
/* Populate all required OPPs which are part of "required-opps" list */
300
321
static int _of_opp_alloc_required_opps (struct opp_table * opp_table ,
301
322
struct dev_pm_opp * opp )
302
323
{
303
- struct dev_pm_opp * * required_opps ;
304
324
struct opp_table * required_table ;
305
- struct device_node * np ;
306
325
int i , ret , count = opp_table -> required_opp_count ;
307
326
308
327
if (!count )
309
328
return 0 ;
310
329
311
- required_opps = kcalloc (count , sizeof (* required_opps ), GFP_KERNEL );
312
- if (!required_opps )
330
+ opp -> required_opps = kcalloc (count , sizeof (* opp -> required_opps ), GFP_KERNEL );
331
+ if (!opp -> required_opps )
313
332
return - ENOMEM ;
314
333
315
- opp -> required_opps = required_opps ;
316
-
317
334
for (i = 0 ; i < count ; i ++ ) {
318
335
required_table = opp_table -> required_opp_tables [i ];
319
336
320
337
/* Required table not added yet, we will link later */
321
338
if (IS_ERR_OR_NULL (required_table ))
322
339
continue ;
323
340
324
- np = of_parse_required_opp (opp -> np , i );
325
- if (unlikely (!np )) {
326
- ret = - ENODEV ;
327
- goto free_required_opps ;
328
- }
329
-
330
- required_opps [i ] = _find_opp_of_np (required_table , np );
331
- of_node_put (np );
332
-
333
- if (!required_opps [i ]) {
334
- pr_err ("%s: Unable to find required OPP node: %pOF (%d)\n" ,
335
- __func__ , opp -> np , i );
336
- ret = - ENODEV ;
341
+ ret = _link_required_opps (opp , required_table , i );
342
+ if (ret )
337
343
goto free_required_opps ;
338
- }
339
344
}
340
345
341
346
return 0 ;
@@ -350,22 +355,13 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table,
350
355
static int lazy_link_required_opps (struct opp_table * opp_table ,
351
356
struct opp_table * new_table , int index )
352
357
{
353
- struct device_node * required_np ;
354
358
struct dev_pm_opp * opp ;
359
+ int ret ;
355
360
356
361
list_for_each_entry (opp , & opp_table -> opp_list , node ) {
357
- required_np = of_parse_required_opp (opp -> np , index );
358
- if (unlikely (!required_np ))
359
- return - ENODEV ;
360
-
361
- opp -> required_opps [index ] = _find_opp_of_np (new_table , required_np );
362
- of_node_put (required_np );
363
-
364
- if (!opp -> required_opps [index ]) {
365
- pr_err ("%s: Unable to find required OPP node: %pOF (%d)\n" ,
366
- __func__ , opp -> np , index );
367
- return - ENODEV ;
368
- }
362
+ ret = _link_required_opps (opp , new_table , index );
363
+ if (ret )
364
+ return ret ;
369
365
}
370
366
371
367
return 0 ;
0 commit comments