diff options
author | Dmitry Osipenko <digetx@gmail.com> | 2021-01-20 23:26:49 +0100 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2021-02-02 05:57:43 +0100 |
commit | 04b447df1d098dcd7d133203a310a6d415875547 (patch) | |
tree | e95c1618a7fbaaea8f9082770c631c4a000902bd /drivers/opp | |
parent | opp: Prepare for ->set_opp() helper to work without regulators (diff) | |
download | linux-04b447df1d098dcd7d133203a310a6d415875547.tar.xz linux-04b447df1d098dcd7d133203a310a6d415875547.zip |
opp: Make _set_opp_custom() work without regulators
Check whether OPP table has regulators in _set_opp_custom() and set up
dev_pm_set_opp_data accordingly. Now _set_opp_custom() works properly,
i.e. it doesn't crash if OPP table doesn't have assigned regulators.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
[ Viresh: Rearrange the routine a bit ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp')
-rw-r--r-- | drivers/opp/core.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index f482937d72eb..b4528e40ad01 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -828,24 +828,31 @@ static int _set_opp_custom(const struct opp_table *opp_table, struct dev_pm_opp_supply *old_supply, struct dev_pm_opp_supply *new_supply) { - struct dev_pm_set_opp_data *data; + struct dev_pm_set_opp_data *data = opp_table->set_opp_data; int size; - data = opp_table->set_opp_data; + /* + * We support this only if dev_pm_opp_set_regulators() was called + * earlier. + */ + if (opp_table->sod_supplies) { + size = sizeof(*old_supply) * opp_table->regulator_count; + if (!old_supply) + memset(data->old_opp.supplies, 0, size); + else + memcpy(data->old_opp.supplies, old_supply, size); + + memcpy(data->new_opp.supplies, new_supply, size); + data->regulator_count = opp_table->regulator_count; + } else { + data->regulator_count = 0; + } + data->regulators = opp_table->regulators; - data->regulator_count = opp_table->regulator_count; data->clk = opp_table->clk; data->dev = dev; - data->old_opp.rate = old_freq; - size = sizeof(*old_supply) * opp_table->regulator_count; - if (!old_supply) - memset(data->old_opp.supplies, 0, size); - else - memcpy(data->old_opp.supplies, old_supply, size); - data->new_opp.rate = freq; - memcpy(data->new_opp.supplies, new_supply, size); return opp_table->set_opp(data); } |