I would like to:
- initiate complex I2C transfer sequences with parameters
- read results
- do it from user space C code and/or command line/scripts
I2C driver (like other platform drivers), does not give us a way to implement custom IOCTL or read/write callbacks. "struct i2c_driver" has few callbacks like probe/remove, but no read/write/ioctl. There is "command" callback - "a ioctl like command that can be used to perform specific functions" but it is marked as "deprecated" in .html
IOCTL to I2C device, such as I2C_RDWR, are handled by drivers/i2c/i2c-dev.c and are not passed to my driver.
I can create sysfs subdirectory with multiple attributes for my I2C device, but that would violate the convention that there should be only one value per attribute (but I need multiple) and it should not be used to perform transfers (/).
May be I should use sysfs Binary Attributes? For example, NVMEM subsystem, used by drivers/misc/eeprom/at24.c, exposes entire EEPROM as a binary sysfs file for random reading/writing. May be I can use "loff_t pos" parameter for ssize_t (*read)(struct kobject *kobj, char *buffer, loff_t pos, size_t size); in struct bin_attribute to pass parameter(s), execute transfer and then print the result? Would it violate some convention?
Or I can create debugfs, which does not appear to have such strict limitations, but it sounds wrong to use debugfs for the core device functionality.
Or should I create a traditional chardev in parallel to I2C one?
Any other options? What is the best one?
Note: my question appears to be similar to accessing i2c platform device from userspace program, but that was specific to EEPROM.