From 7cf6d75a1120253007b375a757fa772131827933 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 20 Dec 2022 15:37:22 -0800 Subject: [PATCH] drivers/sensor: lsm6dso: Move interrupt config to after chip reset The initialization code would configure the lsm6dso interrupt, then configure the rest of the chip. The chip init includes a reset that would undo the register setting done during interrupt configuration. It's also not a good idea to enable the interrupt on the SoC when the lsm6dso has not yet been reset or configured. It might be generating interrupts. The lsm6dso has no hardware reset line, so it will not be reset on reboot unless a power cycle is involved. Signed-off-by: Trent Piepho --- drivers/sensor/lsm6dso/lsm6dso.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/sensor/lsm6dso/lsm6dso.c b/drivers/sensor/lsm6dso/lsm6dso.c index 9a39d7f93c6..80ba9fd5e85 100644 --- a/drivers/sensor/lsm6dso/lsm6dso.c +++ b/drivers/sensor/lsm6dso/lsm6dso.c @@ -823,6 +823,11 @@ static int lsm6dso_init(const struct device *dev) LOG_INF("Initialize device %s", dev->name); data->dev = dev; + if (lsm6dso_init_chip(dev) < 0) { + LOG_DBG("failed to initialize chip"); + return -EIO; + } + #ifdef CONFIG_LSM6DSO_TRIGGER if (cfg->trig_enabled) { if (lsm6dso_init_interrupt(dev) < 0) { @@ -832,11 +837,6 @@ static int lsm6dso_init(const struct device *dev) } #endif - if (lsm6dso_init_chip(dev) < 0) { - LOG_DBG("failed to initialize chip"); - return -EIO; - } - #ifdef CONFIG_LSM6DSO_SENSORHUB data->shub_inited = true; if (lsm6dso_shub_init(dev) < 0) {