]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
devfreq: clip max/min frequencies in store APIs
authorDeepak Nibade <dnibade@nvidia.com>
Wed, 7 Dec 2016 08:13:09 +0000 (13:43 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Fri, 9 Dec 2016 12:34:57 +0000 (04:34 -0800)
In max_freq_store(), we allow any large to be
stored as max_freq
Similarly in min_freq_store() we allow any
lower value as min_freq

Fix this so that we clip max_freq to highest
freq value supported and clip min_freq to
lowest freq value supported

Bug 200260336

Change-Id: I6b11f6a5fd31f9411299dbeea1d3a528e1077bc5
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1266463
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/devfreq/devfreq.c

index 6524c099c1b920f19f5843b12b8b41d15df68e2c..d65dcb23e600bfccc68fb29524d81e004f6146f3 100644 (file)
@@ -947,6 +947,10 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
                goto unlock;
        }
 
+       /* can't drop below supported MIN */
+       if (value < df->profile->freq_table[0])
+               value = df->profile->freq_table[0];
+
        df->min_freq = value;
        update_devfreq(df);
        ret = count;
@@ -968,6 +972,7 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
        unsigned long value;
        int ret;
        unsigned long min;
+       unsigned int max_states;
 
        ret = sscanf(buf, "%lu", &value);
        if (ret != 1)
@@ -980,6 +985,11 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
                goto unlock;
        }
 
+       /* can't exceed supported MAX */
+       max_states = df->profile->max_state;
+       if (value > df->profile->freq_table[max_states - 1])
+               value = df->profile->freq_table[max_states - 1];
+
        df->max_freq = value;
        update_devfreq(df);
        ret = count;