I2C communication from user space getting error

Respected Sir,
I have Connectcore Wi-i.mx51 board, I written driver for battery management, that is connected externally through i2c.

  • I am getting 00 for reading and writing data from userspace.
  • Other method if i include all in driver part (copy-to-user and copy-from-user) showing segmentation fault while insmod driver.

kernelspace - i2c driver
userspace - simple program to access my driver
using file descriptor and ioctl operations.
(I tried another method using fd and
sm_bus_read_word_data() it also
showing error)

Whenever i am going to access my driver its showing error after including i2c-dev.h in userspace program.

I am giving input from user(pgm) -> copyfromuser(driver)->smbusread(driver)->gettingdata and copytouser(driver)->accessing data( userspace pgm) showing error.

i2c-dev.h showing partial header file after including to digi. outside digi its showing smbus_read and smbus_write is there.

Please help me to get out from this problem.
Send If any sample code of i2c driver for charger and program for access driver from userspace.

thank you,

Can you please be more specific as of what you are doing?
in kernel configuration:
enabled raw access by enabling Linux Kernel Configuration > Device Drivers > I2C support > I2C device interface.

navigated to Linux Kernel Configuration > System Type > Freescale MXC implementations > I2C interface options and enabled I2C2 and I2C3 modules.

Under Linux Kernel Configuration > Device Drivers > I2C support, enabled MXC HIGH SPEED I2C support.

Under Linux Kernel Configuration > Device Drivers > I2C support > I2C Hardware Bus Support, enabled IMX I2C Interface, MXC I2C support, and MXC HIGH SPEED I2C support.

What are you doing next? Do you see and can open
/dev/i2c-0, /dev/i2c-1, /dev/i2c-2?

[root /]# ls /dev/i2c-* -al
crw-rw---- 1 root root 89, 0 Jan 4 23:26 /dev/i2c-0
crw-rw---- 1 root root 89, 1 Jan 4 23:26 /dev/i2c-1

i2cdetect -F 0
i2cdetect -F 1
i2cdetect -ya 0