From patchwork Thu May 24 20:35:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10425493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3521260327 for ; Thu, 24 May 2018 20:37:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2407029599 for ; Thu, 24 May 2018 20:37:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17D462971B; Thu, 24 May 2018 20:37:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82BDC29599 for ; Thu, 24 May 2018 20:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034638AbeEXUhN (ORCPT ); Thu, 24 May 2018 16:37:13 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56670 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033167AbeEXUhH (ORCPT ); Thu, 24 May 2018 16:37:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 3978D286F45 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Abylay Ospan , Ezequiel Garcia Subject: [PATCH 10/20] staging: bcm2835-camera: Provide lock for vb2_queue Date: Thu, 24 May 2018 17:35:10 -0300 Message-Id: <20180524203520.1598-11-ezequiel@collabora.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180524203520.1598-1-ezequiel@collabora.com> References: <20180524203520.1598-1-ezequiel@collabora.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the device mutex to protect the vb2_queue. This allows to replace the ad-hoc wait_{prepare, finish} with vb2_ops_wait_{prepare, finish}. Signed-off-by: Ezequiel Garcia --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 24 +++++----------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index d2262275a870..2a628475a1bd 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -601,28 +601,14 @@ static void stop_streaming(struct vb2_queue *vq) v4l2_err(&dev->v4l2_dev, "Failed to disable camera\n"); } -static void bm2835_mmal_lock(struct vb2_queue *vq) -{ - struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq); - - mutex_lock(&dev->mutex); -} - -static void bm2835_mmal_unlock(struct vb2_queue *vq) -{ - struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq); - - mutex_unlock(&dev->mutex); -} - static const struct vb2_ops bm2835_mmal_video_qops = { .queue_setup = queue_setup, .buf_prepare = buffer_prepare, .buf_queue = buffer_queue, .start_streaming = start_streaming, .stop_streaming = stop_streaming, - .wait_prepare = bm2835_mmal_unlock, - .wait_finish = bm2835_mmal_lock, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, }; /* ------------------------------------------------------------------ @@ -1831,6 +1817,8 @@ static int __init bm2835_mmal_init(void) goto cleanup_gdev; } + /* v4l2 core mutex used to protect all fops and v4l2 ioctls. */ + mutex_init(&dev->mutex); dev->camera_num = camera; dev->max_width = resolutions[camera][0]; dev->max_height = resolutions[camera][1]; @@ -1875,13 +1863,11 @@ static int __init bm2835_mmal_init(void) q->ops = &bm2835_mmal_video_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + q->lock = &dev->mutex; ret = vb2_queue_init(q); if (ret < 0) goto unreg_dev; - /* v4l2 core mutex used to protect all fops and v4l2 ioctls. */ - mutex_init(&dev->mutex); - /* initialise video devices */ ret = bm2835_mmal_init_device(dev, &dev->vdev); if (ret < 0)