mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Angel Iglesias <ang.iglesiasg@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.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, 04 Jul 2022 09:14:00 +0200	[thread overview]
Message-ID: <4fd9fd1afb7b7f2dab029da80e82824f54333a02.camel@gmail.com> (raw)
In-Reply-To: <20220704045229.GT11460@kadam>

On lun, 2022-07-04 at 07:52 +0300, Dan Carpenter wrote:
> 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, &reg);
> > +       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?

Yes, it should. Thanks for the catch!

> > +               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, &reg);
> > +       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


      reply	other threads:[~2022-07-04  7:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04  0:32 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
2022-07-04  7:14   ` Angel Iglesias [this message]

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=4fd9fd1afb7b7f2dab029da80e82824f54333a02.camel@gmail.com \
    --to=ang.iglesiasg@gmail.com \
    --cc=dan.carpenter@oracle.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

Powered by JetHome