From: Dan Carpenter <dan.carpenter@oracle.com>
To: Angel Iglesias <ang.iglesiasg@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Paul Cercueil <paul@crapouillou.net>,
Ulf Hansson <ulf.hansson@linaro.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/5] iio: pressure: bmp280: Add support for BMP380 sensor family
Date: Mon, 4 Jul 2022 07:52:29 +0300 [thread overview]
Message-ID: <20220704045229.GT11460@kadam> (raw)
In-Reply-To: <20220704003219.208409-1-ang.iglesiasg@gmail.com>
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
next prev parent reply other threads:[~2022-07-04 4:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 0:32 [PATCH v2 4/5] iio: pressure: bmp280: Add support for BMP380 sensor family Angel Iglesias
2022-07-04 2:01 ` kernel test robot
2022-07-04 2:01 ` kernel test robot
2022-07-04 4:52 ` Dan Carpenter [this message]
2022-07-04 7:14 ` Angel Iglesias
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220704045229.GT11460@kadam \
--to=dan.carpenter@oracle.com \
--cc=ang.iglesiasg@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=rafael.j.wysocki@intel.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox