Skip to content

Commit 46dd701

Browse files
cjd8jic23
authored andcommitted
iio: magnetometer: ak8975: check if gpiod read was successful
Add a check that ensures that valid data has been read from GPIOD. If not, log an error and return the negative read value. Suggested-by: Jonathan Cameron <jic23@kernel.org> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Reviewed-by: Maxwell Doose <m32285159@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent cfa30b4 commit 46dd701

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/iio/magnetometer/ak8975.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data,
658658
timeout_ms * USEC_PER_MSEC);
659659
if (ret)
660660
return ret;
661+
if (val < 0) {
662+
dev_err(&client->dev, "Error in reading GPIOD\n");
663+
return val;
664+
}
661665

662666
ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]);
663667
if (ret < 0)

0 commit comments

Comments
 (0)