Reputation: 11017
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:
/dev/i2c-N
and call ioctl()
on it. By doing so you "specify with what device address you want to communicate"i2c_smbus_write_byte_data()
or i2c_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?
Upvotes: 0
Views: 496