Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5494a98f authored by Fabio Estevam's avatar Fabio Estevam Committed by Mark Brown
Browse files

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: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent bfaa25f3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
	if (config->reg_stride)
		map->reg_stride = config->reg_stride;