简体   繁体   中英

How to forward IOCTL's from i2c-dev.c to adapter driver (i2c-rt3352.c)

I'm writing the I2C adapter driver for SOC. This adapter exist now in system and RTC driver works with it via .master_xfer.

I would like to send IOCTL's from application via /dev/i2c. I have loaded i2c_dev and all modules. After sending IOCTL I get following :

#i2ccmd read 0
i2cdev_open[382]
i2c_dev_get_by_minor[54]
i2c_get_adapter[896]
i2cdev_ioctl[186]
ioctl, cmd=0x03, arg=0x00
i2c_control[731]
i2cdev_release[420]
i2c_put_adapter[910]

i2cdev_ioctl method doesn't send I2C_RDWR IOCT'L to my adapter driver. How can I forward those IOCTL's to i2c-rt3352.c ?

In the output I see you are sending IOCTL 0x03, what is this? is this a custom command?. One of the ways to write/read is I2C_RDWR ioctl command. You need to build the i2c_msgs in your application and issue the I2C_RDWR command using the ioctl. I2C_RDWR is understood only by the i2c-dev driver and it will call the adapter transfer function.

No IOCTL command is passed to adapter driver, there is no way to talk to the adapter driver using IOCTL if you are using i2c-dev driver interface.

I've found the way to pass my own IOCTL's: .algo_control function pointer in i2c_algorithm struct will handle special ioctl's.

i2cdev_ioctl -> (default) -> i2c_control -> (default) -> (adap->algo->algo_control)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM