regmap: mmio: Fix the bug of 'offset' value parsing.
authorXiubo Li <Li.Xiubo@freescale.com>
Wed, 2 Apr 2014 02:20:17 +0000 (10:20 +0800)
committerMark Brown <broonie@linaro.org>
Mon, 14 Apr 2014 15:58:54 +0000 (16:58 +0100)
commit88cb32c657ed13dc29561d0f4aa154e0fd25759f
treeb1e737c0e70e8c1bc3a7ed9dc690a12fa99d8ad0
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5
regmap: mmio: Fix the bug of 'offset' value parsing.

'offset = *(u32 *)reg;'
This will be okey for 32/64-bits register device, but for 8/16-bits
register ones, the 'offset' value will overflow, for example:

The IMX2 Watchdog, whose registers and values are all 16-bits:

If the IO base virtual address is ctx->regs = 0x888c0000, and the now
doing the 0x00 register accessing:
Using 'offset = *(u32 *)reg' the offset value will possiblly be 0x77310000,
Using 'offset = *(u16 *)reg' the offset value will be 0x0000.

In the regmap_mmio_gather_write(), ctx->regs + 0x7731000 will be 0xffbd0000,
but actually it should be ctx->regs + 0x0000 = 0x888c0000.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/regmap/regmap-mmio.c