title: Linux tty flip buffer lock when reading part of available data
body: <p>I have a driver that builds on the new serdev bus in the linux kernel.</p>
  
  <p>In my driver I receive messages from an external device, all messages ends with a null byte (0x00) and the protocol ensures that there are no null bytes in my data (COBS). Now I try to have the TTY layer hand me full messages by scanning for zeros in my input and if there are none I'll just return zero in the callback that is called from the tty layer when bytes are available.</p>
  
  <p>This kind of works. Or rather it works for some messages. After a while though it locks up and the tty layer keeps sending the same size of received bytes indefinitely. My guess is that this happens when one half of the tty flip buffer is full and the rest of my message is in the other half.</p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>Am I correct in that the tty layer can "hang" until I read out all data in one half of the flip buffer?</p></li>
  <li><p>If that is so, is there some way to prevent this from happening? I'd rather not implement my own buffering scheme on top of the tty buffer already available.</p></li>
  </ol>
  
  <p>Thanks</p>