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