+ if (!val1 && !val2)
+ break;
+
+ addr = buf2[1] | (buf2[0] << 8) | (buf1[3] << 16) |
+ ((u64)buf1[2] << 24) | ((u64)buf1[1] << 32) |
+ ((u64)buf1[0] << 40);
+
+ sdw_extract_slave_id(bus, addr, &id);
+ /* Now compare with entries */
+ list_for_each_entry_safe(slave, _s, &bus->slaves, node) {
+ if (sdw_compare_devid(slave, id) == 0) {
+ u32 status = qcom_swrm_get_n_device_status(ctrl, i);
+ if (status == SDW_SLAVE_ATTACHED) {
+ slave->dev_num = i;
+ mutex_lock(&bus->bus_lock);
+ set_bit(i, bus->assigned);
+ mutex_unlock(&bus->bus_lock);
+
+ }
And that part is strange as well. The bus->assigned bit should be set even if the Slave is not in the list provided by platform firmware. It's really tracking the state of the hardware, and it should not be influenced by what software knows to manage.
Am not 100% sure If I understand the concern here, but In normal (non auto enum) cases this bit is set by the bus code while its doing enumeration to assign a dev number from the assigned bitmap!
However in this case where auto enumeration happens it makes sense to set this here with matching dev number!
AFAIU from code, each bit in this bitmap corresponds to slave dev number!
+ complete(&ctrl->enumeration);
you have init_completion() and complete() in this patch, but no wait_for_completion(), so that should be added in a later patch, no?
make sense, will move that to other patch!