Hey Andrey, Thanks for the review :) see some comments below. >> + /* Don't read anything on error or if 0 bytes were requested */ >> + if (size > 0) { >> + adapter = i2c_get_adapter(i2c_read_req->bus); >> + if (!adapter) { >> + printf("ratp i2c read ignored: i2c bus %u not found\n", i2c_read_req->bus); >> + ret = -ENODEV; >> + goto out; >> + } >> + >> + client.adapter = adapter; >> + client.addr = i2c_read_req->addr; >> + >> + if (i2c_read_req->flags & I2C_FLAG_MASTER_MODE) { >> + ret = i2c_master_recv(&client, i2c_read_rsp->buffer, size); >> + } else { >> + ret = i2c_read_reg(&client, reg | wide, i2c_read_rsp->buffer, size); >> + } >> + if (ret != size) { >> + printf("ratp i2c read ignored: not all bytes read (%u < %u)\n", ret, size); >> + ret = -EIO; >> + goto out; >> + } >> + ret = 0; >> + } >> + >> +out: >> + if (ret != 0) { >> + i2c_read_rsp->data_size = 0; >> + i2c_read_rsp->errno = cpu_to_be32(ret); >> + i2c_read_rsp_len = sizeof(*i2c_read_rsp); >> + } else { >> + i2c_read_rsp->data_size = cpu_to_be16(size); >> + i2c_read_rsp->errno = 0; >> + } >> + > > It looks like you can move: > > i2c_read_rsp->data_size = cpu_to_be16(size); > i2c_read_rsp->errno = cpu_to_be32(ret); > > outside of if since it should work as intended for both cases (size is > 0 if ret != 0). > Don't think I can do that. In the if (size > 0) {} just a bit above, size is not modified but ret may become an error. We do want to make sure 0 is returned as size when there is an error, so cannot move it outside the if() as you suggest here. -- Aleksander https://aleksander.es _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox