title: Designing a Linux char device driver so multiple processes can read
body: <p>I notice that for serial devices, e.g. <code>/dev/ttyUSB0</code>, multiple processes can open the device but only one process gets the bytes (whichever reads them first).</p>
  
  <p>However, for the Linux input API, e.g. <code>/dev/input/event0</code>, multiple processes can open the device, and all of the processes are able to read the input events.</p>
  
  <p>My current goal:</p>
  
  <p>I'd like to write a driver for several multi-position switches (e.g. like a slider switch with 3 or 4 possible positions), where apps can get a notification of any switch position changes. Ideally I'd like to use the Linux input API, however it seems that the Linux input API has no support for the concept of multi-position switches. So I'm looking at making a custom driver with similar capabilities to the Linux input API.</p>
  
  <p>Two questions:</p>
  
  <ul>
  <li>From a driver design point-of-view, why is there that difference in behaviour between Linux input API and Linux serial devices? I reckon it could be useful for multiple processes to all be able to open one serial port and all listen to incoming bytes.</li>
  <li>What is a good way to write a Linux character device driver so that it's like the Linux input API, so multiple processes can open the device and read all the data?</li>
  </ul>