return 0;
}
-static int regulator_fill_coupling_array(struct regulator_dev *rdev)
+static void regulator_resolve_coupling(struct regulator_dev *rdev)
{
struct coupling_desc *c_desc = &rdev->coupling_desc;
int n_coupled = c_desc->n_coupled;
c_rdev = of_parse_coupled_regulator(rdev, i - 1);
- if (c_rdev) {
- c_desc->coupled_rdevs[i] = c_rdev;
- c_desc->n_resolved++;
- }
- }
-
- if (rdev->coupling_desc.n_resolved < n_coupled)
- return -1;
- else
- return 0;
-}
+ if (!c_rdev)
+ continue;
-static int regulator_register_fill_coupling_array(struct device *dev,
- void *data)
-{
- struct regulator_dev *rdev = dev_to_rdev(dev);
+ regulator_lock(c_rdev);
- if (!IS_ENABLED(CONFIG_OF))
- return 0;
+ c_desc->coupled_rdevs[i] = c_rdev;
+ c_desc->n_resolved++;
- if (regulator_fill_coupling_array(rdev))
- rdev_dbg(rdev, "unable to resolve coupling\n");
+ regulator_unlock(c_rdev);
- return 0;
+ regulator_resolve_coupling(c_rdev);
+ }
}
-static int regulator_resolve_coupling(struct regulator_dev *rdev)
+static int regulator_init_coupling(struct regulator_dev *rdev)
{
int n_phandles;
if (!of_check_coupling_data(rdev))
return -EPERM;
- /*
- * After everything has been checked, try to fill rdevs array
- * with pointers to regulators parsed from device tree. If some
- * regulators are not registered yet, retry in late init call
- */
- regulator_fill_coupling_array(rdev);
-
return 0;
}
if (ret < 0)
goto wash;
- mutex_lock(®ulator_list_mutex);
- ret = regulator_resolve_coupling(rdev);
- mutex_unlock(®ulator_list_mutex);
-
- if (ret != 0)
+ ret = regulator_init_coupling(rdev);
+ if (ret < 0)
goto wash;
/* add consumers devices */
rdev_init_debugfs(rdev);
+ /* try to resolve regulators coupling since a new one was registered */
+ mutex_lock(®ulator_list_mutex);
+ regulator_resolve_coupling(rdev);
+ mutex_unlock(®ulator_list_mutex);
+
/* try to resolve regulators supply since a new one was registered */
class_for_each_device(®ulator_class, NULL, NULL,
regulator_register_resolve_supply);
class_for_each_device(®ulator_class, NULL, NULL,
regulator_late_cleanup);
- class_for_each_device(®ulator_class, NULL, NULL,
- regulator_register_fill_coupling_array);
-
return 0;
}
late_initcall_sync(regulator_init_complete);