diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2016-01-25 10:45:48 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-01-27 17:23:54 -0500 |
| commit | b331bc20d9281213f7fb67912638e0fb5baeb324 (patch) | |
| tree | e55d1bfa61250b0b11b55f586dc70e5240ccaedb | |
| parent | fb2a24a1c6457d21df9fae0dd66b20c63ba56077 (diff) | |
cpufreq: cpufreq-dt: avoid uninitialized variable warnings:
gcc warns quite a bit about values returned from allocate_resources()
in cpufreq-dt.c:
cpufreq-dt.c: In function 'cpufreq_init':
cpufreq-dt.c:327:6: error: 'cpu_dev' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cpufreq-dt.c:197:17: note: 'cpu_dev' was declared here
cpufreq-dt.c:376:2: error: 'cpu_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cpufreq-dt.c:199:14: note: 'cpu_clk' was declared here
cpufreq-dt.c: In function 'dt_cpufreq_probe':
cpufreq-dt.c:461:2: error: 'cpu_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cpufreq-dt.c:447:14: note: 'cpu_clk' was declared here
The problem is that it's slightly hard for gcc to follow return
codes across PTR_ERR() calls.
This patch uses explicit assignments to the "ret" variable to make
it easier for gcc to verify that the code is actually correct,
without the need to add a bogus initialization.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
| -rw-r--r-- | drivers/cpufreq/cpufreq-dt.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 9bc37c437874..0ca74d070058 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c | |||
| @@ -142,15 +142,16 @@ static int allocate_resources(int cpu, struct device **cdev, | |||
| 142 | 142 | ||
| 143 | try_again: | 143 | try_again: |
| 144 | cpu_reg = regulator_get_optional(cpu_dev, reg); | 144 | cpu_reg = regulator_get_optional(cpu_dev, reg); |
| 145 | if (IS_ERR(cpu_reg)) { | 145 | ret = PTR_ERR_OR_ZERO(cpu_reg); |
| 146 | if (ret) { | ||
| 146 | /* | 147 | /* |
| 147 | * If cpu's regulator supply node is present, but regulator is | 148 | * If cpu's regulator supply node is present, but regulator is |
| 148 | * not yet registered, we should try defering probe. | 149 | * not yet registered, we should try defering probe. |
| 149 | */ | 150 | */ |
| 150 | if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { | 151 | if (ret == -EPROBE_DEFER) { |
| 151 | dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", | 152 | dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", |
| 152 | cpu); | 153 | cpu); |
| 153 | return -EPROBE_DEFER; | 154 | return ret; |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | /* Try with "cpu-supply" */ | 157 | /* Try with "cpu-supply" */ |
| @@ -159,18 +160,16 @@ try_again: | |||
| 159 | goto try_again; | 160 | goto try_again; |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n", | 163 | dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret); |
| 163 | cpu, PTR_ERR(cpu_reg)); | ||
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | cpu_clk = clk_get(cpu_dev, NULL); | 166 | cpu_clk = clk_get(cpu_dev, NULL); |
| 167 | if (IS_ERR(cpu_clk)) { | 167 | ret = PTR_ERR_OR_ZERO(cpu_clk); |
| 168 | if (ret) { | ||
| 168 | /* put regulator */ | 169 | /* put regulator */ |
| 169 | if (!IS_ERR(cpu_reg)) | 170 | if (!IS_ERR(cpu_reg)) |
| 170 | regulator_put(cpu_reg); | 171 | regulator_put(cpu_reg); |
| 171 | 172 | ||
| 172 | ret = PTR_ERR(cpu_clk); | ||
| 173 | |||
| 174 | /* | 173 | /* |
| 175 | * If cpu's clk node is present, but clock is not yet | 174 | * If cpu's clk node is present, but clock is not yet |
| 176 | * registered, we should try defering probe. | 175 | * registered, we should try defering probe. |
