title: Getting EINVAL when trying to write to mtd device
body: <p>I am referring to the code in this <a href="https://stackoverflow.com/a/15340705/338476">answer</a>. 
  I added error handling though.
  The <code>open()</code> erase and the <code>read()</code> all perform without error and the 20 bytes that I read all are <code>0xff</code>.
  However, when trying to write the 20 bytes from the <code>data[]</code> array, I get an <code>EINVAL</code> errorcode from the <code>write()</code> function.
  What could be the cause of the problem? I did erase the memory before trying to write...</p>