diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2012-05-31 20:10:30 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-03 08:14:01 -0400 |
commit | 5494a98f451d59f6c05f3f688510e0832445f661 (patch) | |
tree | 4df15dff1a3f3c490999c733aff7732ee968a2f9 /drivers | |
parent | bfaa25f33425db16a942b7c71e396a47581c646d (diff) |
regmap: Fix the size calculation for map->format.buf_size
The word to be transmitted/received via regmap is composed by the following
parts:
config->reg_bits
config->val_bits
config->pad_bits
,so the total size should be calculated by summing up the number of bits of
each element and using a DIV_ROUND_UP to return the number of bytes.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/regmap/regmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 2aa076e61367..04b48027c213 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -246,11 +246,11 @@ struct regmap *regmap_init(struct device *dev, | |||
246 | map->lock = regmap_lock_mutex; | 246 | map->lock = regmap_lock_mutex; |
247 | map->unlock = regmap_unlock_mutex; | 247 | map->unlock = regmap_unlock_mutex; |
248 | } | 248 | } |
249 | map->format.buf_size = (config->reg_bits + config->val_bits) / 8; | ||
250 | map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8); | 249 | map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8); |
251 | map->format.pad_bytes = config->pad_bits / 8; | 250 | map->format.pad_bytes = config->pad_bits / 8; |
252 | map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8); | 251 | map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8); |
253 | map->format.buf_size += map->format.pad_bytes; | 252 | map->format.buf_size = DIV_ROUND_UP(config->reg_bits + |
253 | config->val_bits + config->pad_bits, 8); | ||
254 | map->reg_shift = config->pad_bits % 8; | 254 | map->reg_shift = config->pad_bits % 8; |
255 | if (config->reg_stride) | 255 | if (config->reg_stride) |
256 | map->reg_stride = config->reg_stride; | 256 | map->reg_stride = config->reg_stride; |