Show a patch.

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

{
    "id": 3236,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3236/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3236/",
    "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": "<20200321180951.32685-1-laurent.pinchart@ideasonboard.com>",
    "date": "2020-03-21T18:09:50",
    "name": "[libcamera-devel,1/2] libcamera: device_enumerator_udev: Update pending list in addUdevDevice",
    "commit_ref": "e75ef59e028e5b686d686789439ede443c9c4cde",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "7cdfd381a30c0743cd399ec607421b98695041bb",
    "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/3236/mbox/",
    "series": [
        {
            "id": 755,
            "url": "https://patchwork.libcamera.org/api/1.1/series/755/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=755",
            "date": "2020-03-21T18:09:50",
            "name": "[libcamera-devel,1/2] libcamera: device_enumerator_udev: Update pending list in addUdevDevice",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/755/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3236/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3236/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 4921D60415\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 21 Mar 2020 19:10:03 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BFDCF308\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 21 Mar 2020 19:10:02 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584814202;\n\tbh=roOAZQK5OOIObpv4aTNuCySoSwr8IvsYcY3GJ7Ktix8=;\n\th=From:To:Subject:Date:From;\n\tb=TsBL7bb0ZPJ4a/JXyPmI9MeCcFzBbKrNjXdPvzLHtihMg353Hcun1AVN8KU9z/Y93\n\tVUSa1Mkts1TtJI4pdYKs3eRaoWBFTdosqA7Lgdqke/95qa0kPlBn30V3wU7Ww/GWIJ\n\thrO2NwUl+6TTmmaXAMD/RubSj2VnI1a1KHA/JLus=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 21 Mar 2020 20:09:50 +0200",
        "Message-Id": "<20200321180951.32685-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: device_enumerator_udev:\n\tUpdate pending list in addUdevDevice",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "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": "Sat, 21 Mar 2020 18:10:03 -0000"
    },
    "content": "Media devices that have unmet dependencies are added to the pending list\nin populateMediaDevice(). Move the code to the caller, addUdevDevice(),\nas it logically belongs there.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/device_enumerator_udev.cpp      | 28 ++++++++-----------\n .../include/device_enumerator_udev.h          |  2 +-\n 2 files changed, 13 insertions(+), 17 deletions(-)",
    "diff": "diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex e55350544feb..ea3f6b7c9ae0 100644\n--- a/src/libcamera/device_enumerator_udev.cpp\n+++ b/src/libcamera/device_enumerator_udev.cpp\n@@ -81,7 +81,8 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)\n \t\tif (!media)\n \t\t\treturn -ENODEV;\n \n-\t\tint ret = populateMediaDevice(media);\n+\t\tDependencyMap deps;\n+\t\tint ret = populateMediaDevice(media.get(), &deps);\n \t\tif (ret < 0) {\n \t\t\tLOG(DeviceEnumerator, Warning)\n \t\t\t\t<< \"Failed to populate media device \"\n@@ -90,10 +91,16 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)\n \t\t\treturn ret;\n \t\t}\n \n-\t\tif (ret) {\n+\t\tif (!deps.empty()) {\n \t\t\tLOG(DeviceEnumerator, Debug)\n \t\t\t\t<< \"Defer media device \" << media->deviceNode()\n \t\t\t\t<< \" due to \" << ret << \" missing dependencies\";\n+\n+\t\t\tpending_.emplace_back(media, deps);\n+\t\t\tMediaDeviceDeps *mediaDeps = &pending_.back();\n+\t\t\tfor (const auto &dep : mediaDeps->deps_)\n+\t\t\t\tdevMap_[dep.first] = mediaDeps;\n+\n \t\t\treturn 0;\n \t\t}\n \n@@ -185,10 +192,9 @@ done:\n \treturn 0;\n }\n \n-int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr<MediaDevice> &media)\n+int DeviceEnumeratorUdev::populateMediaDevice(MediaDevice *media, DependencyMap *deps)\n {\n \tstd::set<dev_t> children;\n-\tDependencyMap deps;\n \n \t/* Associate entities to device node paths. */\n \tfor (MediaEntity *entity : media->entities()) {\n@@ -203,7 +209,7 @@ int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr<MediaDevice>\n \t\t * dependencies.\n \t\t */\n \t\tif (orphans_.find(devnum) == orphans_.end()) {\n-\t\t\tdeps[devnum].push_back(entity);\n+\t\t\t(*deps)[devnum].push_back(entity);\n \t\t\tcontinue;\n \t\t}\n \n@@ -231,17 +237,7 @@ int DeviceEnumeratorUdev::populateMediaDevice(const std::shared_ptr<MediaDevice>\n \t\t\t++it;\n \t}\n \n-\t/*\n-\t * If the media device has unmet dependencies, add it to the pending\n-\t * list and update the devnum map accordingly.\n-\t */\n-\tif (!deps.empty()) {\n-\t\tpending_.emplace_back(media, deps);\n-\t\tfor (const auto &dep : deps)\n-\t\t\tdevMap_[dep.first] = &pending_.back();\n-\t}\n-\n-\treturn deps.size();\n+\treturn 0;\n }\n \n /**\ndiff --git a/src/libcamera/include/device_enumerator_udev.h b/src/libcamera/include/device_enumerator_udev.h\nindex 6d8268620185..efaefe5dc4a3 100644\n--- a/src/libcamera/include/device_enumerator_udev.h\n+++ b/src/libcamera/include/device_enumerator_udev.h\n@@ -63,7 +63,7 @@ private:\n \tstd::map<dev_t, MediaDeviceDeps *> devMap_;\n \n \tint addUdevDevice(struct udev_device *dev);\n-\tint populateMediaDevice(const std::shared_ptr<MediaDevice> &media);\n+\tint populateMediaDevice(MediaDevice *media, DependencyMap *deps);\n \tstd::string lookupDeviceNode(dev_t devnum);\n \n \tint addV4L2Device(dev_t devnum);\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}