Show a patch.

GET /api/1.1/patches/1960/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1960,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1960/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1960/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20190912200330.19004-2-laurent.pinchart@ideasonboard.com>",
    "date": "2019-09-12T20:03:27",
    "name": "[libcamera-devel,1/4] libcamera: device_enumerator: Move lookupDeviceNode() to child classes",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6b86ebb51a5cbb0e04a341374e6f5c572740cc3c",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1960/mbox/",
    "series": [
        {
            "id": 487,
            "url": "https://patchwork.libcamera.org/api/1.1/series/487/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=487",
            "date": "2019-09-12T20:03:26",
            "name": "Fix udev device enumerator with V4L2 M2M devices",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/487/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1960/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1960/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@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 09B53600E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Sep 2019 22:03:45 +0200 (CEST)",
            "from pendragon.lan (bl10-204-24.dsl.telepac.pt [85.243.204.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 78C0C57E;\n\tThu, 12 Sep 2019 22:03:44 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1568318624;\n\tbh=bo7SorejL3DE7ScmvSpk3qcsNv9md85LasT1Dr71sbA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ofZ8MDegN+EL3kuLu6G8H6D38rIQ78ZFu54fHVXC7G6zXYvAvKy9Obgm/3CGF1t+w\n\tscWCi51dbh8d0yh9Usvgkf3iGfE036jqp3O+OaIuKvinVGaNI8WPlj3JtzHG9+7zTz\n\tG1wrAv9z5jQoNItrXpWP9u7q7FvzONrmkTx5mBGA=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 12 Sep 2019 23:03:27 +0300",
        "Message-Id": "<20190912200330.19004-2-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",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/4] libcamera: device_enumerator: Move\n\tlookupDeviceNode() 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": "Thu, 12 Sep 2019 20:03:45 -0000"
    },
    "content": "The lookupDeviceNode() method is declared as pure virtual in the base\nDeviceEnumerator class, but is only called by derived classes. Move it\nto the DeviceEnumeratorSysfs and DeviceEnumeratorUdev. This allows\nchanging the udev version to take a dev_t instead of separate\nmajor/minor, as that's what both the caller and the callee end up using.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\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(-)",
    "diff": "diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex 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 */\ndiff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp\nindex 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;\ndiff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex 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 \ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nindex 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 */\ndiff --git a/src/libcamera/include/device_enumerator_sysfs.h b/src/libcamera/include/device_enumerator_sysfs.h\nindex 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 */\ndiff --git a/src/libcamera/include/device_enumerator_udev.h b/src/libcamera/include/device_enumerator_udev.h\nindex 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",
    "prefixes": [
        "libcamera-devel",
        "1/4"
    ]
}