[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zwj3tFd549K6ahbY@smile.fi.intel.com>
Date: Fri, 11 Oct 2024 13:02:28 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: vamoirid <vassilisamir@...il.com>
Cc: jic23@...nel.org, lars@...afoo.de, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, anshulusr@...il.com, gustavograzs@...il.com,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 05/13] iio: chemical: bme680: refactorize set_mode()
mode
On Thu, Oct 10, 2024 at 11:00:22PM +0200, vamoirid wrote:
> From: Vasileios Amoiridis <vassilisamir@...il.com>
>
> 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
Powered by blists - more mailing lists