From patchwork Thu Sep 12 20:03:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1961 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97FD260C1A for ; Thu, 12 Sep 2019 22:03:45 +0200 (CEST) Received: from pendragon.lan (bl10-204-24.dsl.telepac.pt [85.243.204.24]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0CEF633A; Thu, 12 Sep 2019 22:03:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568318625; bh=A5c81SPgvpkLHXknSmlBCbcSsOwAvMPMabq1kb1p0WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sx0js3NTmZWjaFPmEDB/OuiX0urM9qOaNYTOriFNedLxt717NBhkhbA4Lj+rH8FrI oA1+8wqJCK8LlUA53kL39gzz91hs9CkYyl+GkbIWFr3GQIjw+wGmFarLeOO6MT5MZW OyrDDl4SIdKf3H6TQKDFYnenaZKC7750oNJcqfSQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Sep 2019 23:03:28 +0300 Message-Id: <20190912200330.19004-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190912200330.19004-1-laurent.pinchart@ideasonboard.com> References: <20190912200330.19004-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: device_enumerator_udev: Delay device node lookup X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Sep 2019 20:03:46 -0000 When populating media devices, we look up device nodes for every entity in the media device, regardless of if the entity is present in the orphans list. This causes unnecessary lookups (that may also fail as the device node may not be ready yet at that time). Move the lookup at a later time, when the device node is actually needed. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/device_enumerator_udev.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index e0c646c997de..210f5c1f2870 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -180,10 +180,10 @@ int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr dev_t devnum = makedev(entity->deviceMajor(), entity->deviceMinor()); - std::string deviceNode = lookupDeviceNode(devnum); /* Take device from orphan list first, if it is in the list. */ if (std::find(orphans_.begin(), orphans_.end(), devnum) != orphans_.end()) { + std::string deviceNode = lookupDeviceNode(devnum); if (deviceNode.empty()) return -EINVAL;