[{"id":2642,"web_url":"https://patchwork.libcamera.org/comment/2642/","msgid":"<a139ed7b-a47b-5acc-5b85-e6e6634b37ee@ideasonboard.com>","date":"2019-09-13T08:41:04","subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: device_enumerator:\n\tMove lookupDeviceNode() to child classes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 12/09/2019 21:03, Laurent Pinchart wrote:\n> The lookupDeviceNode() method is declared as pure virtual in the base\n> DeviceEnumerator class, but is only called by derived classes. Move it\n> to the DeviceEnumeratorSysfs and DeviceEnumeratorUdev. This allows\n> changing the udev version to take a dev_t instead of separate\n> major/minor, as that's what both the caller and the callee end up using.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/device_enumerator.cpp           | 13 -------------\n>  src/libcamera/device_enumerator_sysfs.cpp     | 11 +++++++++++\n>  src/libcamera/device_enumerator_udev.cpp      | 19 ++++++++++++-------\n>  src/libcamera/include/device_enumerator.h     |  2 --\n>  .../include/device_enumerator_sysfs.h         |  2 +-\n>  .../include/device_enumerator_udev.h          |  2 +-\n>  6 files changed, 25 insertions(+), 24 deletions(-)\n> \n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index e76438afdd65..0b596bcec363 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -306,17 +306,4 @@ std::shared_ptr<MediaDevice> DeviceEnumerator::search(const DeviceMatch &dm)\n>  \treturn nullptr;\n>  }\n>  \n> -/**\n> - * \\fn DeviceEnumerator::lookupDeviceNode(int major, int minor)\n> - * \\brief Lookup device node path from device number\n> - * \\param[in] major The device major number\n> - * \\param[in] minor The device minor number\n> - *\n> - * Translate a device number given as \\a major and \\a minor to a device node\n> - * path.\n> - *\n> - * \\return the device node path on success, or an empty string if the lookup\n> - * fails\n> - */\n> -\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp\n> index 78a7da8d79e5..ad26affb38a3 100644\n> --- a/src/libcamera/device_enumerator_sysfs.cpp\n> +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> @@ -112,6 +112,17 @@ int DeviceEnumeratorSysfs::populateMediaDevice(const std::shared_ptr<MediaDevice\n>  \treturn 0;\n>  }\n>  \n> +/**\n> + * \\brief Lookup device node path from device number\n> + * \\param[in] major The device major number\n> + * \\param[in] minor The device minor number\n> + *\n> + * Translate a device number given as \\a major and \\a minor to a device node\n> + * path.\n> + *\n> + * \\return The device node path on success, or an empty string if the lookup\n> + * fails\n> + */\n>  std::string DeviceEnumeratorSysfs::lookupDeviceNode(int major, int minor)\n>  {\n>  \tstd::string deviceNode;\n> diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> index 40853e77902f..e0c646c997de 100644\n> --- a/src/libcamera/device_enumerator_udev.cpp\n> +++ b/src/libcamera/device_enumerator_udev.cpp\n> @@ -178,10 +178,9 @@ int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr<MediaDevice>\n>  \t\tif (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)\n>  \t\t\tcontinue;\n>  \n> -\t\tstd::string deviceNode = lookupDeviceNode(entity->deviceMajor(),\n> -\t\t\t\t\t\t\t  entity->deviceMinor());\n>  \t\tdev_t devnum = makedev(entity->deviceMajor(),\n>  \t\t\t\t       entity->deviceMinor());\n> +\t\tstd::string deviceNode = lookupDeviceNode(devnum);\n>  \n>  \t\t/* Take device from orphan list first, if it is in the list. */\n>  \t\tif (std::find(orphans_.begin(), orphans_.end(), devnum) != orphans_.end()) {\n> @@ -205,14 +204,21 @@ int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr<MediaDevice>\n>  \treturn pendingNodes;\n>  }\n>  \n> -std::string DeviceEnumeratorUdev::lookupDeviceNode(int major, int minor)\n> +/**\n> + * \\brief Lookup device node path from device number\n> + * \\param[in] devnum The device number\n> + *\n> + * Translate a device number given as \\a devnum to a device node path.\n> + *\n> + * \\return The device node path on success, or an empty string if the lookup\n> + * fails\n> + */\n> +std::string DeviceEnumeratorUdev::lookupDeviceNode(dev_t devnum)\n>  {\n>  \tstruct udev_device *device;\n>  \tconst char *name;\n> -\tdev_t devnum;\n>  \tstd::string deviceNode = std::string();\n>  \n> -\tdevnum = makedev(major, minor);\n>  \tdevice = udev_device_new_from_devnum(udev_, 'c', devnum);\n>  \tif (!device)\n>  \t\treturn std::string();\n> @@ -246,8 +252,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n>  \t\treturn 0;\n>  \t}\n>  \n> -\tstd::string deviceNode = lookupDeviceNode(entity->deviceMajor(),\n> -\t\t\t\t\t\t  entity->deviceMinor());\n> +\tstd::string deviceNode = lookupDeviceNode(devnum);\n>  \tif (deviceNode.empty())\n>  \t\treturn -EINVAL;\n>  \n> diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\n> index c5d26f1a883e..770f42772270 100644\n> --- a/src/libcamera/include/device_enumerator.h\n> +++ b/src/libcamera/include/device_enumerator.h\n> @@ -50,8 +50,6 @@ protected:\n>  \n>  private:\n>  \tstd::vector<std::shared_ptr<MediaDevice>> devices_;\n> -\n> -\tvirtual std::string lookupDeviceNode(int major, int minor) = 0;\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/include/device_enumerator_sysfs.h b/src/libcamera/include/device_enumerator_sysfs.h\n> index 242b22b289b0..9063f6a75e11 100644\n> --- a/src/libcamera/include/device_enumerator_sysfs.h\n> +++ b/src/libcamera/include/device_enumerator_sysfs.h\n> @@ -24,7 +24,7 @@ public:\n>  \n>  private:\n>  \tint populateMediaDevice(const std::shared_ptr<MediaDevice> &media);\n> -\tstd::string lookupDeviceNode(int major, int minor) final;\n> +\tstd::string lookupDeviceNode(int major, int minor);\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/include/device_enumerator_udev.h b/src/libcamera/include/device_enumerator_udev.h\n> index 5bdcdea65c35..fb7cac8011a1 100644\n> --- a/src/libcamera/include/device_enumerator_udev.h\n> +++ b/src/libcamera/include/device_enumerator_udev.h\n> @@ -47,7 +47,7 @@ private:\n>  \n>  \tint addUdevDevice(struct udev_device *dev);\n>  \tint populateMediaDevice(const std::shared_ptr<MediaDevice> &media);\n> -\tstd::string lookupDeviceNode(int major, int minor) final;\n> +\tstd::string lookupDeviceNode(dev_t devnum);\n>  \n>  \tint addV4L2Device(dev_t devnum);\n>  \tvoid udevNotify(EventNotifier *notifier);\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A0AF160BB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Sep 2019 10:41:07 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 01BC933A;\n\tFri, 13 Sep 2019 10:41:06 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1568364067;\n\tbh=jnrnOBu6gOOgAcWShVKsUJjZ9SwqoBZHLDykVn8STfQ=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=tNu0aHP54EPneHmjmiKCyt8OFh5OToJpafds95B6m0MbZVFNpPJml7dphMdQzLgE3\n\tCxO/uN9NvJmdvvVF0nIwlgf1+I2aI2Xkj/CHRKSX0UoX3Xm40g+Bsmoqyl355yh/Ii\n\tdNYHj71+OTyQddhxsuG0nC9zkDFv4/pC2LeNahQU=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190912200330.19004-1-laurent.pinchart@ideasonboard.com>\n\t<20190912200330.19004-2-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq\n\t8K8FieAjgjMSxngo/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQcOdhtd36\n\tOe9X9dXB8YSNt7VjOcO7BTmFn/Z8r92mSAfHXpb07YJWJosQOQARAQABtDBLaWVyYW4gQmlu\n\tZ2hhbSA8a2llcmFuLmJpbmdoYW1AaWRlYXNvbmJvYXJkLmNvbT6JAlcEEw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hTTPt4m/Y14XzEcy6JREIjOrFfUZVho2QpOdv9CNryGdieRTNjUtz463CIaZ\n\tdPBiw9mOMBoNffkn9FIoCjLnAaj9gUAnEHWBZOEviQ5NuyqpeP0YtzI4iaRbSUkYZHej99X3\n\tVmHrdLlMqd/ZgYYbPGSL4AN3FVACb5CxuxEHwo029VcE5U3CSjzqtCoX12tm7A==","Organization":"Ideas on Board","Message-ID":"<a139ed7b-a47b-5acc-5b85-e6e6634b37ee@ideasonboard.com>","Date":"Fri, 13 Sep 2019 09:41:04 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.8.0","MIME-Version":"1.0","In-Reply-To":"<20190912200330.19004-2-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 1/4] libcamera: device_enumerator:\n\tMove lookupDeviceNode() to child classes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 13 Sep 2019 08:41:07 -0000"}}]