regulator: twl: make twl_info tables const
authorArnd Bergmann <arnd@arndb.de>
Tue, 14 Aug 2012 12:41:50 +0000 (12:41 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 28 Aug 2012 18:00:28 +0000 (11:00 -0700)
commit0ffff5a60fdd7455c83855ee788a8aae9a79aab4
tree5a75585df8ecc9bbdf916cae20b70bee4d3a377d
parentf9cfbde723ba89b7bf7d1ec0b8adeea0c3c4a091
regulator: twl: make twl_info tables const

I currently carry the series to make of_device_id->data const in the
arm-soc tree, which fixes a number of issues, but leaves one new
compiler warning about the twl-regulator driver:

drivers/regulator/twl-regulator.c: In function 'twlreg_probe':
drivers/regulator/twl-regulator.c:1130:8: warning: assignment discards 'const'
qualifier from pointer target type [enabled by default]
drivers/regulator/twl-regulator.c:1139:9: warning: assignment discards 'const'
qualifier from pointer target type [enabled by default]

The warning indicates that the driver takes a static table with
initialization data for each regulator, modifies the data in place
and passes a pointer to that structure to the regulator_register
function. This is probably ok because a system contains only one
instance of each regulator, but it's still bad style because any
driver should be written to support multiple instances of the same
hardware.

This patch changes the code to dynamically allocate the memory
we pass to the regulator core so the table can be constant.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/twl-regulator.c