]>
Commit | Line | Data |
---|---|---|
112fe2e3 GKH |
1 | From c53403a37cf083ce85da720f18918f73580d0064 Mon Sep 17 00:00:00 2001 |
2 | From: Joe Perches <joe@perches.com> | |
3 | Date: Mon, 18 May 2015 10:01:03 -0700 | |
4 | Subject: regulator: max77686: fix gpio_enabled shift wrapping bug | |
5 | ||
6 | From: Joe Perches <joe@perches.com> | |
7 | ||
8 | commit c53403a37cf083ce85da720f18918f73580d0064 upstream. | |
9 | ||
10 | The code should handle more than 32 bits here because "id" | |
11 | can be a value up to MAX77686_REGULATORS (currently 34). | |
12 | ||
13 | Convert the gpio_enabled type to DECLARE_BITMAP and use | |
14 | test_bit/set_bit. | |
15 | ||
16 | Fixes: 3307e9025d29 ("regulator: max77686: Add GPIO control") | |
17 | Reported-by: Dan Carpenter <dan.carpenter@oracle.com> | |
18 | Signed-off-by: Joe Perches <joe@perches.com> | |
19 | Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> | |
20 | Signed-off-by: Mark Brown <broonie@kernel.org> | |
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
22 | ||
23 | --- | |
24 | drivers/regulator/max77686.c | 6 +++--- | |
25 | 1 file changed, 3 insertions(+), 3 deletions(-) | |
26 | ||
27 | --- a/drivers/regulator/max77686.c | |
28 | +++ b/drivers/regulator/max77686.c | |
29 | @@ -88,7 +88,7 @@ enum max77686_ramp_rate { | |
30 | }; | |
31 | ||
32 | struct max77686_data { | |
33 | - u64 gpio_enabled:MAX77686_REGULATORS; | |
34 | + DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); | |
35 | ||
36 | /* Array indexed by regulator id */ | |
37 | unsigned int opmode[MAX77686_REGULATORS]; | |
38 | @@ -121,7 +121,7 @@ static unsigned int max77686_map_normal_ | |
39 | case MAX77686_BUCK8: | |
40 | case MAX77686_BUCK9: | |
41 | case MAX77686_LDO20 ... MAX77686_LDO22: | |
42 | - if (max77686->gpio_enabled & (1 << id)) | |
43 | + if (test_bit(id, max77686->gpio_enabled)) | |
44 | return MAX77686_GPIO_CONTROL; | |
45 | } | |
46 | ||
47 | @@ -277,7 +277,7 @@ static int max77686_of_parse_cb(struct d | |
48 | } | |
49 | ||
50 | if (gpio_is_valid(config->ena_gpio)) { | |
51 | - max77686->gpio_enabled |= (1 << desc->id); | |
52 | + set_bit(desc->id, max77686->gpio_enabled); | |
53 | ||
54 | return regmap_update_bits(config->regmap, desc->enable_reg, | |
55 | desc->enable_mask, |