public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: bu27034: Reinit regmap cache after reset
@ 2023-05-04  4:59 Matti Vaittinen
  2023-05-06 18:07 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Matti Vaittinen @ 2023-05-04  4:59 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Matti Vaittinen, Jonathan Cameron, Lars-Peter Clausen, linux-iio,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]

When BU27034 restores the default register values when SWRESET is
issued. This can cause register cache to be outdated.

Rebuild register cache after SWRESET.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: e52afbd61039 ("iio: light: ROHM BU27034 Ambient Light Sensor")

---
I noticed this was missing while writing driver for another light
sensor. The change is not tested in hardware as I don't have the BU27034
at my hands right now. Careful review would be highly appreciated.

This change is built on top of the
https://lore.kernel.org/all/ZFIw%2FKdApZe1euN8@fedora/
and could probably be squashed with it. Unfortunately I spotted the
missing cache re-init only after sending the fix linked above.

Please, let me know if you want me to squash and respin.
---
 drivers/iio/light/rohm-bu27034.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c
index 740ebd86b6e5..f85194fda6b0 100644
--- a/drivers/iio/light/rohm-bu27034.c
+++ b/drivers/iio/light/rohm-bu27034.c
@@ -1281,6 +1281,13 @@ static int bu27034_chip_init(struct bu27034_data *data)
 		return dev_err_probe(data->dev, ret, "Sensor reset failed\n");
 
 	msleep(1);
+
+	ret = regmap_reinit_cache(data->regmap, &bu27034_regmap);
+	if (ret) {
+		dev_err(data->dev, "Failed to reinit reg cache\n");
+		return ret;
+	}
+
 	/*
 	 * Read integration time here to ensure it is in regmap cache. We do
 	 * this to speed-up the int-time acquisition in the start of the buffer
-- 
2.40.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-07 15:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-04  4:59 [PATCH] iio: bu27034: Reinit regmap cache after reset Matti Vaittinen
2023-05-06 18:07 ` Jonathan Cameron
2023-05-07 10:16   ` Matti Vaittinen
2023-05-07 13:36     ` Jonathan Cameron
2023-05-07 15:45       ` Matti Vaittinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox