sensors/lis2dh12: Minor change to also support lis2dk10
Change CTRL_REG0 register access to read-modify-write so that
reserved bits are not modified. This allows the driver to be
used with lis2dk10.
@@ -640,13 +640,20 @@ int
lis2dh12_pull_up_disc(struct sensor_itf *itf, uint8_t disconnect)
{
uint8_t reg;
+ int rc;
- reg = 0;
+ rc = lis2dh12_readlen(itf, LIS2DH12_REG_CTRL_REG0, &reg, 1);
+ if (rc) {
+ goto err;
+ }
+
+ reg &= ~LIS2DH12_CTRL_REG0_SPD;
+ reg |= (disconnect ? LIS2DH12_CTRL_REG0_SPD : 0);
- reg |= ((disconnect ? LIS2DH12_CTRL_REG0_SPD : 0) |
- LIS2DH12_CTRL_REG0_CORR_OP);
+ rc = lis2dh12_writelen(itf, LIS2DH12_REG_CTRL_REG0, &reg, 1);
- return lis2dh12_writelen(itf, LIS2DH12_REG_CTRL_REG0, &reg, 1);
+err:
+ return rc;
}
/**
