Fix longstanding bug in openr2_chan_write() API, this API is really not used
that much as the majority of the users of openr2 have a direct access to the IO
layer and they write directly to the device without using this API so that's the
reason we had never seen this bug before in the field. I only found it by chance
when inspecting the code.

The issue is if EAGAIN is returned from write(), we would still do the written +=
calculation, which would actually decrement the written count, no good :)