Show a patch.

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

{
    "id": 2256,
    "url": "https://patchwork.libcamera.org/api/patches/2256/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2256/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20191028022224.795355-7-niklas.soderlund@ragnatech.se>",
    "date": "2019-10-28T02:22:20",
    "name": "[libcamera-devel,06/10] libcamera: v4l2_videodevice: Simplify error checking for requestBuffers()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0e1417de49c996b406d5599338c6b7b076132661",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2256/mbox/",
    "series": [
        {
            "id": 560,
            "url": "https://patchwork.libcamera.org/api/series/560/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=560",
            "date": "2019-10-28T02:22:14",
            "name": "libcamera: Fixes found while working on new buffer API",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/560/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2256/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2256/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA6256139C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 03:22:48 +0100 (CET)",
            "from localhost.localdomain (unknown [93.2.121.143])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid d34a2ef7-f929-11e9-903a-005056917f90;\n\tMon, 28 Oct 2019 03:22:44 +0100 (CET)"
        ],
        "X-Halon-ID": "d34a2ef7-f929-11e9-903a-005056917f90",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 28 Oct 2019 03:22:20 +0100",
        "Message-Id": "<20191028022224.795355-7-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191028022224.795355-1-niklas.soderlund@ragnatech.se>",
        "References": "<20191028022224.795355-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 06/10] libcamera: v4l2_videodevice:\n\tSimplify error checking for requestBuffers()",
        "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": "Mon, 28 Oct 2019 02:22:49 -0000"
    },
    "content": "There is no point in explicitly checking the same error in the only call\nsites for the internal function, centralize the check and simplify the\ncode.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/v4l2_videodevice.cpp | 31 ++++++++++--------------------\n 1 file changed, 10 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 208ab54199b141c3..a2a9eab2bcc0d7e8 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -819,9 +819,16 @@ int V4L2VideoDevice::requestBuffers(unsigned int count)\n \t\treturn ret;\n \t}\n \n+\tif (rb.count < count) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Not enough buffers provided by V4L2VideoDevice\";\n+\t\trequestBuffers(0);\n+\t\treturn -ENOMEM;\n+\t}\n+\n \tLOG(V4L2, Debug) << rb.count << \" buffers requested.\";\n \n-\treturn rb.count;\n+\treturn 0;\n }\n \n /**\n@@ -832,24 +839,15 @@ int V4L2VideoDevice::requestBuffers(unsigned int count)\n  */\n int V4L2VideoDevice::exportBuffers(BufferPool *pool)\n {\n-\tunsigned int allocatedBuffers;\n \tunsigned int i;\n \tint ret;\n \n \tmemoryType_ = V4L2_MEMORY_MMAP;\n \n \tret = requestBuffers(pool->count());\n-\tif (ret < 0)\n+\tif (ret)\n \t\treturn ret;\n \n-\tallocatedBuffers = ret;\n-\tif (allocatedBuffers < pool->count()) {\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Not enough buffers provided by V4L2VideoDevice\";\n-\t\trequestBuffers(0);\n-\t\treturn -ENOMEM;\n-\t}\n-\n \t/* Map the buffers. */\n \tfor (i = 0; i < pool->count(); ++i) {\n \t\tstruct v4l2_plane planes[VIDEO_MAX_PLANES] = {};\n@@ -936,23 +934,14 @@ int V4L2VideoDevice::createPlane(BufferMemory *buffer, unsigned int index,\n  */\n int V4L2VideoDevice::importBuffers(BufferPool *pool)\n {\n-\tunsigned int allocatedBuffers;\n \tint ret;\n \n \tmemoryType_ = V4L2_MEMORY_DMABUF;\n \n \tret = requestBuffers(pool->count());\n-\tif (ret < 0)\n+\tif (ret)\n \t\treturn ret;\n \n-\tallocatedBuffers = ret;\n-\tif (allocatedBuffers < pool->count()) {\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Not enough buffers provided by V4L2VideoDevice\";\n-\t\trequestBuffers(0);\n-\t\treturn -ENOMEM;\n-\t}\n-\n \tLOG(V4L2, Debug) << \"provided pool of \" << pool->count() << \" buffers\";\n \tbufferPool_ = pool;\n \n",
    "prefixes": [
        "libcamera-devel",
        "06/10"
    ]
}