On Mon, Aug 03, 2015 at 01:21:08AM -0700, Matt Ranostay wrote: > On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@xxxxxxxxxx> wrote: > > On Sun, 2 Aug 2015, Matt Ranostay wrote: > > > >> + > >> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg) > >> +{ > >> + struct i2c_client *client = data->client; > >> + int tries = 10; > >> + int ret; > >> + > >> + /* start sample */ > >> + ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE); > >> + if (ret < 0) { > >> + dev_err(&client->dev, "cannot send start measurement command"); > >> + return ret; > >> + } > >> + > >> + while (tries--) { > >> + usleep_range(1000, 2000); > >> + > >> + ret = lidar_read_byte(data, LIDAR_REG_STATUS); > >> + if (ret < 0) > >> + break; > >> + > >> + /* return 0 since laser is likely pointed out of range */ > >> + if (ret & LIDAR_REG_STATUS_INVALID) { > >> + *reg = 0; > >> + ret = 0; > >> + break; > >> + } > >> + > >> + /* sample ready to read */ > >> + if (!(ret & LIDAR_REG_STATUS_READY)) { > >> + ret = lidar_read_measurement(data, reg); > >> + break; > >> + } > >> + } > >> + > > > > what happens when the timeout occurs? > > no error code is set > > Ah yes it should return an error code. Would a -EIO be a logical choice? > I would think -ETIMEDOUT to make more sense here. -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html