From patchwork Fri Jun 22 15:33:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 139708 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1023794lji; Fri, 22 Jun 2018 08:41:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKPNNgBBcs9Nb+roO75nGugHSgPMyvmyh3lre+4kxSx0nL7kLdVu2sjpuYxGZ5NZzvCgC6Q X-Received: by 2002:a17:902:ab95:: with SMTP id f21-v6mr2199252plr.264.1529682101245; Fri, 22 Jun 2018 08:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529682101; cv=none; d=google.com; s=arc-20160816; b=t5cqGveP1MGs8kpeWokTT6zHI9eqqy8dbVcQFF7xBTgIVct+xr3dmf/iCJjMMvwa7q MDIjEsmB11maszExk4UGwSsqxEsSD7nPmCEVZTb1BoknpDH9NieLkjk3QmdZe5AWQSNo 9zmD4VM73urR2+GLf9NkdD7WBcE+zO2tnt9Sqnbn9FJkXjKo6SMKBnwGiqCSp+EldAvX IKsw55alVGCRI85+kdWJtDInTA6gxsnhFSvxZs4tV8/Sr9g16Vo1e2kplcE9567BjDHp czfXTlhNb81Q+J+hUOC7ycOhKSIYdPfJZV+LC8W0/Ah8Zt/Inmyy6YRdyyt2PtmpbJ3P DyuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4wsHeZPFiY6afuYTlWK9WhEH08a/4OUGQ13ChPWDPAo=; b=ly8ccXowF6lntUPPF3S+ZbfB5iaS88JbiyxiFWbav5G5ZAtsdoMUkkS9o2vqN3zXCz DUQzQvBKy8WftU+8mnhZ3j55IbponC40P/Fup+SQR3g1pydzbrwHPbjzuQHnO31MUsQF yrmyC3Pwjt+Um14y7t//k3g4K8XiDjhKm7JXoh1oiAs7BhHr2ZWl/xiJ3nFaimcGhlcs JdrzwhW+8X2IvVIKZgPmX5c1P+tM3N4m9Bi9aAuNYyA7Px6/xjIV4CIWgverXvKytFT7 Dy5LQI2z5a1OKXopHEHxsZTJQzCMmqP7TWaqTM+UseSbxezYJyGtV3cwfdfdZ2HaNtgF agEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b35-v6si7810543plh.36.2018.06.22.08.41.40; Fri, 22 Jun 2018 08:41:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934058AbeFVPjm (ORCPT + 31 others); Fri, 22 Jun 2018 11:39:42 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:46447 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933976AbeFVPeE (ORCPT ); Fri, 22 Jun 2018 11:34:04 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 50E804F888; Fri, 22 Jun 2018 18:33:59 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hans.verkuil@cisco.com, laurent.pinchart+renesas@ideasonboard.com, linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Todor Tomov Subject: [PATCH 12/32] media: camss: vfe: Get line pointer as container of video_out Date: Fri, 22 Jun 2018 18:33:21 +0300 Message-Id: <1529681621-9682-13-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529681621-9682-1-git-send-email-todor.tomov@linaro.org> References: <1529681621-9682-1-git-send-email-todor.tomov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify getting of the line pointer by using the container_of macro instead of traversing media controller links. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss/camss-vfe.c | 38 +++------------------------ 1 file changed, 4 insertions(+), 34 deletions(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 51ad3f8..77167f1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -2038,26 +2038,6 @@ static void vfe_put(struct vfe_device *vfe) } /* - * vfe_video_pad_to_line - Get pointer to VFE line by media pad - * @pad: Media pad - * - * Return pointer to vfe line structure - */ -static struct vfe_line *vfe_video_pad_to_line(struct media_pad *pad) -{ - struct media_pad *vfe_pad; - struct v4l2_subdev *subdev; - - vfe_pad = media_entity_remote_pad(pad); - if (vfe_pad == NULL) - return NULL; - - subdev = media_entity_to_v4l2_subdev(vfe_pad->entity); - - return container_of(subdev, struct vfe_line, subdev); -} - -/* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure * @buf: Buffer to be enqueued @@ -2070,16 +2050,11 @@ static struct vfe_line *vfe_video_pad_to_line(struct media_pad *pad) static int vfe_queue_buffer(struct camss_video *vid, struct camss_buffer *buf) { - struct vfe_device *vfe = &vid->camss->vfe; - struct vfe_line *line; + struct vfe_line *line = container_of(vid, struct vfe_line, video_out); + struct vfe_device *vfe = to_vfe(line); struct vfe_output *output; unsigned long flags; - line = vfe_video_pad_to_line(&vid->pad); - if (!line) { - dev_err(to_device(vfe), "Can not queue buffer\n"); - return -1; - } output = &line->output; spin_lock_irqsave(&vfe->output_lock, flags); @@ -2104,16 +2079,11 @@ static int vfe_queue_buffer(struct camss_video *vid, static int vfe_flush_buffers(struct camss_video *vid, enum vb2_buffer_state state) { - struct vfe_device *vfe = &vid->camss->vfe; - struct vfe_line *line; + struct vfe_line *line = container_of(vid, struct vfe_line, video_out); + struct vfe_device *vfe = to_vfe(line); struct vfe_output *output; unsigned long flags; - line = vfe_video_pad_to_line(&vid->pad); - if (!line) { - dev_err(to_device(vfe), "Can not flush buffers\n"); - return -1; - } output = &line->output; spin_lock_irqsave(&vfe->output_lock, flags);