lkml.org 
[lkml]   [2012]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] regmap: Fix the size calculation for map->format.buf_size
From
Date
On Thu, 2012-05-31 at 21:10 -0300, Fabio Estevam wrote:
> 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.
[]
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
[]
> @@ -246,11 +246,11 @@ struct regmap *regmap_init(struct device *dev,
> map->lock = regmap_lock_mutex;
> map->unlock = regmap_unlock_mutex;
> }
> - map->format.buf_size = (config->reg_bits + config->val_bits) / 8;
> map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
> map->format.pad_bytes = config->pad_bits / 8;
> map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
> - map->format.buf_size += map->format.pad_bytes;
> + map->format.buf_size = DIV_ROUND_UP(config->reg_bits +
> + config->val_bits + config->pad_bits, 8);
> map->reg_shift = config->pad_bits % 8;

s/8/BITS_PER_BYTE/ ?




\
 
 \ /
  Last update: 2012-06-01 02:41    [W:0.059 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site