Skip to content

Commit acea356

Browse files
cjd8jic23
authored andcommitted
iio: magnetometer: ak8975: fix wrong errno on return
The driver currently returns -EINVAL on polling timeout instead of -ETIMEDOUT. Replace return code for -ETIMEDOUT and remove unnecessary error message as -ETIMEDOUT is a standard POSIX error. Also replace instances of -EINVAL in comments. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 833ca88 commit acea356

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

drivers/iio/magnetometer/ak8975.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,8 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data)
662662
break;
663663
timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
664664
}
665-
if (!timeout_ms) {
666-
dev_err(&client->dev, "Conversion timeout happened\n");
667-
return -EINVAL;
668-
}
665+
if (!timeout_ms)
666+
return -ETIMEDOUT;
669667

670668
ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]);
671669
if (ret < 0)
@@ -695,15 +693,13 @@ static int wait_conversion_complete_polled(struct ak8975_data *data)
695693
break;
696694
timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
697695
}
698-
if (!timeout_ms) {
699-
dev_err(&client->dev, "Conversion timeout happened\n");
700-
return -EINVAL;
701-
}
696+
if (!timeout_ms)
697+
return -ETIMEDOUT;
702698

703699
return read_status;
704700
}
705701

706-
/* Returns 0 if the end of conversion interrupt occurred or -ETIME otherwise */
702+
/* Returns 0 if the end of conversion interrupt occurred or -ETIMEDOUT otherwise */
707703
static int wait_conversion_complete_interrupt(struct ak8975_data *data)
708704
{
709705
int ret;
@@ -713,7 +709,7 @@ static int wait_conversion_complete_interrupt(struct ak8975_data *data)
713709
AK8975_DATA_READY_TIMEOUT);
714710
clear_bit(0, &data->flags);
715711

716-
return ret > 0 ? 0 : -ETIME;
712+
return ret > 0 ? 0 : -ETIMEDOUT;
717713
}
718714

719715
static int ak8975_start_read_axis(struct ak8975_data *data,

0 commit comments

Comments
 (0)