Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
d049151a a146eccb

+11 -1
+11 -1
drivers/iio/light/rohm-bu27034.c
··· 231 231 232 232 static const struct regmap_range bu27034_volatile_ranges[] = { 233 233 { 234 + .range_min = BU27034_REG_SYSTEM_CONTROL, 235 + .range_max = BU27034_REG_SYSTEM_CONTROL, 236 + }, { 234 237 .range_min = BU27034_REG_MODE_CONTROL4, 235 238 .range_max = BU27034_REG_MODE_CONTROL4, 236 239 }, { ··· 1275 1272 int ret, sel; 1276 1273 1277 1274 /* Reset */ 1278 - ret = regmap_update_bits(data->regmap, BU27034_REG_SYSTEM_CONTROL, 1275 + ret = regmap_write_bits(data->regmap, BU27034_REG_SYSTEM_CONTROL, 1279 1276 BU27034_MASK_SW_RESET, BU27034_MASK_SW_RESET); 1280 1277 if (ret) 1281 1278 return dev_err_probe(data->dev, ret, "Sensor reset failed\n"); 1282 1279 1283 1280 msleep(1); 1281 + 1282 + ret = regmap_reinit_cache(data->regmap, &bu27034_regmap); 1283 + if (ret) { 1284 + dev_err(data->dev, "Failed to reinit reg cache\n"); 1285 + return ret; 1286 + } 1287 + 1284 1288 /* 1285 1289 * Read integration time here to ensure it is in regmap cache. We do 1286 1290 * this to speed-up the int-time acquisition in the start of the buffer