@@ -1076,7 +1076,7 @@ static int _opp_set_required_opps_genpd(struct device *dev,
10761076{
10771077 struct device * * genpd_virt_devs =
10781078 opp_table -> genpd_virt_devs ? opp_table -> genpd_virt_devs : & dev ;
1079- int index , target , delta , ret = 0 ;
1079+ int index , target , delta , ret ;
10801080
10811081 /* Scaling up? Set required OPPs in normal order, else reverse */
10821082 if (!scaling_down ) {
@@ -1089,23 +1089,15 @@ static int _opp_set_required_opps_genpd(struct device *dev,
10891089 delta = -1 ;
10901090 }
10911091
1092- /*
1093- * Acquire genpd_virt_dev_lock to make sure we don't use a genpd_dev
1094- * after it is freed from another thread.
1095- */
1096- mutex_lock (& opp_table -> genpd_virt_dev_lock );
1097-
10981092 while (index != target ) {
10991093 ret = _set_performance_state (dev , genpd_virt_devs [index ], opp , index );
11001094 if (ret )
1101- break ;
1095+ return ret ;
11021096
11031097 index += delta ;
11041098 }
11051099
1106- mutex_unlock (& opp_table -> genpd_virt_dev_lock );
1107-
1108- return ret ;
1100+ return 0 ;
11091101}
11101102
11111103/* This is only called for PM domain for now */
@@ -1474,7 +1466,6 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index)
14741466 return ERR_PTR (- ENOMEM );
14751467
14761468 mutex_init (& opp_table -> lock );
1477- mutex_init (& opp_table -> genpd_virt_dev_lock );
14781469 INIT_LIST_HEAD (& opp_table -> dev_list );
14791470 INIT_LIST_HEAD (& opp_table -> lazy );
14801471
@@ -1510,7 +1501,6 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index)
15101501remove_opp_dev :
15111502 _of_clear_opp_table (opp_table );
15121503 _remove_opp_dev (opp_dev , opp_table );
1513- mutex_destroy (& opp_table -> genpd_virt_dev_lock );
15141504 mutex_destroy (& opp_table -> lock );
15151505err :
15161506 kfree (opp_table );
@@ -1678,7 +1668,6 @@ static void _opp_table_kref_release(struct kref *kref)
16781668 list_for_each_entry_safe (opp_dev , temp , & opp_table -> dev_list , node )
16791669 _remove_opp_dev (opp_dev , opp_table );
16801670
1681- mutex_destroy (& opp_table -> genpd_virt_dev_lock );
16821671 mutex_destroy (& opp_table -> lock );
16831672 kfree (opp_table );
16841673}
@@ -2395,7 +2384,7 @@ static void _opp_put_config_regulators_helper(struct opp_table *opp_table)
23952384 opp_table -> config_regulators = NULL ;
23962385}
23972386
2398- static void _detach_genpd (struct opp_table * opp_table )
2387+ static void _opp_detach_genpd (struct opp_table * opp_table )
23992388{
24002389 int index ;
24012390
@@ -2449,13 +2438,11 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
24492438 if (!opp_table -> required_opp_count )
24502439 return - EPROBE_DEFER ;
24512440
2452- mutex_lock (& opp_table -> genpd_virt_dev_lock );
2453-
24542441 opp_table -> genpd_virt_devs = kcalloc (opp_table -> required_opp_count ,
24552442 sizeof (* opp_table -> genpd_virt_devs ),
24562443 GFP_KERNEL );
24572444 if (!opp_table -> genpd_virt_devs )
2458- goto unlock ;
2445+ return - ENOMEM ;
24592446
24602447 while (* name ) {
24612448 if (index >= opp_table -> required_opp_count ) {
@@ -2478,29 +2465,15 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
24782465
24792466 if (virt_devs )
24802467 * virt_devs = opp_table -> genpd_virt_devs ;
2481- mutex_unlock (& opp_table -> genpd_virt_dev_lock );
24822468
24832469 return 0 ;
24842470
24852471err :
2486- _detach_genpd (opp_table );
2487- unlock :
2488- mutex_unlock (& opp_table -> genpd_virt_dev_lock );
2472+ _opp_detach_genpd (opp_table );
24892473 return ret ;
24902474
24912475}
24922476
2493- static void _opp_detach_genpd (struct opp_table * opp_table )
2494- {
2495- /*
2496- * Acquire genpd_virt_dev_lock to make sure virt_dev isn't getting
2497- * used in parallel.
2498- */
2499- mutex_lock (& opp_table -> genpd_virt_dev_lock );
2500- _detach_genpd (opp_table );
2501- mutex_unlock (& opp_table -> genpd_virt_dev_lock );
2502- }
2503-
25042477static void _opp_clear_config (struct opp_config_data * data )
25052478{
25062479 if (data -> flags & OPP_CONFIG_GENPD )
0 commit comments