title: Using a linux driver found on github
body: <p>I recently found a driver for an IC I need: <a href="https://github.com/skelton/s7300B_common_3050/blob/master/customer/drivers/misc/lsm303d.c" rel="nofollow">https://github.com/skelton/s7300B_common_3050/blob/master/customer/drivers/misc/lsm303d.c</a>
  It is an accelerometer with a magnetometer, and is spoken to via i^2c.</p>
  
  <p>I added this .c to my kernel under <code>&lt;kernel&gt;/drivers/compass/</code>,
  and .h to <code>&lt;kernel&gt;/include/linux/</code>
  I had to add some defines to make it compile, but nothing spectacular.</p>
  
  <p>My Makefile resides together with the .c file, and contains</p>
  
  <pre><code>obj-$(CONFIG_LSM303D)   += lsm303d.o
  </code></pre>
  
  <p>My Kconfig:</p>
  
  <pre><code>config LSM303D
  tristate "LSM303D compass driver"  
  depends on ARM
  default y if ARM
  help
    lsm303d driver.
  </code></pre>
  
  <p>I also added</p>
  
  <pre><code>obj-y += compass/ 
  </code></pre>
  
  <p>to the <code>&lt;kernel&gt;/drivers/Makefile</code></p>
  
  <p>I compile with</p>
  
  <pre><code>make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm distclean
  make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- my_defconfig
  make ARCH=arm -j 4 CROSS_COMPILE=arm-linux-gnueabihf- uImage
  make ARCH=arm -j 4 CROSS_COMPILE=arm-linux-gnueabihf- modules
  make ARCH=arm -j 4 CROSS_COMPILE=arm-linux-gnueabihf- modules_install
  </code></pre>
  
  <p>I am not sure if the last 2 lines are necessary for me.</p>
  
  <p>What I am trying to do is to use this driver to read the data from it. But I don't find any starting points on how to use its API, and what functionality it gives me.</p>
  
  <p>I find the folder called lsm303d on my test machine:
      $ ls /sys/bus/i2c/drivers/lsm303d
      bind    uevent  unbind</p>
  
  <p>I read here: <a href="https://www.kernel.org/doc/Documentation/console/console.txt" rel="nofollow">https://www.kernel.org/doc/Documentation/console/console.txt</a>
  what these files are. This does not help me much, as I am just starting with the whole kernel/driver/module experimenting.</p>
  
  <p>So, my question: How do I use this driver to e.g. read out something over i2c from it?</p>
  
  <p>Any help would be appreciated.</p>