| @@ -123,7 +123,7 @@ void devfreq_get_freq_range(struct devfreq *devfreq, · 122 unmodified lines |
| 123 | unsigned long *min_freq, | 123 | unsigned long *min_freq, |
| 124 | unsigned long *max_freq) | 124 | unsigned long *max_freq) |
| 125 | { | 125 | { |
| 126 | unsigned long *freq_table = devfreq->profile->freq_table; | 126 | unsigned long *freq_table = devfreq->freq_table; |
| 127 | s32 qos_min_freq, qos_max_freq; | 127 | s32 qos_min_freq, qos_max_freq; |
| 128 | | 128 | |
| 129 | lockdep_assert_held(&devfreq->lock); | 129 | lockdep_assert_held(&devfreq->lock); |
| @@ -133,11 +133,11 @@ void devfreq_get_freq_range(struct devfreq *devfreq, · 3 unmodified lines |
| 133 | * The devfreq drivers can initialize this in either ascending or | 133 | * The devfreq drivers can initialize this in either ascending or |
| 134 | * descending order and devfreq core supports both. | 134 | * descending order and devfreq core supports both. |
| 135 | */ | 135 | */ |
| 136 | if (freq_table[0] < freq_table[devfreq->profile->max_state - 1]) { | 136 | if (freq_table[0] < freq_table[devfreq->max_state - 1]) { |
| 137 | *min_freq = freq_table[0]; | 137 | *min_freq = freq_table[0]; |
| 138 | *max_freq = freq_table[devfreq->profile->max_state - 1]; | 138 | *max_freq = freq_table[devfreq->max_state - 1]; |
| 139 | } else { | 139 | } else { |
| 140 | *min_freq = freq_table[devfreq->profile->max_state - 1]; | 140 | *min_freq = freq_table[devfreq->max_state - 1]; |
| 141 | *max_freq = freq_table[0]; | 141 | *max_freq = freq_table[0]; |
| 142 | } | 142 | } |
| 143 | | 143 | |
| @@ -169,8 +169,8 @@ static int devfreq_get_freq_level(struct devfreq *devfreq, unsigned long freq) · 25 unmodified lines |
| 169 | { | 169 | { |
| 170 | int lev; | 170 | int lev; |
| 171 | | 171 | |
| 172 | for (lev = 0; lev < devfreq->profile->max_state; lev++) | 172 | for (lev = 0; lev < devfreq->max_state; lev++) |
| 173 | if (freq == devfreq->profile->freq_table[lev]) | 173 | if (freq == devfreq->freq_table[lev]) |
| 174 | return lev; | 174 | return lev; |
| 175 | | 175 | |
| 176 | return -EINVAL; | 176 | return -EINVAL; |
| @@ -178,7 +178,6 @@ static int devfreq_get_freq_level(struct devfreq *devfreq, unsigned long freq) · 1 unmodified line |
| 178 | | 178 | |
| 179 | static int set_freq_table(struct devfreq *devfreq) | 179 | static int set_freq_table(struct devfreq *devfreq) |
| 180 | { | 180 | { |
| 181 | struct devfreq_dev_profile *profile = devfreq->profile; | | |
| 182 | struct dev_pm_opp *opp; | 181 | struct dev_pm_opp *opp; |
| 183 | unsigned long freq; | 182 | unsigned long freq; |
| 184 | int i, count; | 183 | int i, count; |
| @@ -188,25 +187,22 @@ static int set_freq_table(struct devfreq *devfreq) · 3 unmodified lines |
| 188 | if (count <= 0) | 187 | if (count <= 0) |
| 189 | return -EINVAL; | 188 | return -EINVAL; |
| 190 | | 189 | |
| 191 | profile->max_state = count; | 190 | devfreq->max_state = count; |
| 192 | profile->freq_table = devm_kcalloc(devfreq->dev.parent, | 191 | devfreq->freq_table = devm_kcalloc(devfreq->dev.parent, |
| 193 | profile->max_state, | 192 | devfreq->max_state, |
| 194 | sizeof(*profile->freq_table), | 193 | sizeof(*devfreq->freq_table), |
| 195 | GFP_KERNEL); | 194 | GFP_KERNEL); |
| 196 | if (!profile->freq_table) { | 195 | if (!devfreq->freq_table) |
| 197 | profile->max_state = 0; | | |
| 198 | return -ENOMEM; | 196 | return -ENOMEM; |
| 199 | } | | |
| 200 | | 197 | |
| 201 | for (i = 0, freq = 0; i < profile->max_state; i++, freq++) { | 198 | for (i = 0, freq = 0; i < devfreq->max_state; i++, freq++) { |
| 202 | opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq); | 199 | opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq); |
| 203 | if (IS_ERR(opp)) { | 200 | if (IS_ERR(opp)) { |
| 204 | devm_kfree(devfreq->dev.parent, profile->freq_table); | 201 | devm_kfree(devfreq->dev.parent, devfreq->freq_table); |
| 205 | profile->max_state = 0; | | |
| 206 | return PTR_ERR(opp); | 202 | return PTR_ERR(opp); |
| 207 | } | 203 | } |
| 208 | dev_pm_opp_put(opp); | 204 | dev_pm_opp_put(opp); |
| 209 | profile->freq_table[i] = freq; | 205 | devfreq->freq_table[i] = freq; |
| 210 | } | 206 | } |
| 211 | | 207 | |
| 212 | return 0; | 208 | return 0; |
| @@ -246,7 +242,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) · 33 unmodified lines |
| 246 | | 242 | |
| 247 | if (lev != prev_lev) { | 243 | if (lev != prev_lev) { |
| 248 | devfreq->stats.trans_table[ | 244 | devfreq->stats.trans_table[ |
| 249 | (prev_lev * devfreq->profile->max_state) + lev]++; | 245 | (prev_lev * devfreq->max_state) + lev]++; |
| 250 | devfreq->stats.total_trans++; | 246 | devfreq->stats.total_trans++; |
| 251 | } | 247 | } |
| 252 | | 248 | |
| @@ -835,6 +831,9 @@ struct devfreq *devfreq_add_device(struct device *dev, · 582 unmodified lines |
| 835 | if (err < 0) | 831 | if (err < 0) |
| 836 | goto err_dev; | 832 | goto err_dev; |
| 837 | mutex_lock(&devfreq->lock); | 833 | mutex_lock(&devfreq->lock); |
| | 834 | } else { |
| | 835 | devfreq->freq_table = devfreq->profile->freq_table; |
| | 836 | devfreq->max_state = devfreq->profile->max_state; |
| 838 | } | 837 | } |
| 839 | | 838 | |
| 840 | devfreq->scaling_min_freq = find_available_min_freq(devfreq); | 839 | devfreq->scaling_min_freq = find_available_min_freq(devfreq); |
| @@ -870,8 +869,8 @@ struct devfreq *devfreq_add_device(struct device *dev, · 29 unmodified lines |
| 870 | | 869 | |
| 871 | devfreq->stats.trans_table = devm_kzalloc(&devfreq->dev, | 870 | devfreq->stats.trans_table = devm_kzalloc(&devfreq->dev, |
| 872 | array3_size(sizeof(unsigned int), | 871 | array3_size(sizeof(unsigned int), |
| 873 | devfreq->profile->max_state, | 872 | devfreq->max_state, |
| 874 | devfreq->profile->max_state), | 873 | devfreq->max_state), |
| 875 | GFP_KERNEL); | 874 | GFP_KERNEL); |
| 876 | if (!devfreq->stats.trans_table) { | 875 | if (!devfreq->stats.trans_table) { |
| 877 | mutex_unlock(&devfreq->lock); | 876 | mutex_unlock(&devfreq->lock); |
| @@ -880,7 +879,7 @@ struct devfreq *devfreq_add_device(struct device *dev, · 2 unmodified lines |
| 880 | } | 879 | } |
| 881 | | 880 | |
| 882 | devfreq->stats.time_in_state = devm_kcalloc(&devfreq->dev, | 881 | devfreq->stats.time_in_state = devm_kcalloc(&devfreq->dev, |
| 883 | devfreq->profile->max_state, | 882 | devfreq->max_state, |
| 884 | sizeof(*devfreq->stats.time_in_state), | 883 | sizeof(*devfreq->stats.time_in_state), |
| 885 | GFP_KERNEL); | 884 | GFP_KERNEL); |
| 886 | if (!devfreq->stats.time_in_state) { | 885 | if (!devfreq->stats.time_in_state) { |
| @@ -932,8 +931,9 @@ struct devfreq *devfreq_add_device(struct device *dev, · 45 unmodified lines |
| 932 | err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START, | 931 | err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START, |
| 933 | NULL); | 932 | NULL); |
| 934 | if (err) { | 933 | if (err) { |
| 935 | dev_err(dev, "%s: Unable to start governor for the device\n", | 934 | dev_err_probe(dev, err, |
| 936 | __func__); | 935 | "%s: Unable to start governor for the device\n", |
| | 936 | __func__); |
| 937 | goto err_init; | 937 | goto err_init; |
| 938 | } | 938 | } |
| 939 | create_sysfs_files(devfreq, devfreq->governor); | 939 | create_sysfs_files(devfreq, devfreq->governor); |
| @@ -1665,9 +1665,9 @@ static ssize_t available_frequencies_show(struct device *d, · 725 unmodified lines |
| 1665 | | 1665 | |
| 1666 | mutex_lock(&df->lock); | 1666 | mutex_lock(&df->lock); |
| 1667 | | 1667 | |
| 1668 | for (i = 0; i < df->profile->max_state; i++) | 1668 | for (i = 0; i < df->max_state; i++) |
| 1669 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | 1669 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), |
| 1670 | "%lu ", df->profile->freq_table[i]); | 1670 | "%lu ", df->freq_table[i]); |
| 1671 | | 1671 | |
| 1672 | mutex_unlock(&df->lock); | 1672 | mutex_unlock(&df->lock); |
| 1673 | /* Truncate the trailing space */ | 1673 | /* Truncate the trailing space */ |
| @@ -1690,7 +1690,7 @@ static ssize_t trans_stat_show(struct device *dev, · 16 unmodified lines |
| 1690 | | 1690 | |
| 1691 | if (!df->profile) | 1691 | if (!df->profile) |
| 1692 | return -EINVAL; | 1692 | return -EINVAL; |
| 1693 | max_state = df->profile->max_state; | 1693 | max_state = df->max_state; |
| 1694 | | 1694 | |
| 1695 | if (max_state == 0) | 1695 | if (max_state == 0) |
| 1696 | return sprintf(buf, "Not Supported.\n"); | 1696 | return sprintf(buf, "Not Supported.\n"); |
| @@ -1707,19 +1707,17 @@ static ssize_t trans_stat_show(struct device *dev, · 10 unmodified lines |
| 1707 | len += sprintf(buf + len, " :"); | 1707 | len += sprintf(buf + len, " :"); |
| 1708 | for (i = 0; i < max_state; i++) | 1708 | for (i = 0; i < max_state; i++) |
| 1709 | len += sprintf(buf + len, "%10lu", | 1709 | len += sprintf(buf + len, "%10lu", |
| 1710 | df->profile->freq_table[i]); | 1710 | df->freq_table[i]); |
| 1711 | | 1711 | |
| 1712 | len += sprintf(buf + len, " time(ms)\n"); | 1712 | len += sprintf(buf + len, " time(ms)\n"); |
| 1713 | | 1713 | |
| 1714 | for (i = 0; i < max_state; i++) { | 1714 | for (i = 0; i < max_state; i++) { |
| 1715 | if (df->profile->freq_table[i] | 1715 | if (df->freq_table[i] == df->previous_freq) |
| 1716 | == df->previous_freq) { | | |
| 1717 | len += sprintf(buf + len, "*"); | 1716 | len += sprintf(buf + len, "*"); |
| 1718 | } else { | 1717 | else |
| 1719 | len += sprintf(buf + len, " "); | 1718 | len += sprintf(buf + len, " "); |
| 1720 | } | 1719 | |
| 1721 | len += sprintf(buf + len, "%10lu:", | 1720 | len += sprintf(buf + len, "%10lu:", df->freq_table[i]); |
| 1722 | df->profile->freq_table[i]); | | |
| 1723 | for (j = 0; j < max_state; j++) | 1721 | for (j = 0; j < max_state; j++) |
| 1724 | len += sprintf(buf + len, "%10u", | 1722 | len += sprintf(buf + len, "%10u", |
| 1725 | df->stats.trans_table[(i * max_state) + j]); | 1723 | df->stats.trans_table[(i * max_state) + j]); |
| @@ -1743,7 +1741,7 @@ static ssize_t trans_stat_store(struct device *dev, · 17 unmodified lines |
| 1743 | if (!df->profile) | 1741 | if (!df->profile) |
| 1744 | return -EINVAL; | 1742 | return -EINVAL; |
| 1745 | | 1743 | |
| 1746 | if (df->profile->max_state == 0) | 1744 | if (df->max_state == 0) |
| 1747 | return count; | 1745 | return count; |
| 1748 | | 1746 | |
| 1749 | err = kstrtoint(buf, 10, &value); | 1747 | err = kstrtoint(buf, 10, &value); |
| @@ -1751,11 +1749,11 @@ static ssize_t trans_stat_store(struct device *dev, · 1 unmodified line |
| 1751 | return -EINVAL; | 1749 | return -EINVAL; |
| 1752 | | 1750 | |
| 1753 | mutex_lock(&df->lock); | 1751 | mutex_lock(&df->lock); |
| 1754 | memset(df->stats.time_in_state, 0, (df->profile->max_state * | 1752 | memset(df->stats.time_in_state, 0, (df->max_state * |
| 1755 | sizeof(*df->stats.time_in_state))); | 1753 | sizeof(*df->stats.time_in_state))); |
| 1756 | memset(df->stats.trans_table, 0, array3_size(sizeof(unsigned int), | 1754 | memset(df->stats.trans_table, 0, array3_size(sizeof(unsigned int), |
| 1757 | df->profile->max_state, | 1755 | df->max_state, |
| 1758 | df->profile->max_state)); | 1756 | df->max_state)); |
| 1759 | df->stats.total_trans = 0; | 1757 | df->stats.total_trans = 0; |
| 1760 | df->stats.last_update = get_jiffies_64(); | 1758 | df->stats.last_update = get_jiffies_64(); |
| 1761 | mutex_unlock(&df->lock); | 1759 | mutex_unlock(&df->lock); |