libcamera: device_enumerator_udev: Don't add media device twice
Commit68daa9302f
("libcamera: device_enumerator: Don't stop if one device fails") introduced a bug in device enumeration. Previously, a media device would only be added when all its dependencies were present, as indicated by populateMediaDevice() returning 0. The commit changed the logic to propagate the populateMediaDevice() return code up, but mistakenly added the media device to the enumerator even when dependencies were missing. This causes media devices enumerated with missing dependencies to be added twice, once when enumerating the media device itself, and a second time when all the dependencies are found. Fix it by deferring addition of the media device when dependencies are missing, and add debug messages to track this process. Fixes:68daa9302f
("libcamera: device_enumerator: Don't stop if one device fails") Reported-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
d6f5621e15
commit
3f97be923c
1 changed files with 10 additions and 0 deletions
|
@ -90,6 +90,13 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
LOG(DeviceEnumerator, Debug)
|
||||||
|
<< "Defer media device " << media->deviceNode()
|
||||||
|
<< " due to " << ret << " missing dependencies";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
addDevice(media);
|
addDevice(media);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -313,6 +320,9 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)
|
||||||
deps->deps_.erase(devnum);
|
deps->deps_.erase(devnum);
|
||||||
|
|
||||||
if (deps->deps_.empty()) {
|
if (deps->deps_.empty()) {
|
||||||
|
LOG(DeviceEnumerator, Debug)
|
||||||
|
<< "All dependencies for media device "
|
||||||
|
<< deps->media_->deviceNode() << " found";
|
||||||
addDevice(deps->media_);
|
addDevice(deps->media_);
|
||||||
pending_.remove(*deps);
|
pending_.remove(*deps);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue