The device driver libraries shouldn't initialize the SPI and I2C buses, that should be up to the user code to do before instantiating or initializing them. Otherwise using multiple devices on the same bus will result in multiple calls to the buses' open() methods.
For I2C devices that just means the open() calls need to be removed.
For SPI, the open() calls need to be removed from class init() methods, and any clock mode or frequency settings need to be moved to the data transfer methods so those settings are always applied before transferring data. (Note: SPI devices won't be thread safe because those settings could be changed by another thread before data is sent; is there a good way to implement a mutex for that?)
The device driver libraries shouldn't initialize the SPI and I2C buses, that should be up to the user code to do before instantiating or initializing them. Otherwise using multiple devices on the same bus will result in multiple calls to the buses' open() methods.
For I2C devices that just means the open() calls need to be removed.
For SPI, the open() calls need to be removed from class init() methods, and any clock mode or frequency settings need to be moved to the data transfer methods so those settings are always applied before transferring data. (Note: SPI devices won't be thread safe because those settings could be changed by another thread before data is sent; is there a good way to implement a mutex for that?)