Attention is currently required from: Paul Menzel, Yu-Ping Wu. Felix Held has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/59539 )
Change subject: soc/mediatek/i2c: Return negative values on error ......................................................................
Patch Set 3:
(3 comments)
Patchset:
PS2:
Done. […]
it's usually that a return value of 0 means success and a negative value means failure and if it's just success or some failure the return value won't be > 0, so that will also work. I find that the code gets easier to understand when re-typing the return value of platform_i2c_transfer from int to enum cb_err; that will be a rather big rework though, since it will require changing the return type for basically all common I2C functions. CB:58494 from the x86 mp_init rework might be worth a look
File src/soc/mediatek/common/i2c.c:
https://review.coreboot.org/c/coreboot/+/59539/comment/5924505d_cf5e0849 PS3, Line 282: return ret; looked at the definitions that get assigned to ret in the different cases and ret will always be a positive number
https://review.coreboot.org/c/coreboot/+/59539/comment/293ef85c_bd45076f PS3, Line 317: if (ret < 0) since mtk_i2c_transfer will return 0 or positive, this condition will always be false. easiest way would probably be to only change the break in the if (ret) case to a return -1 and the final return ret to a return 0 and don't change mtk_i2c_transfer.