From patchwork Tue Jun 21 16:34:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 584111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8371CCA473 for ; Tue, 21 Jun 2022 16:35:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352857AbiFUQfG (ORCPT ); Tue, 21 Jun 2022 12:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351517AbiFUQfE (ORCPT ); Tue, 21 Jun 2022 12:35:04 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42EC22A255 for ; Tue, 21 Jun 2022 09:35:03 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id h14-20020a1ccc0e000000b0039eff745c53so3420396wmb.5 for ; Tue, 21 Jun 2022 09:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ikPqVfIj+7XxQ7IV8Dt/cvK1XPLZfzxNSdqUyqBY9Fk=; b=ABMIFd19+fr+xk5NR+jK6boP7cRv+yIxt2XFrr3yJrDCl2wRWeA2LbLSgQgCsu4TMr tJshStCPRR+56713bcVZvdJ3H+uWma+Ohr0CELBgRuW9fk+roLy+Rsy5x1GnFbplYLAC 7F03Xd4vufSBsa8trgp9ZJUcpzJAIny+pfLkzszrmWQMuIc1Qn/MbQyKgS7Xhar4G2hz AvIL3z6tUZexYtjZooq+QqAvbxi9JnH1HnozFuG7elshyJ9VNAHw6ZjDujOYs9hqrbuD hARNK2VbnrQcXN2F3UKIiqTtEVCxk9D5w6FcQG9jNaJypJ/q8jHW4DVv7mc1/+liChLb ONPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ikPqVfIj+7XxQ7IV8Dt/cvK1XPLZfzxNSdqUyqBY9Fk=; b=5WetpysG3BDySG1WP2e0l+4XKSk832hXd7t5vTawvVAWnupMlueCJ482/SS7cuZ8pu XSTTyeAYXeekHvcwqXqWz1cqUsHVVygfrF2LsKJ9RHzER7jR9YJF+Ael2XEIn10018R+ VB50MFTwRKFNRr2Ow/bqMObyzNXGVYZ+fzTOqXtLz4ePB1F4X4Kevlc0bVXYFesvo12G C2kScOpP0I/Mkbh/yPfGu8B+DxBMd2MU9nt00DGCveQURFZ0aM6GxcR6Zg6dNiAU6vqR AnuE9wM7Hh4lGPBJC4wOf23xwh04kCkyBVkRqz54vbZ6euTdJ8iNr0/Cvv64YInGyX/F S+qw== X-Gm-Message-State: AOAM531XVt4KJLweWDI/Uf8SRrTlUQ20y2BbULGOWyus5CvVjqdFg68X k4j6nl5HgDO0JHEj5jvF8SHUOfJfnFE= X-Google-Smtp-Source: ABdhPJzPKuTJjt/5g+USZb/25f/igzUgBs3+d6RsPBUHKqZPk6cXkUtw9a2LeAenQI+sRGYFPo9B8w== X-Received: by 2002:a05:600c:1ca5:b0:39b:a66b:7805 with SMTP id k37-20020a05600c1ca500b0039ba66b7805mr40298975wms.87.1655829301792; Tue, 21 Jun 2022 09:35:01 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id v184-20020a1cacc1000000b0039c454067ddsm18649887wme.15.2022.06.21.09.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 09:35:01 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, paul.elder@ideasonboard.com Subject: [PATCH 1/2] media: media-entity.h: Add iterator for entity data links Date: Tue, 21 Jun 2022 17:34:56 +0100 Message-Id: <20220621163457.766496-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621163457.766496-1-djrscally@gmail.com> References: <20220621163457.766496-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Iterating over the links for an entity is a somewhat common need through the media subsystem, but generally the assumption is that they will all be data links. To meet that assumption add a new macro that iterates through an entity's links and skips non-data links. Signed-off-by: Daniel Scally --- include/media/media-entity.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a9a1c0ec5d1c..b13f67f33508 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -550,6 +550,32 @@ static inline bool media_entity_enum_intersects( min(ent_enum1->idx_max, ent_enum2->idx_max)); } +static inline struct media_link * +__media_entity_next_data_link(struct media_entity *entity, + struct media_link *pos) +{ + if (!pos) { + list_for_each_entry(pos, &entity->links, list) + if ((pos->flags & MEDIA_LNK_FL_LINK_TYPE) == + MEDIA_LNK_FL_DATA_LINK) + return pos; + + return NULL; + } + + list_for_each_entry_continue(pos, &entity->links, list) + if ((pos->flags & MEDIA_LNK_FL_LINK_TYPE) == + MEDIA_LNK_FL_DATA_LINK) + return pos; + + return NULL; +} + +#define for_each_media_entity_data_link(entity, pos) \ + for (pos = __media_entity_next_data_link(entity, NULL); \ + pos; \ + pos = __media_entity_next_data_link(entity, pos)) + /** * gobj_to_entity - returns the struct &media_entity pointer from the * @gobj contained on it. From patchwork Tue Jun 21 16:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 583753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 864F9C433EF for ; Tue, 21 Jun 2022 16:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352902AbiFUQfG (ORCPT ); Tue, 21 Jun 2022 12:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352486AbiFUQfF (ORCPT ); Tue, 21 Jun 2022 12:35:05 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF092A729 for ; Tue, 21 Jun 2022 09:35:04 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id a10so7803850wmj.5 for ; Tue, 21 Jun 2022 09:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eg+EwYeQfLen8K8rKVkBgSycceBY/89PL9/DRUnl5b0=; b=CDo0Tp5SqLceA6R+yfUF658/Y1p3KZcdoCRqpc4wHVOt+roqX5h6LttaoKlaig7igf kuD3POYyOKZvnjbhGwvWX82pMKV5xsiVPQcSSyl5AbBKpHZsNN1ON2Wsa2jdpdFjN0hA 1BzakBzn8YkGSafJxIOi2SOH3i15j7DheqAlvfQoEO141T9pT1kFHuRt6g5xb5WAsgLX GaEs75yvqy1Jp9fvoZr/Vk1sPM2t9OmbFo6vkpaNyLKUxmYJVBErIgamurO2+NDdyePW yk6ZWzo6WFgbgq+NxG+CzCeukF2SD6bKNyaATYFpo2X1hB06ZmmVi9wvEqRuMbihCy9w i46A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Eg+EwYeQfLen8K8rKVkBgSycceBY/89PL9/DRUnl5b0=; b=FbWR4TQ0twgHHhoG1+pWxKKTkSCuWVYCi3nloKfy2frchRI7S8iph9pOB24HT9OaKt AJMHKX9YG0ZmRRM+P1BkL+7rbP4MpE6LYZ+QOt6BPX7UqrrdS6OjS4xI/26VV7KmgT54 IS5Y/QutSrJA02uU9gdUJtbuC7K616ISDymQbliXs7grB2JQAcPQNLeZPjpFk/jhHAQ4 /FKhIl55854DiVlO78Ece4Af5kMfi1Cl7T5s3KQkfflfuSiStlSsbSFhjCE1iVu9wwbA R9x7/mMJuM8decZvnTiGbW2vd8lfg/qggkQwxjRQBofINtdNLftdVQO7A4aKPapoogbD 3eeQ== X-Gm-Message-State: AJIora/nFh0AYCJ61UbieRFUE+VSuL4vsb+PwoUdcd2p3VxDIrJiNsy8 WYq4H0qZeX22OeqUe1D5IbRwNm9EpIk= X-Google-Smtp-Source: AGRyM1s0HrwQygnfrs3Qr9xRiB8YupbWgaF2awz9mMy4XrQzHNozoiRJRuKUBxi/zgoAI7RJYbGwxQ== X-Received: by 2002:a7b:c856:0:b0:39c:3b44:7ab0 with SMTP id c22-20020a7bc856000000b0039c3b447ab0mr31438076wml.117.1655829302744; Tue, 21 Jun 2022 09:35:02 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id v184-20020a1cacc1000000b0039c454067ddsm18649887wme.15.2022.06.21.09.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 09:35:02 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, paul.elder@ideasonboard.com Subject: [PATCH 2/2] media: entity: Use dedicated data link iterator Date: Tue, 21 Jun 2022 17:34:57 +0100 Message-Id: <20220621163457.766496-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621163457.766496-1-djrscally@gmail.com> References: <20220621163457.766496-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Where iteration over links for an entity is clearly assuming that all of those links are data links, use the new iterator to guarantee that that assumption is met. Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- drivers/media/mc/mc-entity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 11f5207f73aa..f46690fd141d 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -449,7 +449,7 @@ __must_check int __media_pipeline_start(struct media_entity *entity, bitmap_zero(active, entity->num_pads); bitmap_fill(has_no_links, entity->num_pads); - list_for_each_entry(link, &entity->links, list) { + for_each_media_entity_data_link(entity, link) { struct media_pad *pad = link->sink->entity == entity ? link->sink : link->source; @@ -888,7 +888,7 @@ media_entity_find_link(struct media_pad *source, struct media_pad *sink) { struct media_link *link; - list_for_each_entry(link, &source->entity->links, list) { + for_each_media_entity_data_link(source->entity, link) { if (link->source->entity == source->entity && link->source->index == source->index && link->sink->entity == sink->entity && @@ -904,7 +904,7 @@ struct media_pad *media_entity_remote_pad(const struct media_pad *pad) { struct media_link *link; - list_for_each_entry(link, &pad->entity->links, list) { + for_each_media_entity_data_link(pad->entity, link) { if (!(link->flags & MEDIA_LNK_FL_ENABLED)) continue;