i2c_spi_buses: method to count instances per bus

Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
Julian Oes 2023-10-11 12:47:15 +13:00 committed by Daniel Agar
parent 742d237ae3
commit 895ddee16a
2 changed files with 14 additions and 0 deletions

View File

@ -392,6 +392,19 @@ int BusInstanceIterator::runningInstancesCount() const
return num_instances;
}
int BusInstanceIterator::runningInstancesOnBusCount() const
{
int num_instances = 0;
for (const auto &modules : i2c_spi_module_instances) {
if (modules->_bus == bus() && strcmp(modules->_module_name, _module_name) == 0) {
++num_instances;
}
}
return num_instances;
}
I2CSPIInstance *BusInstanceIterator::instance() const
{
if (_current_instance == i2c_spi_module_instances.end()) {

View File

@ -229,6 +229,7 @@ public:
I2CSPIBusOption configuredBusOption() const { return _bus_option; }
int runningInstancesCount() const;
int runningInstancesOnBusCount() const;
bool next();