title: How to read data from LSM330 in /dev/iio:deviceX?
body: <p>I am trying to interface a LSM330 accelerometer/gyroscope module on an i.MX6 board. The module is connected to an I2C bus, the relevant parts of the device tree file are as follows:</p>
  
  <pre><code>&amp;i2c1 {
      clock-frequency = &lt;100000&gt;;
      pinctrl-names = "default";
      pinctrl-0 = &lt;&amp;pinctrl_i2c1_2&gt;;
      status = "okay";
  
      /* LSM330 motion detector (accelerometer) */
      lsm330_accel: lsm330_accel@0x1e {
          compatible = "st,lsm330-accel";
          st,drdy-int-pin = &lt;1&gt;;
          reg = &lt;0x1e&gt;;
      };
  
      /* LSM330 motion detector (gyroscope) */
      lsm330_gyro: lsm330_gyro@0x6a {
          compatible = "st,lsm330-gyro";
          st,drdy-int-pin = &lt;2&gt;;
          reg = &lt;0x6a&gt;;
      };
  };
  </code></pre>
  
  <p>The module shows up as <code>/dev/iio:device0</code> for the accelerometer and <code>/dev/iio:device1</code> for the gyroscope. They also show up as <code>/sys/bus/iio/devices/iio:device0</code>and <code>/sys/bus/iio/devices/iio:device1</code>. I can get the sensor readings via <code>cat in_accel_x_raw</code> etc. However, running <code>cat /dev/iio:device0</code> immediately returns and produce no output. </p>
  
  <p>After searching around the Internet, I also tried the commands:</p>
  
  <pre><code>cd /sys/bus/iio/devices/iio_sysfs_trigger
  echo 0 &gt; add_trigger
  cd /sys/bus/iio/devices/iio:device0
  echo 1 &gt; scan_elements/in_accel_x_en
  echo 1 &gt; scan_elements/in_accel_y_en
  echo 1 &gt; scan_elements/in_accel_z_en
  echo 1 &gt; scan_elements/in_timestamp_en
  echo sysfstrig0 &gt; trigger/current_trigger
  echo 100 &gt; buffer/length
  echo 1 &gt; buffer/enable
  echo 1 &gt; /sys/bus/iio/devices/trigger0/trigger_now
  </code></pre>
  
  <p>This should set the channels, enable the buffer and get some readings into the buffer. As far as I know, <code>cat /dev/iio:device0</code> should display the buffer, but it is giving me <code>Device or resource busy</code>. Further reads from the kernel with <code>cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw</code> no longer works and give the same error message.</p>
  
  <p>I am very new to the linux kernel, my goal is to expose the sensor data to the Android system so the user can rotate the screen etc. How do I get Android to obtain sensor readings from the module?</p>