modbus: Close device after scan
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.
This commit is contained in:
parent
8f3c77db26
commit
1d657f47be
|
@ -51,13 +51,14 @@ static struct sr_dev_inst *sr_modbus_scan_resource(const char *resource,
|
|||
return NULL;
|
||||
};
|
||||
|
||||
if ((sdi = probe_device(modbus)))
|
||||
return sdi;
|
||||
sdi = probe_device(modbus);
|
||||
|
||||
sr_modbus_close(modbus);
|
||||
|
||||
if (!sdi)
|
||||
sr_modbus_free(modbus);
|
||||
|
||||
return NULL;
|
||||
return sdi;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue