title: What's the point of a Linux character device driver if you can just use outb/inb from userspace?
body: <p>I'm having a hard time understand when I should write a device driver instead of just sending opcodes directly to the hardware via <code>outb</code> from my userspace programs. I initially figured that I should create simple routines for the hardware, but now I'm starting to think that algorithms should stay in the userspace.</p>
  
  <p>Suppose I'm programming a hypothetical robotic arm. I could write several functions in a Linux kernel module that would automate the hardware outputs needed for common tasks (e.g. move arm to HOME position, pickup new block from known location at start of assembly line, etc.). However, after reading more about device drivers, it seems that rule of thumb is to keep the device driver as close to hardware-specific code as possible, leaving the "heavy lifting" algorithms to userspace.</p>
  
  <p>This confuses me, since if the only functions implemented by the device drivers are simple opcode calls, what's the reason for a userspace program to use the device file instead of calling <code>outb</code>/<code>inb</code> directly?</p>
  
  <p>I suppose what I'm trying to figure out is: how do I decide what functionality goes in kernelspace instead of userspace?</p>