While reading the linux kernel documentation on I2C device drivers from user space, I noticed that ioctl() is used to "put the address on the bus".
So a typical workflow as described is:
- Open
/dev/i2c-Nand callioctl()on it. By doing so you "specify with what device address you want to communicate" - Followed by a read or write operation to
i2c_smbus_write_byte_data()ori2c_smbus_read_byte_data().
Then it occurred to me that if I am building a system which has more than one device connected to that bus (i2c-N), and I have different threads that will use this device driver, there must be a mutex lock on the file descriptor that wraps the ioctl() + read()/write() operation, to ensure that the read/write is being done on the intended device.
Is this reasoning correct or have I misunderstood something?