How to include SMBus commands in my i2c program

Hi, I’m trying to write a demo for i2c on my Colibri iMX6

I followed the instructions here
http://git.toradex.com/cgit/linux-toradex.git/tree/Documentation/i2c/dev-interface?h=toradex_imx_3.14.52_1.1.0_ga

It seemed worked will before I use SMBus commands

  res = i2c_smbus_read_word_data(file, register);
  if (res < 0) {
    /* ERROR HANDLING: i2c transaction failed */
  } else {
    /* res contains the read word */
  }

There is an error saying that cannot find the i2c_smbus_read_word_data() function.
I have included linux/i2c and linux/i2c-dev
What should I do?
Thanks!

Hi

As the kernel document states, you need to use the i2c-dev.h header of the i2c-tools project if you want the SMBus inline functions.

If you did your own OE build you have that file renamed to i2c-dev-user.h in the resulting sysroot after building the package. Otherwise you could download the project sources and use the header file contained in the unpacked sources.

wget http://downloads.yoctoproject.org/mirror/sources/i2c-tools-3.1.2.tar.bz2

Max