@@ -4439,7 +4439,7 @@ static int regulator_register_resolve_supply(struct device *dev, void *data)
4439
4439
return 0 ;
4440
4440
}
4441
4441
4442
- static int regulator_fill_coupling_array (struct regulator_dev * rdev )
4442
+ static void regulator_resolve_coupling (struct regulator_dev * rdev )
4443
4443
{
4444
4444
struct coupling_desc * c_desc = & rdev -> coupling_desc ;
4445
4445
int n_coupled = c_desc -> n_coupled ;
@@ -4453,33 +4453,21 @@ static int regulator_fill_coupling_array(struct regulator_dev *rdev)
4453
4453
4454
4454
c_rdev = of_parse_coupled_regulator (rdev , i - 1 );
4455
4455
4456
- if (c_rdev ) {
4457
- c_desc -> coupled_rdevs [i ] = c_rdev ;
4458
- c_desc -> n_resolved ++ ;
4459
- }
4460
- }
4461
-
4462
- if (rdev -> coupling_desc .n_resolved < n_coupled )
4463
- return -1 ;
4464
- else
4465
- return 0 ;
4466
- }
4456
+ if (!c_rdev )
4457
+ continue ;
4467
4458
4468
- static int regulator_register_fill_coupling_array (struct device * dev ,
4469
- void * data )
4470
- {
4471
- struct regulator_dev * rdev = dev_to_rdev (dev );
4459
+ regulator_lock (c_rdev );
4472
4460
4473
- if (! IS_ENABLED ( CONFIG_OF ))
4474
- return 0 ;
4461
+ c_desc -> coupled_rdevs [ i ] = c_rdev ;
4462
+ c_desc -> n_resolved ++ ;
4475
4463
4476
- if (regulator_fill_coupling_array (rdev ))
4477
- rdev_dbg (rdev , "unable to resolve coupling\n" );
4464
+ regulator_unlock (c_rdev );
4478
4465
4479
- return 0 ;
4466
+ regulator_resolve_coupling (c_rdev );
4467
+ }
4480
4468
}
4481
4469
4482
- static int regulator_resolve_coupling (struct regulator_dev * rdev )
4470
+ static int regulator_init_coupling (struct regulator_dev * rdev )
4483
4471
{
4484
4472
int n_phandles ;
4485
4473
@@ -4519,13 +4507,6 @@ static int regulator_resolve_coupling(struct regulator_dev *rdev)
4519
4507
if (!of_check_coupling_data (rdev ))
4520
4508
return - EPERM ;
4521
4509
4522
- /*
4523
- * After everything has been checked, try to fill rdevs array
4524
- * with pointers to regulators parsed from device tree. If some
4525
- * regulators are not registered yet, retry in late init call
4526
- */
4527
- regulator_fill_coupling_array (rdev );
4528
-
4529
4510
return 0 ;
4530
4511
}
4531
4512
@@ -4662,11 +4643,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
4662
4643
if (ret < 0 )
4663
4644
goto wash ;
4664
4645
4665
- mutex_lock (& regulator_list_mutex );
4666
- ret = regulator_resolve_coupling (rdev );
4667
- mutex_unlock (& regulator_list_mutex );
4668
-
4669
- if (ret != 0 )
4646
+ ret = regulator_init_coupling (rdev );
4647
+ if (ret < 0 )
4670
4648
goto wash ;
4671
4649
4672
4650
/* add consumers devices */
@@ -4700,6 +4678,11 @@ regulator_register(const struct regulator_desc *regulator_desc,
4700
4678
4701
4679
rdev_init_debugfs (rdev );
4702
4680
4681
+ /* try to resolve regulators coupling since a new one was registered */
4682
+ mutex_lock (& regulator_list_mutex );
4683
+ regulator_resolve_coupling (rdev );
4684
+ mutex_unlock (& regulator_list_mutex );
4685
+
4703
4686
/* try to resolve regulators supply since a new one was registered */
4704
4687
class_for_each_device (& regulator_class , NULL , NULL ,
4705
4688
regulator_register_resolve_supply );
@@ -5155,9 +5138,6 @@ static int __init regulator_init_complete(void)
5155
5138
class_for_each_device (& regulator_class , NULL , NULL ,
5156
5139
regulator_late_cleanup );
5157
5140
5158
- class_for_each_device (& regulator_class , NULL , NULL ,
5159
- regulator_register_fill_coupling_array );
5160
-
5161
5141
return 0 ;
5162
5142
}
5163
5143
late_initcall_sync (regulator_init_complete );
0 commit comments