iio: bu27034: Ensure reset is written
authorMatti Vaittinen <mazziesaccount@gmail.com>
Mon, 8 May 2023 11:01:25 +0000 (14:01 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 13 May 2023 18:22:01 +0000 (19:22 +0100)
commitd049151adde4ec17392592d145e94f0086f8ee80
treef36ad79489cf23135483e408c812e79825ff130b
parenta146eccb68be161ae9eab5f3f68bb0ed7c0fbaa8
iio: bu27034: Ensure reset is written

The reset bit must be always written to the hardware no matter what value
is in a cache or register. Ensure this by using regmap_write_bits()
instead of the regmap_update_bits(). Furthermore, the SWRESET bit may be
self-clearing, so mark the SYSTEM_CONTROL register volatile to guarantee
we do also read the right state - should we ever need to read it.

Finally, writing the SWRESET bit will restore the default register
values. This can cause register cache to be outdated if there are any
register values cached.

Rebuild register cache after SWRESET and use regmap_update_bits() when
performing the reset.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: e52afbd61039 ("iio: light: ROHM BU27034 Ambient Light Sensor")
Link: https://lore.kernel.org/r/ZFjWhbfuN5XcKty+@fedora
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/rohm-bu27034.c