mac80211: fix spurious disconnections with powersave clients
[openwrt/openwrt.git] / target / linux / sunxi / patches-4.9 / 0041-pinctrl-sunxi-fix-theoretical-uninitialized-variable.patch
1 From d8a22212737314cc02692cc90eda7d844fa20257 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Wed, 16 Nov 2016 15:18:18 +0100
4 Subject: pinctrl: sunxi: fix theoretical uninitialized variable access
5
6 gcc warns about a way that it could use an uninitialized variable:
7
8 drivers/pinctrl/sunxi/pinctrl-sunxi.c: In function 'sunxi_pinctrl_init':
9 drivers/pinctrl/sunxi/pinctrl-sunxi.c:1191:8: error: 'best_div' may be used uninitialized in this function [-Werror=maybe-uninitialized]
10
11 This cannot really happen except if 'freq' is UINT_MAX and 'clock' is
12 zero, and both of these are forbidden. To shut up the warning anyway,
13 this changes the logic to initialize the return code to the first
14 divider value before looking at the others.
15
16 Fixes: 7c926492d38a ("pinctrl: sunxi: Add support for interrupt debouncing")
17 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
18 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
19 ---
20 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 7 +++++--
21 1 file changed, 5 insertions(+), 2 deletions(-)
22
23 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
24 +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
25 @@ -1125,10 +1125,13 @@ static int sunxi_pinctrl_build_state(str
26 static int sunxi_pinctrl_get_debounce_div(struct clk *clk, int freq, int *diff)
27 {
28 unsigned long clock = clk_get_rate(clk);
29 - unsigned int best_diff = ~0, best_div;
30 + unsigned int best_diff, best_div;
31 int i;
32
33 - for (i = 0; i < 8; i++) {
34 + best_diff = abs(freq - clock);
35 + best_div = 0;
36 +
37 + for (i = 1; i < 8; i++) {
38 int cur_diff = abs(freq - (clock >> i));
39
40 if (cur_diff < best_diff) {