On Thu, Oct 10, 2024 at 11:00:22PM +0200, vamoirid wrote: > From: Vasileios Amoiridis <vassilisamir@xxxxxxxxx> > > Refactorize the set_mode() function to use an external enum that > describes the possible modes of the BME680 device instead of using > true/false variables for selecting SLEEPING/FORCED mode. ... > - if (mode) { > - ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, > - BME680_MODE_MASK, BME680_MODE_FORCED); > - if (ret < 0) > - dev_err(dev, "failed to set forced mode\n"); > - > - } else { > - ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, > - BME680_MODE_MASK, BME680_MODE_SLEEP); > - if (ret < 0) > - dev_err(dev, "failed to set sleep mode\n"); > - > + switch (mode) { > + case BME680_SLEEP: > + case BME680_FORCED: > + break; > + default: > + return -EINVAL; > } > > + ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, > + BME680_MODE_MASK, mode); > + if (ret < 0) > + dev_err(dev, "failed to set ctrl_meas register\n"); This is an information loss. You shuld probably still have a value of mode to be printed. -- With Best Regards, Andy Shevchenko