Commit 87686cc8 authored by Viresh Kumar's avatar Viresh Kumar
Browse files

OPP: Make dev_pm_opp_set_regulators() accept NULL terminated list



Make dev_pm_opp_set_regulators() accept a NULL terminated list of names
instead of making the callers keep the two parameters in sync, which
creates an opportunity for bugs to get in.

Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Steven Price <steven.price@arm.com> # panfrost
Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 0a43452b
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
	struct private_data *priv;
	struct device *cpu_dev;
	bool fallback = false;
	const char *reg_name;
	const char *reg_name[] = { NULL, NULL };
	int ret;

	/* Check if this CPU is already covered by some other policy */
@@ -218,10 +218,9 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
	 * OPP layer will be taking care of regulators now, but it needs to know
	 * the name of the regulator first.
	 */
	reg_name = find_supply_name(cpu_dev);
	if (reg_name) {
		priv->opp_table = dev_pm_opp_set_regulators(cpu_dev, &reg_name,
							    1);
	reg_name[0] = find_supply_name(cpu_dev);
	if (reg_name[0]) {
		priv->opp_table = dev_pm_opp_set_regulators(cpu_dev, reg_name);
		if (IS_ERR(priv->opp_table)) {
			ret = PTR_ERR(priv->opp_table);
			if (ret != -EPROBE_DEFER)
+3 −4
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ static struct ti_cpufreq_soc_data omap34xx_soc_data = {
 *    seems to always read as 0).
 */

static const char * const omap3_reg_names[] = {"cpu0", "vbb"};
static const char * const omap3_reg_names[] = {"cpu0", "vbb", NULL};

static struct ti_cpufreq_soc_data omap36xx_soc_data = {
	.reg_names = omap3_reg_names,
@@ -326,7 +326,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
	const struct of_device_id *match;
	struct opp_table *ti_opp_table;
	struct ti_cpufreq_data *opp_data;
	const char * const default_reg_names[] = {"vdd", "vbb"};
	const char * const default_reg_names[] = {"vdd", "vbb", NULL};
	int ret;

	match = dev_get_platdata(&pdev->dev);
@@ -387,8 +387,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
		if (opp_data->soc_data->reg_names)
			reg_names = opp_data->soc_data->reg_names;
		ti_opp_table = dev_pm_opp_set_regulators(opp_data->cpu_dev,
							 reg_names,
							 ARRAY_SIZE(default_reg_names));
							 reg_names);
		if (IS_ERR(ti_opp_table)) {
			dev_pm_opp_put_supported_hw(opp_data->opp_table);
			ret =  PTR_ERR(ti_opp_table);
+2 −2
Original line number Diff line number Diff line
@@ -180,10 +180,10 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
{
	struct device *dev = bus->dev;
	struct opp_table *opp_table;
	const char *vdd = "vdd";
	const char *supplies[] = { "vdd", NULL };
	int i, ret, count, size;

	opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
	opp_table = dev_pm_opp_set_regulators(dev, supplies);
	if (IS_ERR(opp_table)) {
		ret = PTR_ERR(opp_table);
		dev_err(dev, "failed to set regulators %d\n", ret);
+2 −1
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ int lima_devfreq_init(struct lima_device *ldev)
	struct dev_pm_opp *opp;
	unsigned long cur_freq;
	int ret;
	const char *regulator_names[] = { "mali", NULL };

	if (!device_property_present(dev, "operating-points-v2"))
		/* Optional, continue without devfreq */
@@ -122,7 +123,7 @@ int lima_devfreq_init(struct lima_device *ldev)
	if (ret)
		return ret;

	ret = devm_pm_opp_set_regulators(dev, (const char *[]){ "mali" }, 1);
	ret = devm_pm_opp_set_regulators(dev, regulator_names);
	if (ret) {
		/* Continue if the optional regulator is missing */
		if (ret != -ENODEV)
+1 −2
Original line number Diff line number Diff line
@@ -101,8 +101,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
		return 0;
	}

	ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
					 pfdev->comp->num_supplies);
	ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names);
	if (ret) {
		/* Continue if the optional regulator is missing */
		if (ret != -ENODEV) {
Loading