Skip to content

Commit 5b9202b

Browse files
arndbAlex Shi
authored andcommitted
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> (cherry picked from commit b331bc20d9281213f7fb67912638e0fb5baeb324) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 59dfbb9 commit 5b9202b

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/cpufreq/cpufreq-dt.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,16 @@ static int allocate_resources(int cpu, struct device **cdev,
141141

142142
try_again:
143143
cpu_reg = regulator_get_optional(cpu_dev, reg);
144-
if (IS_ERR(cpu_reg)) {
144+
ret = PTR_ERR_OR_ZERO(cpu_reg);
145+
if (ret) {
145146
/*
146147
* If cpu's regulator supply node is present, but regulator is
147148
* not yet registered, we should try defering probe.
148149
*/
149-
if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) {
150+
if (ret == -EPROBE_DEFER) {
150151
dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n",
151152
cpu);
152-
return -EPROBE_DEFER;
153+
return ret;
153154
}
154155

155156
/* Try with "cpu-supply" */
@@ -158,18 +159,16 @@ static int allocate_resources(int cpu, struct device **cdev,
158159
goto try_again;
159160
}
160161

161-
dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n",
162-
cpu, PTR_ERR(cpu_reg));
162+
dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret);
163163
}
164164

165165
cpu_clk = clk_get(cpu_dev, NULL);
166-
if (IS_ERR(cpu_clk)) {
166+
ret = PTR_ERR_OR_ZERO(cpu_clk);
167+
if (ret) {
167168
/* put regulator */
168169
if (!IS_ERR(cpu_reg))
169170
regulator_put(cpu_reg);
170171

171-
ret = PTR_ERR(cpu_clk);
172-
173172
/*
174173
* If cpu's clk node is present, but clock is not yet
175174
* registered, we should try defering probe.

0 commit comments

Comments
 (0)