From patchwork Sat Jul 13 17:23:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1683 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A93E6175D for ; Sat, 13 Jul 2019 19:24:28 +0200 (CEST) Received: from pendragon.ideasonboard.com (softbank126209254147.bbtec.net [126.209.254.147]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD85A2B2 for ; Sat, 13 Jul 2019 19:24:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1563038667; bh=CgQ2O/+AQhBnbdoGGmgOysR85DTzo4B4OUSV1DEUV4o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HwJBjqfDgOfFTNdLG9507rho6r9AQGtQJirAw5eEO1uuI1sQ2rV3vA1rPUFr/CyJy 9Clhc/XoAsy905aMjUu9pFahDjP2Pmz/ODTqVu8wG/XP+w4zGL0GDaRQh42ccklELA 0kcV1zahq5EbupRw+SJTzkmlKfrHs2oo9w11+jWU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 13 Jul 2019 20:23:37 +0300 Message-Id: <20190713172351.25452-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190713172351.25452-1-laurent.pinchart@ideasonboard.com> References: <20190713172351.25452-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/16] libcamera: camera: Don't check buffer count before freeing buffers 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: Sat, 13 Jul 2019 17:24:28 -0000 There's no need to check if buffers have been allocated before freeing them as the BufferPool::destroyBuffers() method is a no-op when no buffers have been allocated. Document this fact explicitly, and remove the buffer count check. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/buffer.cpp | 3 +++ src/libcamera/camera.cpp | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index d86278a8a90a..c0a020942f5c 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -311,6 +311,9 @@ void BufferPool::createBuffers(unsigned int count) /** * \brief Release all buffers from pool + * + * If no buffers have been created or if buffers have already been released no + * operation is performed. */ void BufferPool::destroyBuffers() { diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 094f1b63b7f1..810cb1295f34 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -740,9 +740,6 @@ int Camera::freeBuffers() return -EACCES; for (Stream *stream : activeStreams_) { - if (!stream->bufferPool().count()) - continue; - /* * All mappings must be destroyed before buffers can be freed * by the V4L2 device that has allocated them.