kernel: bump 4.14 to 4.14.48 for 18.06
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.14 / 0054-cpufreq-dt-Handle-OPP-voltage-adjust-events.patch
index 47c64eca8201a14d6ef7afd149c09f6db2da67cd..969adfe4b5219e83d21c673017842286e9eb74b4 100644 (file)
@@ -26,19 +26,19 @@ Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
 --- a/drivers/cpufreq/cpufreq-dt.c
 +++ b/drivers/cpufreq/cpufreq-dt.c
 @@ -32,6 +32,9 @@ struct private_data {
-       struct device *cpu_dev;
-       struct thermal_cooling_device *cdev;
-       const char *reg_name;
+       struct device *cpu_dev;
+       struct thermal_cooling_device *cdev;
+       const char *reg_name;
 +      struct notifier_block opp_nb;
 +      struct mutex lock;
 +      unsigned long opp_freq;
  };
-
  static struct freq_attr *cpufreq_dt_attr[] = {
 @@ -43,9 +46,16 @@ static struct freq_attr *cpufreq_dt_attr
  static int set_target(struct cpufreq_policy *policy, unsigned int index)
  {
-       struct private_data *priv = policy->driver_data;
+       struct private_data *priv = policy->driver_data;
 +      int ret;
 +      unsigned long target_freq = policy->freq_table[index].frequency * 1000;
 +
@@ -47,17 +47,17 @@ Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
 +      if (!ret)
 +              priv->opp_freq = target_freq;
 +      mutex_unlock(&priv->lock);
-
 -      return dev_pm_opp_set_rate(priv->cpu_dev,
 -                                 policy->freq_table[index].frequency * 1000);
 +      return ret;
  }
-
  /*
 @@ -86,6 +96,39 @@ node_put:
-       return name;
+       return name;
  }
-
 +static int opp_notifier(struct notifier_block *nb, unsigned long event,
 +                      void *data)
 +{
@@ -93,39 +93,39 @@ Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
 +
  static int resources_available(void)
  {
-       struct device *cpu_dev;
+       struct device *cpu_dev;
 @@ -152,6 +195,7 @@ static int cpufreq_init(struct cpufreq_p
-       bool fallback = false;
-       const char *name;
-       int ret;
+       bool fallback = false;
+       const char *name;
+       int ret;
 +      struct srcu_notifier_head *opp_srcu_head;
-
-       cpu_dev = get_cpu_device(policy->cpu);
-       if (!cpu_dev) {
+       cpu_dev = get_cpu_device(policy->cpu);
+       if (!cpu_dev) {
 @@ -241,13 +285,16 @@ static int cpufreq_init(struct cpufreq_p
-               goto out_free_opp;
-       }
-
+               goto out_free_opp;
+       }
 +      mutex_init(&priv->lock);
 +      dev_pm_opp_register_notifier(cpu_dev, &priv->opp_nb);
 +
-       priv->reg_name = name;
-       priv->opp_table = opp_table;
-
-       ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
-       if (ret) {
-               dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
+       priv->reg_name = name;
+       priv->opp_table = opp_table;
+       ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
+       if (ret) {
+               dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
 -              goto out_free_priv;
 +              goto out_unregister_nb;
-       }
-
-       priv->cpu_dev = cpu_dev;
-@@ -283,6 +343,8 @@ static int cpufreq_init(struct cpufreq_p
-
+       }
+       priv->cpu_dev = cpu_dev;
+@@ -283,6 +330,8 @@ static int cpufreq_init(struct cpufreq_p
  out_free_cpufreq_table:
-       dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
+       dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
 +out_unregister_nb:
 +      dev_pm_opp_unregister_notifier(cpu_dev, &priv->opp_nb);
  out_free_priv:
-       kfree(priv);
+       kfree(priv);
  out_free_opp: