From patchwork Tue Dec 3 13:12:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 3275781 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECB469F380 for ; Tue, 3 Dec 2013 13:13:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 400482037E for ; Tue, 3 Dec 2013 13:13:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D0C720268 for ; Tue, 3 Dec 2013 13:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754258Ab3LCNNL (ORCPT ); Tue, 3 Dec 2013 08:13:11 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:17949 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209Ab3LCNNI (ORCPT ); Tue, 3 Dec 2013 08:13:08 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MX8008Q6FDUZZD0@mailout2.samsung.com>; Tue, 03 Dec 2013 22:13:06 +0900 (KST) X-AuditID: cbfee61a-b7f796d000004313-d4-529dd8e230fe Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AA.B1.17171.2E8DD925; Tue, 03 Dec 2013 22:13:06 +0900 (KST) Received: from amdc1339.mshome.net ([106.116.147.30]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MX800HWMFDK8740@mmp2.samsung.com>; Tue, 03 Dec 2013 22:13:06 +0900 (KST) From: Marek Szyprowski To: linux-media@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Kamil Debski , lxr1234@hotmail.com, jtp.park@samsung.com, m.chehab@samsung.com, kyungmin.park@samsung.com, stable@vger.kernel.org Subject: [PATCH] media: s5p_mfc: remove s5p_mfc_get_node_type() function Date: Tue, 03 Dec 2013 14:12:51 +0100 Message-id: <1386076371-26699-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t9jQd1HN+YGGfz9pWJxZO1VJosfry+w WZxtesNu0bNhK6vF1tdHWCwurpO3WHvkLrvF4TftrBYLNj5idOD0eNxzhs2jb8sqRo/Pm+QC mKO4bFJSczLLUov07RK4MtqWb2ApeKtQsW/mbLYGxpnSXYycHBICJhLr5x1mhbDFJC7cW88G YgsJTGeUODDJAsJuZZJ486sKxGYTMJToetsFViMiIC/xpPcGkM3FwSzwl1HiyodJjCAJYQEP iR+7eoBsDg4WAVWJDVd5QMK8QOG1x14xg4QlBBQk5kyymcDIvYCRYRWjaGpBckFxUnquoV5x Ym5xaV66XnJ+7iZGcHg8k9rBuLLB4hCjAAejEg/vg+1zgoRYE8uKK3MPMUpwMCuJ8BqcnRsk xJuSWFmVWpQfX1Sak1p8iFGag0VJnPdAq3WgkEB6YklqdmpqQWoRTJaJg1OqgdEs4TB/RNOu k61lPuHcavJpaV8Y/PkWlusfZ9fW+c/l9fyy7psvFv1bV/k/ko3eKP3oSGOq7rmNBq4X9x96 /HTRC8Zktp2ryz2C/qrcsIj/fPti+bwD36J6rVekVXMXuO1nkGXb0uMQf884ZfL31TsVfn8P eBz0LytIIbH228fZa+5ePrf4eIASS3FGoqEWc1FxIgCnxKPCCwIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP s5p_mfc_get_node_type() relies on get_index() helper function, which in turn relies on video_device index numbers assigned on driver registration. All this code is not really needed, because there is already access to respective video_device structures via common s5p_mfc_dev structure. This fixes the issues introduced by patch 1056e4388b0454917a512618c8416a98628fc9ce ("v4l2-dev: Fix race condition on __video_register_device"), which has been merged in v3.12-rc1. Signed-off-by: Marek Szyprowski Cc: stable@vger.kernel.org --- This patch should be applied also to stable v3.12 series. --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 28 ++++++----------------- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 9 -------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 80562809b28a..bd750a1e8632 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -178,21 +178,6 @@ unlock: mutex_unlock(&dev->mfc_mutex); } -static enum s5p_mfc_node_type s5p_mfc_get_node_type(struct file *file) -{ - struct video_device *vdev = video_devdata(file); - - if (!vdev) { - mfc_err("failed to get video_device"); - return MFCNODE_INVALID; - } - if (vdev->index == 0) - return MFCNODE_DECODER; - else if (vdev->index == 1) - return MFCNODE_ENCODER; - return MFCNODE_INVALID; -} - static void s5p_mfc_clear_int_flags(struct s5p_mfc_dev *dev) { mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT); @@ -706,6 +691,7 @@ irq_cleanup_hw: /* Open an MFC node */ static int s5p_mfc_open(struct file *file) { + struct video_device *vdev = video_devdata(file); struct s5p_mfc_dev *dev = video_drvdata(file); struct s5p_mfc_ctx *ctx = NULL; struct vb2_queue *q; @@ -743,7 +729,7 @@ static int s5p_mfc_open(struct file *file) /* Mark context as idle */ clear_work_bit_irqsave(ctx); dev->ctx[ctx->num] = ctx; - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { + if (vdev == dev->vfd_dec) { ctx->type = MFCINST_DECODER; ctx->c_ops = get_dec_codec_ops(); s5p_mfc_dec_init(ctx); @@ -753,7 +739,7 @@ static int s5p_mfc_open(struct file *file) mfc_err("Failed to setup mfc controls\n"); goto err_ctrls_setup; } - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { + } else if (vdev == dev->vfd_enc) { ctx->type = MFCINST_ENCODER; ctx->c_ops = get_enc_codec_ops(); /* only for encoder */ @@ -798,10 +784,10 @@ static int s5p_mfc_open(struct file *file) q = &ctx->vq_dst; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q->drv_priv = &ctx->fh; - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { + if (vdev == dev->vfd_dec) { q->io_modes = VB2_MMAP; q->ops = get_dec_queue_ops(); - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { + } else if (vdev == dev->vfd_enc) { q->io_modes = VB2_MMAP | VB2_USERPTR; q->ops = get_enc_queue_ops(); } else { @@ -820,10 +806,10 @@ static int s5p_mfc_open(struct file *file) q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; q->io_modes = VB2_MMAP; q->drv_priv = &ctx->fh; - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { + if (vdev == dev->vfd_dec) { q->io_modes = VB2_MMAP; q->ops = get_dec_queue_ops(); - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { + } else if (vdev == dev->vfd_enc) { q->io_modes = VB2_MMAP | VB2_USERPTR; q->ops = get_enc_queue_ops(); } else { diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 6920b546181a..823812c6b9b0 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -115,15 +115,6 @@ enum s5p_mfc_fmt_type { }; /** - * enum s5p_mfc_node_type - The type of an MFC device node. - */ -enum s5p_mfc_node_type { - MFCNODE_INVALID = -1, - MFCNODE_DECODER = 0, - MFCNODE_ENCODER = 1, -}; - -/** * enum s5p_mfc_inst_type - The type of an MFC instance. */ enum s5p_mfc_inst_type {