Since the device should be closed after the scan, close it in sr_modbus_scan.
Alternatively, every single driver could close the device after calling
sr_modbus_scan. This causes duplicated code, is prone to forgetting it and it
wasn't the calling driver who opened the device in the first place.
This change unbreaks maynuo-m97 and rdtech-dps.
return NULL;
};
- if ((sdi = probe_device(modbus)))
- return sdi;
+ sdi = probe_device(modbus);
sr_modbus_close(modbus);
- sr_modbus_free(modbus);
- return NULL;
+ if (!sdi)
+ sr_modbus_free(modbus);
+
+ return sdi;
}
/**