summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/device_enumerator.cpp8
-rw-r--r--src/libcamera/media_device.cpp12
2 files changed, 11 insertions, 9 deletions
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index 259eec41..6fcbae76 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -207,11 +207,7 @@ int DeviceEnumerator::addDevice(const std::string &deviceNode)
{
std::shared_ptr<MediaDevice> media = std::make_shared<MediaDevice>(deviceNode);
- int ret = media->open();
- if (ret < 0)
- return ret;
-
- ret = media->populate();
+ int ret = media->populate();
if (ret < 0) {
LOG(DeviceEnumerator, Info)
<< "Unable to populate media device " << deviceNode
@@ -238,8 +234,6 @@ int DeviceEnumerator::addDevice(const std::string &deviceNode)
return ret;
}
- media->close();
-
LOG(DeviceEnumerator, Debug)
<< "Added device " << deviceNode << ": " << media->driver();
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index 449571fb..c3977516 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -221,6 +221,10 @@ int MediaDevice::populate()
clear();
+ ret = open();
+ if (ret)
+ return ret;
+
/*
* Keep calling G_TOPOLOGY until the version number stays stable.
*/
@@ -237,7 +241,7 @@ int MediaDevice::populate()
LOG(MediaDevice, Error)
<< "Failed to enumerate topology: "
<< strerror(-ret);
- return ret;
+ goto done;
}
if (version == topology.topology_version)
@@ -262,6 +266,10 @@ int MediaDevice::populate()
populateLinks(topology))
valid_ = true;
+ ret = 0;
+done:
+ close();
+
delete[] ents;
delete[] interfaces;
delete[] pads;
@@ -272,7 +280,7 @@ int MediaDevice::populate()
return -EINVAL;
}
- return 0;
+ return ret;
}
/**