linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] regulator: max77686: fix a shift wrapping bug
@ 2015-05-15  9:25 Dan Carpenter
  2015-05-15 10:12 ` Krzysztof Kozlowski
  2015-05-15 10:19 ` Chanwoo Choi
  0 siblings, 2 replies; 9+ messages in thread
From: Dan Carpenter @ 2015-05-15  9:25 UTC (permalink / raw)
  To: Chanwoo Choi, Krzysztof Kozlowski
  Cc: Liam Girdwood, Mark Brown, linux-kernel, kernel-janitors

We need to be able to handle more than 32 bits here because "id" can go
up to MAX77686_BUCK9 (34).  ->gpio_enabled is a u64 so that's fine
already.

Fixes: 3307e9025d29 ('regulator: max77686: Add GPIO control')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 23b7c06..59b3210 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -121,7 +121,7 @@ static unsigned int max77686_map_normal_mode(struct max77686_data *max77686,
 	case MAX77686_BUCK8:
 	case MAX77686_BUCK9:
 	case MAX77686_LDO20 ... MAX77686_LDO22:
-		if (max77686->gpio_enabled & (1 << id))
+		if (max77686->gpio_enabled & (1ULL << id))
 			return MAX77686_GPIO_CONTROL;
 	}
 
@@ -277,7 +277,7 @@ static int max77686_of_parse_cb(struct device_node *np,
 	}
 
 	if (gpio_is_valid(config->ena_gpio)) {
-		max77686->gpio_enabled |= (1 << desc->id);
+		max77686->gpio_enabled |= (1ULL << desc->id);
 
 		return regmap_update_bits(config->regmap, desc->enable_reg,
 					  desc->enable_mask,

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-05-20 18:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15  9:25 [patch] regulator: max77686: fix a shift wrapping bug Dan Carpenter
2015-05-15 10:12 ` Krzysztof Kozlowski
2015-05-15 10:19 ` Chanwoo Choi
2015-05-15 17:10   ` Joe Perches
2015-05-16  0:27     ` Krzysztof Kozlowski
2015-05-18  9:22     ` Dan Carpenter
2015-05-18 17:01   ` [PATCH] regulator: max77686: fix gpio_enabled " Joe Perches
2015-05-19  0:16     ` Krzysztof Kozlowski
2015-05-20 18:10     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).