From patchwork Wed Jul 25 16:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 142864 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1028124ljj; Wed, 25 Jul 2018 09:39:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgperrxfwXtgekBXH/6xFplc/fHVMCigt4/zxe0cbIF5CdeRfmTIH8YAytYngr8n94vxVjrij X-Received: by 2002:a17:902:28aa:: with SMTP id f39-v6mr2069188plb.150.1532536741472; Wed, 25 Jul 2018 09:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532536741; cv=none; d=google.com; s=arc-20160816; b=LmEi9zNIedNwdaFfWtb9roUrSpyEbfCB1P9qNwl9SrLPsPpOAqjlaaCZn4iW5zEdjX 9rf08hoRJmgaKn69dpNyvtLAlTFW3e0owQklcz1g4hiIbACFaAywyxNdi/qWH0B/zUme fAk1bbtbN2cPXxfmkSsPqZRVfr8mha1o1JPAG58osmcWg1YI2hT6oMiOgvbEZSX76VML 2+7wpCo/ZHs4Bs1VWp0wj/LhTDVY3lB1QVuDFgBegrkCafHW3n1raqEWqnYRGCiaYJAT 38p1VxWH/V+jK3YOK2mlyl7+lHBLVA7njENWBYTqaHHG/yO8F5gNtpZYeiSjz1+SDGfq 7ZeA== 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=FqE6HT3Gdyjd7kGyQly0X/qmPpC1XWyQ7Ky7sy0BoirgaSZJVxFdAbLftAXbJQe0yU W3Hv6RvcKgWKp/AUahnkQxkRo1CCu7ajMZL0NkzEjQKW2PDDoSQNHH+XqCEf7ZLbFIy8 cMRAlEJjI28bDH2jED8JhV+pWSv7L2Tv/QLUspVL5+92u8JvTcPGCRSkdo27vB9CkAiJ YOJ1JhXNAjkAwirpopRO15hE3ETp0sx6zDYN+HF5qdT3KfERbXA5ZZntm7oY0vYEuq+K HOFqhVbKK2hN7YSsGDYjlP0LFG8s7j7nk2V2jEnU/c2m+IDBqqBHSBHCKwR9ul7CgufP bJBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 62-v6si13602946ply.520.2018.07.25.09.39.01; Wed, 25 Jul 2018 09:39:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 S1730171AbeGYRv0 (ORCPT + 4 others); Wed, 25 Jul 2018 13:51:26 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:35576 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbeGYRv0 (ORCPT ); Wed, 25 Jul 2018 13:51:26 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 1EDC8CD5F; Wed, 25 Jul 2018 19:38:54 +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 v4 13/34] media: camss: vfe: Get line pointer as container of video_out Date: Wed, 25 Jul 2018 19:38:22 +0300 Message-Id: <1532536723-19062-14-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532536723-19062-1-git-send-email-todor.tomov@linaro.org> References: <1532536723-19062-1-git-send-email-todor.tomov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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);