1. No need to have an additional variable (done) when refactoring can provide you an existing variable (time) to be tested instead. 2. There are generic macros readx_poll_timeout() that are doing this kind of busy loop with IO.