[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4fd9fd1afb7b7f2dab029da80e82824f54333a02.camel@gmail.com>
Date: Mon, 04 Jul 2022 09:14:00 +0200
From: Angel Iglesias <ang.iglesiasg@...il.com>
To: Dan Carpenter <dan.carpenter@...cle.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 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, ®);
> > + 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, ®);
> > + 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