title: Accessing a serial port from a linux kernel module
body: <p>Hello Linux Kernel Driver Gurus!</p>
  
  <p>I'm writing a v4l2 driver for a camera that uses a serial interface for configuration.  I'd like the driver to configure the camera, as it keeps the client code consistent across camera models.  The question is: what's the best way to access the camera's serial interface from the driver module?</p>
  
  <p>From what I hear, accessing files from a kernel driver is a big no-no, but it can be done.  As such, I'm currently using the following code snippet, but it feels like a hack.</p>
  
  <pre><code>oldfs = get_fs();
  set_fs(KERNEL_DS);
  
  fd-&gt;f_pos=0;
  fd-&gt;f_op-&gt;write(fd, data, data_len, &amp;fd-&gt;f_pos);
  
  set_fs(oldfs);
  </code></pre>
  
  <p>My question is really: what's the right way to do this?</p>