From patchwork Mon Nov 7 12:42:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minghsiu Tsai X-Patchwork-Id: 9415007 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 6D7C060585 for ; Mon, 7 Nov 2016 12:43:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C52C28C6A for ; Mon, 7 Nov 2016 12:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50B6C28C82; Mon, 7 Nov 2016 12:43:20 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C72DF28C6A for ; Mon, 7 Nov 2016 12:43:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3jGh-0003fS-79; Mon, 07 Nov 2016 12:43:19 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3jG4-0002kJ-MF; Mon, 07 Nov 2016 12:42:42 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 733962179; Mon, 07 Nov 2016 20:42:14 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Mon, 7 Nov 2016 20:42:13 +0800 From: Minghsiu Tsai To: Hans Verkuil , , Rob Herring , Mauro Carvalho Chehab , Matthias Brugger , Daniel Kurtz , Pawel Osciak Subject: [PATCH] [media] mtk-mdp: allocate video_device dynamically Date: Mon, 7 Nov 2016 20:42:09 +0800 Message-ID: <1478522529-57129-2-git-send-email-minghsiu.tsai@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478522529-57129-1-git-send-email-minghsiu.tsai@mediatek.com> References: <1478522529-57129-1-git-send-email-minghsiu.tsai@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161107_044241_136945_9C3810DA X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Minghsiu Tsai , srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Yingjoe Chen , Eddie Huang , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It can fix known problems with embedded video_device structs. Signed-off-by: Minghsiu Tsai --- drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 2 +- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 33 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h index 848569d..ad1cff3 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h @@ -167,7 +167,7 @@ struct mtk_mdp_dev { struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX]; struct v4l2_m2m_dev *m2m_dev; struct list_head ctx_list; - struct video_device vdev; + struct video_device *vdev; struct v4l2_device v4l2_dev; struct workqueue_struct *job_wq; struct platform_device *vpu_dev; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index 9a747e7..b8dee1c 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -1236,16 +1236,22 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp) int ret; mdp->variant = &mtk_mdp_default_variant; - mdp->vdev.device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; - mdp->vdev.fops = &mtk_mdp_m2m_fops; - mdp->vdev.ioctl_ops = &mtk_mdp_m2m_ioctl_ops; - mdp->vdev.release = video_device_release_empty; - mdp->vdev.lock = &mdp->lock; - mdp->vdev.vfl_dir = VFL_DIR_M2M; - mdp->vdev.v4l2_dev = &mdp->v4l2_dev; - snprintf(mdp->vdev.name, sizeof(mdp->vdev.name), "%s:m2m", + mdp->vdev = video_device_alloc(); + if (!mdp->vdev) { + dev_err(dev, "failed to allocate video device\n"); + ret = -ENOMEM; + goto err_video_alloc; + } + mdp->vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; + mdp->vdev->fops = &mtk_mdp_m2m_fops; + mdp->vdev->ioctl_ops = &mtk_mdp_m2m_ioctl_ops; + mdp->vdev->release = video_device_release; + mdp->vdev->lock = &mdp->lock; + mdp->vdev->vfl_dir = VFL_DIR_M2M; + mdp->vdev->v4l2_dev = &mdp->v4l2_dev; + snprintf(mdp->vdev->name, sizeof(mdp->vdev->name), "%s:m2m", MTK_MDP_MODULE_NAME); - video_set_drvdata(&mdp->vdev, mdp); + video_set_drvdata(mdp->vdev, mdp); mdp->m2m_dev = v4l2_m2m_init(&mtk_mdp_m2m_ops); if (IS_ERR(mdp->m2m_dev)) { @@ -1254,26 +1260,27 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp) goto err_m2m_init; } - ret = video_register_device(&mdp->vdev, VFL_TYPE_GRABBER, 2); + ret = video_register_device(mdp->vdev, VFL_TYPE_GRABBER, 2); if (ret) { dev_err(dev, "failed to register video device\n"); goto err_vdev_register; } v4l2_info(&mdp->v4l2_dev, "driver registered as /dev/video%d", - mdp->vdev.num); + mdp->vdev->num); return 0; err_vdev_register: v4l2_m2m_release(mdp->m2m_dev); err_m2m_init: - video_device_release(&mdp->vdev); + video_unregister_device(mdp->vdev); +err_video_alloc: return ret; } void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp) { - video_device_release(&mdp->vdev); + video_unregister_device(mdp->vdev); v4l2_m2m_release(mdp->m2m_dev); }