[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220704045229.GT11460@kadam>
Date: Mon, 4 Jul 2022 07:52:29 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Angel Iglesias <ang.iglesiasg@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Paul Cercueil <paul@...pouillou.net>,
Ulf Hansson <ulf.hansson@...aro.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/5] iio: pressure: bmp280: Add support for BMP380
sensor family
On Mon, Jul 04, 2022 at 02:32:09AM +0200, Angel Iglesias wrote:
> +/* Send a command to BMP3XX sensors */
> +static int bmp380_cmd(struct bmp280_data *data, u8 cmd)
> +{
> + int ret;
> + unsigned int reg;
> +
> + /* check if device is ready to process a command */
> + ret = regmap_read(data->regmap, BMP380_REG_STATUS, ®);
> + if (ret) {
> + dev_err(data->dev, "failed to read error register\n");
> + return ret;
> + }
> + if (!(cmd & BMP380_STATUS_CMD_RDY_MASK)) {
This looks like it should be "reg" instead of command?
> + dev_err(data->dev, "device is not ready to accept commands\n");
> + return -EBUSY;
> + }
> +
> + /* send command to process */
> + ret = regmap_write(data->regmap, BMP380_REG_CMD, cmd);
> + if (ret) {
> + dev_err(data->dev, "failed to send command to device\n");
> + return ret;
> + }
> + /* wait for 2ms for command to be proccessed */
> + usleep_range(data->start_up_time, data->start_up_time + 100);
> + /* check for command processing error */
> + ret = regmap_read(data->regmap, BMP380_REG_ERROR, ®);
> + if (ret) {
> + dev_err(data->dev, "error reading ERROR reg\n");
> + return ret;
> + }
> + if (reg & BMP380_ERR_CMD_MASK) {
> + dev_err(data->dev, "error processing command 0x%X\n", cmd);
> + return -EINVAL;
> + }
> + dev_dbg(data->dev, "Command 0x%X proccessed successfully\n", cmd);
> +
> + return 0;
> +}
regards,
dan carpenter
Powered by blists - more mailing lists