From patchwork Thu Dec 17 23:43:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2749C35270 for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D732F23441 for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732278AbgLQXog (ORCPT ); Thu, 17 Dec 2020 18:44:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732201AbgLQXof (ORCPT ); Thu, 17 Dec 2020 18:44:35 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8C77C0617A7; Thu, 17 Dec 2020 15:43:54 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 3so559247wmg.4; Thu, 17 Dec 2020 15:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MGjgXza+FG01h/JQoRfmC2web91PoTk50kjVfFmC+Bk=; b=rrPRKNOXArB8EfEK9dLFvQBlLOialUzkQJzDKZTV7W2AhNCRFWtQCObbaPjbbB5nsC ln0NgkU9Y7P/tfB5lzhCk+pCcfnV87PMdCD26G8/VqFzVbKBLE/NqrmgnDWYF/PdLg4R d7szjyZw2dDGXQXDWt6fsmZUMo5youg442pZ7xrrldIRGMayHn5iCrPA5/hNpLKOGLm6 bMgi1gSnxxG7cu+HbB3qysA7FXl8mUovsvzN+f4wo82V8Zc/76vBKW1Lf0dA8NKbIVTm xblbMBqyX/6trN6Pradf4hZK17t8cpsq4mbJn6gI7o8xnbwHRjcXapOpgoPO2ofLdc6Y FLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MGjgXza+FG01h/JQoRfmC2web91PoTk50kjVfFmC+Bk=; b=L3nCnBFJ037RO2Vb9Aubro1Na1r6Tk1X96peKTM+VU5XVZmQRunU1f3POpUFvn/BQM k9goucwAiObhKNp9zoiHzw0JFjrUOrlcySITHyRG9A8FNFXsABKArmrhz8MWXOehIUtx gFPk7Cxe9QBxhKptIxdLu7joPX9UFw/dmTQzjI/NqzpQGOhtfTtJSOkxdJGy2+FFq6Bh ypOA97KAeo0UXpnGG+A4o1er11CfvHC44S89/w+GAnVhZqs4TXXhMTihOTp9bFJY3fy/ QQ24w2neEJZktbcD+yxMxAjrRo/xAo0nfBVeONCDgSFY9/IKs82mXsrC37Ge0zm5rWyQ gSAg== X-Gm-Message-State: AOAM530i4Rog7228j6+y+jixUTglmAcnLppow+tBVkG/zYgg83qp0eMz VTPuQLn+mji6VWvgLsCOws37X8wFdyDG1GW6 X-Google-Smtp-Source: ABdhPJzwmyCMhBM+WTNgZczB1JPvQA344VXaJM58xVEVaqhr6tzOBXfPz9up3q+ofqYPcrGJRCxkOg== X-Received: by 2002:a1c:6a13:: with SMTP id f19mr1586073wmc.10.1608248633449; Thu, 17 Dec 2020 15:43:53 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:52 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 01/12] software_node: Fix refcounts in software_node_get_next_child() Date: Thu, 17 Dec 2020 23:43:26 +0000 Message-Id: <20201217234337.1983732-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The software_node_get_next_child() function currently does not hold references to the child software_node that it finds or put the ref that is held against the old child - fix that. Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework") Reviewed-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally Reviewed-by: Sakari Ailus --- Changes in v2: - None drivers/base/swnode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 010828fc785b..615a0c93e116 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -443,14 +443,18 @@ software_node_get_next_child(const struct fwnode_handle *fwnode, struct swnode *c = to_swnode(child); if (!p || list_empty(&p->children) || - (c && list_is_last(&c->entry, &p->children))) + (c && list_is_last(&c->entry, &p->children))) { + fwnode_handle_put(child); return NULL; + } if (c) c = list_next_entry(c, entry); else c = list_first_entry(&p->children, struct swnode, entry); - return &c->fwnode; + + fwnode_handle_put(child); + return fwnode_handle_get(&c->fwnode); } static struct fwnode_handle * From patchwork Thu Dec 17 23:43:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B7E4C3526B for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6473A22511 for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732331AbgLQXoj (ORCPT ); Thu, 17 Dec 2020 18:44:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732282AbgLQXog (ORCPT ); Thu, 17 Dec 2020 18:44:36 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E061C0617B0; Thu, 17 Dec 2020 15:43:56 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id e25so577361wme.0; Thu, 17 Dec 2020 15:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Y7dtEvdcKPvLmik/Dt9S23LzcoiYY1794f++x+MfCQ=; b=JPrmEJbHxNUecfqssmn8/wie5GeVJTxzyA/rn6Rl4j5dA+Lp0GclYozolxTQAz9m58 HuHSCOz9dq0rYQO+kdhNjQ2Y5pBrA77mmOnDnSzLbo0RxurHLK+O9G/M2be+fgqhKlxl CrhN+wkvm31vU3J9xq+CJPtk66L172qvISTu9m6mBb32vWOS9CDLnR2XnYWXu7gQz98f 8u4FZgL89rzEpfz711/RLQ08FMkrpi9wIAcH+OYcHM0Dh7A81XYiLLX0UI4YkXlYZQzL As2eJubSy6izXowULubnqZvgwUL27qhshq+vpa/z0YJfFtBPqTcejDuTFPlx2gkcEQxO b+8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Y7dtEvdcKPvLmik/Dt9S23LzcoiYY1794f++x+MfCQ=; b=Q5B0n7uNG/Emwkgcz0G1p/tiELboFg2w7i/uA/1jruYgazvoj1gcr+uu8Zb3SuB+93 7ltan9bq8jgKLwGFcGZ+v9KyFk/Miqq86JxHSylZGc5e5ocXTXfwRQvtn9jOXLpVwlPV L00ZlVox9HKaV0ai/JPJzqlho2oVuFHtSulr85oK0ke2p1zNFWmGLj6jaXW3roPFicCf Np8zPI9jv1Mak22tALJL1KJbA6wT2dOGJYfoSfIJXT56K4M2sFYeXjnWLeF8/R3/WN1W hW9zy6NG6oFSZZJA+FqvrypDCNuC7yFA06/ZXBjAnft5aRn8hSH8+75vMLefkG+rlCOL otYA== X-Gm-Message-State: AOAM533Pv1qLl+K5s0XUk9aAdRUdV47b3BhIw9semWm7DSTuLd/7G+0l 5bolZFmhwChcCymwKdUrE/Vwu1GlOmxw8Kjg X-Google-Smtp-Source: ABdhPJxmzGNcdXzky8V04Y/R7C6fI9UL+BpxeY8jBfOHtNyfV7IujbyAyvSd9OUYOSgSlAgwTPjM6g== X-Received: by 2002:a1c:2188:: with SMTP id h130mr1569720wmh.176.1608248634800; Thu, 17 Dec 2020 15:43:54 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:54 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 02/12] property: Return true in fwnode_device_is_available for NULL ops Date: Thu, 17 Dec 2020 23:43:27 +0000 Message-Id: <20201217234337.1983732-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Some types of fwnode_handle do not implement the device_is_available() check, such as those created by software_nodes. There isn't really a meaningful way to check for the availability of a device that doesn't actually exist, so if the check isn't implemented just assume that the "device" is present. Suggested-by: Laurent Pinchart Reviewed-by: Laurent Pinchart Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally Acked-by: Sakari Ailus --- Changes in v2: - None drivers/base/property.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4c43d30145c6..bc9c634df6df 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -785,9 +785,15 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put); /** * fwnode_device_is_available - check if a device is available for use * @fwnode: Pointer to the fwnode of the device. + * + * For fwnode node types that don't implement the .device_is_available() + * operation, this function returns true. */ bool fwnode_device_is_available(const struct fwnode_handle *fwnode) { + if (!fwnode_has_op(fwnode, device_is_available)) + return true; + return fwnode_call_bool_op(fwnode, device_is_available); } EXPORT_SYMBOL_GPL(fwnode_device_is_available); From patchwork Thu Dec 17 23:43:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5793C3526C for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A10C423A56 for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732320AbgLQXoi (ORCPT ); Thu, 17 Dec 2020 18:44:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732201AbgLQXoh (ORCPT ); Thu, 17 Dec 2020 18:44:37 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EE0C06138C; Thu, 17 Dec 2020 15:43:57 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id v14so531558wml.1; Thu, 17 Dec 2020 15:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2D63LdgVtcR4/tv7YaOjAC2rW6v7Ot1epxf/JXyTdFI=; b=aDKCoO63cjworyHY5zkMXmUCGgG2xTtZSue16SQEriXx4wn29dqrvrjrqqHEdzoeIQ 3X+rp09nI04kgEk7BCL68WiCuRrp9xZXmfUG3aTZcz0tBGu2CGz4L6TFIFLyDDri1GrB t6wMLhOURcIt5KzV7+UDBfA9vhXlhkT2xn1CVHyD3YBUKi1fmrmiY33l1epNRgFIemUW pSZGvb+dY7CwPCOFurNYWiqvGSHXLlBurZxv+2nMFuQmdWixFc/wqQ9t/nB3N+L4babb BE817J7hYjSuljVyrLtzmBXaqL6zvn4+CtXV8ymFtSvoBQdXsqZz4C63suuqmxPC4nPv AeSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2D63LdgVtcR4/tv7YaOjAC2rW6v7Ot1epxf/JXyTdFI=; b=F+VqNP9NMA9c2qyIf3knUP8X3OkFjEq0V2KPamRgeEHkENbOkiSAD28t3GbiOGZyPX YYNMFJCrKPtMYeWtduit4eXaJ1CnNCIaxJ7VcFMoCs0XpisR8H4ulvkvNZ28/8oSacOi toacUZo5AkqxndZpYNi8w2hj8cQbGAbHRBS5niXJw2YJWh7yvkfCVdMy16s4fV6Cf7ks s01aypq1KPDwjzqyJ/HwMMavP9rB1LtjAP4TW/yeoYb977c8zS1woYNgXAP18Vb9QIWi woGvWY/mZVsGKXX0a7I+KPoEX1ujGyY+F16cWQFVdYiPDfxTnWSaTFuKlYEoW2vzdoV0 0PRw== X-Gm-Message-State: AOAM530XMu1+RQoxuFaEiAAohbpb0NygXLzEw5p+segzJc0Ro/WzoF8d S8R7OJGOvGrrtWIdz4grgh5mIdpHBjNx/jFV X-Google-Smtp-Source: ABdhPJw7bOQ5fSHhp8BUhvO0zjhy4WuOaDJPqEu2Unh9jf7ITcX4oaKtn24+FuZ2k+cjGuBNpG6PsA== X-Received: by 2002:a1c:7213:: with SMTP id n19mr1633738wmc.14.1608248636146; Thu, 17 Dec 2020 15:43:56 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:55 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 03/12] property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary Date: Thu, 17 Dec 2020 23:43:28 +0000 Message-Id: <20201217234337.1983732-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This function is used to find fwnode endpoints against a device. In some instances those endpoints are software nodes which are children of fwnode->secondary. Add support to fwnode_graph_get_endpoint_by_id() to find those endpoints by recursively calling itself passing the ptr to fwnode->secondary in the event no endpoint is found for the primary. Reviewed-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes in v2: - Some rearranging of the conditionals drivers/base/property.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index bc9c634df6df..ddba75d90af2 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1163,7 +1163,14 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, best_ep_id = fwnode_ep.id; } - return best_ep; + if (best_ep) + return best_ep; + + if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) + return fwnode_graph_get_endpoint_by_id(fwnode->secondary, port, + endpoint, flags); + + return NULL; } EXPORT_SYMBOL_GPL(fwnode_graph_get_endpoint_by_id); From patchwork Thu Dec 17 23:43:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EEF2C3526A for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 384E522CA2 for ; Thu, 17 Dec 2020 23:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732348AbgLQXoj (ORCPT ); Thu, 17 Dec 2020 18:44:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732337AbgLQXoj (ORCPT ); Thu, 17 Dec 2020 18:44:39 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17B1C061282; Thu, 17 Dec 2020 15:43:58 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id w5so210717wrm.11; Thu, 17 Dec 2020 15:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZRG6Du2Q5gaJecr0crPPKYS4mZ7zwOVeReLwF06dy8c=; b=R+U8hHBVOD1dvXrSoEvLCKxYu3++5n4YZ2k3P4lwKlX4SZ7F46ClpBb9F/YER/1WwL 4oRx7vRZYnNXfQMX17iB9DpJHjMKRI2rODDS5quQ/+umxqg69V5hJSQcCwpzCCzLwMhr dx2UIHoiI2lNRhpsstpR0reE1k8dn3KFvj835qp+C8kJe2G72jcom+f/QIkpXdaBrUrp DC94LUztpChvH/lDnHz6CgvK11muVctOTSin4ClAkp4H+YgyaK5Z20iD053EOC9Vdjt7 KQJUSmbRd7f7AYpNj9M1SjxndEbsp4ZKDHu2nM3ZEDZE+97/TARte/nS1oQy4FiQ5U9i psdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZRG6Du2Q5gaJecr0crPPKYS4mZ7zwOVeReLwF06dy8c=; b=nC1nwKKARnX6tHJlkCE1MAgDJGYoHxFq4NY8GvW+A9RP4LNZYkYG7rFgseCMDlBygu e8Xz3ctIOlPgfdNLsNJzZiu4yIGDKkRAqoqWWXCqiiuzooTQIJKRIqzaMFnlCK5x1Hsk lHyXwas7iUwt3cVMWOuNVGFjX2uQQTEuwbMMGvLPHULi3pWFd0mJW1L4U7zM6+RXHWUV StKbyJD6AQKFbQxHt82bpg68j+nzYXjIr1uZVQVaxXrbptUm0N83iQM9UlHw+Yv1Jg0G RSUrlsM1CyktOukPoyfq7SO+4GjE0s7Wa4KPxc8h8lQzv6YRxULwh6CcqiDcPT/oX0QW iyeA== X-Gm-Message-State: AOAM531Pg58q2AwXcYtYw8lM/5GJ1ADajHtL2piYtScggHzhvPTKRrql eKLkXf0SEXl6blB6GKAGHKN4kVMH7ZKSI4XI X-Google-Smtp-Source: ABdhPJw7/NIJWKtof/Iqcc4Lel2jeNJDl8wRWMDmfXSr1kBk/rln+Zxy4omURinH+gaxl7UvniPhKw== X-Received: by 2002:a5d:42d0:: with SMTP id t16mr1255839wrr.230.1608248637431; Thu, 17 Dec 2020 15:43:57 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:56 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com Subject: [PATCH v2 04/12] software_node: Enforce parent before child ordering of nodes arrays Date: Thu, 17 Dec 2020 23:43:29 +0000 Message-Id: <20201217234337.1983732-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Registering software_nodes with the .parent member set to point to a currently unregistered software_node has the potential for problems, so enforce parent -> child ordering in arrays passed in to software_node_register_nodes(). Software nodes that are children of another software node should be unregistered before their parent. To allow easy unregistering of an array of software_nodes ordered parent to child, reverse the order in which software_node_unregister_nodes() unregisters software_nodes. Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- Changes in v2: - Squashed the patches that originally touched these separately - Updated documentation drivers/base/swnode.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 615a0c93e116..cfd1faea48a7 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -692,7 +692,10 @@ swnode_register(const struct software_node *node, struct swnode *parent, * software_node_register_nodes - Register an array of software nodes * @nodes: Zero terminated array of software nodes to be registered * - * Register multiple software nodes at once. + * Register multiple software nodes at once. If any node in the array + * has it's .parent pointer set, then it's parent **must** have been + * registered before it is; either outside of this function or by + * ordering the array such that parent comes before child. */ int software_node_register_nodes(const struct software_node *nodes) { @@ -700,33 +703,47 @@ int software_node_register_nodes(const struct software_node *nodes) int i; for (i = 0; nodes[i].name; i++) { - ret = software_node_register(&nodes[i]); - if (ret) { - software_node_unregister_nodes(nodes); - return ret; + const struct software_node *parent = nodes[i].parent; + + if (parent && !software_node_to_swnode(parent)) { + ret = -EINVAL; + goto err_unregister_nodes; } + + ret = software_node_register(&nodes[i]); + if (ret) + goto err_unregister_nodes; } return 0; + +err_unregister_nodes: + software_node_unregister_nodes(nodes); + return ret; } EXPORT_SYMBOL_GPL(software_node_register_nodes); /** * software_node_unregister_nodes - Unregister an array of software nodes - * @nodes: Zero terminated array of software nodes to be unregistered + * @nodes: Zero terminated array of software nodes to be unregistered. * - * Unregister multiple software nodes at once. + * Unregister multiple software nodes at once. If parent pointers are set up + * in any of the software nodes then the array MUST be ordered such that + * parents come before their children. * - * NOTE: Be careful using this call if the nodes had parent pointers set up in - * them before registering. If so, it is wiser to remove the nodes - * individually, in the correct order (child before parent) instead of relying - * on the sequential order of the list of nodes in the array. + * NOTE: If you are uncertain whether the array is ordered such that + * parents will be unregistered before their children, it is wiser to + * remove the nodes individually, in the correct order (child before + * parent). */ void software_node_unregister_nodes(const struct software_node *nodes) { - int i; + unsigned int i = 0; + + while (nodes[i].name) + i++; - for (i = 0; nodes[i].name; i++) + while (i--) software_node_unregister(&nodes[i]); } EXPORT_SYMBOL_GPL(software_node_unregister_nodes); From patchwork Thu Dec 17 23:43:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 275B5C2BBCD for ; Thu, 17 Dec 2020 23:45:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F225B2255F for ; Thu, 17 Dec 2020 23:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732385AbgLQXpO (ORCPT ); Thu, 17 Dec 2020 18:45:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732382AbgLQXpO (ORCPT ); Thu, 17 Dec 2020 18:45:14 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE8F2C061285; Thu, 17 Dec 2020 15:43:59 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id d13so200861wrc.13; Thu, 17 Dec 2020 15:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v9hWyCxdl7BaMDXzs37QSeG0VlHKb85UKoJQ04gptnE=; b=eLaJcbeBCaeFtHSgKWBkcouRygDfUOsGhvnFKtJmjREtgycPYnhiOyiGwwxU6wQ4PA 2f8jfeHO2hk8zawm7ShOqaqyoj8bkKb2GFFBBn6hfUY2od97El4842jkBjIsJZ9RpUJ0 NlJSkAWsAt+WNVkZzOeHGfT95gNPt8wk8W1dtlgHcvuoQlLv3BNL8ShEBvYD3aP3D3dB AdgpxwtMGuwLVq+mUi2+zZb5//JuLPyxHB9nJeClQmCO6BDVMtY5hmWA4fauC6zwUC1W EgeWQt1TKXxnB6CwE50LUqJx0aPK7E8A4RjzA1YoLec2SGNEpFld6jrJqzwgTfX9s/zC qMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v9hWyCxdl7BaMDXzs37QSeG0VlHKb85UKoJQ04gptnE=; b=uI7wRUav4VmFU/Ekn9Wd56EtGYskRVqxQyy4K5Uv4DJpWHcNveaDd9YAHp/oEuN3mr ZdhyAjwa4GPOGm1/2b/sAFOX8VKjxaYvSsLXuvXfUE6Fq8h7znCJFmvGiRifco8h3b1r zbyUa2vrHyKoBQz80hGFyEOo3KSUVOVDPDPeOHUdohOl0o22Sdo0DQ9+7j4F2Hu0xz3y yPtfdaeSw9VbO4intxEkvm/S9xcRkrBhwovCJc68np0s8fAEJq7AKbejQZ8kV6/+A+uw 04kyvbcvVVuoTt7jXczP2suixLhpOvhqRvUsnHC5/NWO6SaE4MlTYaXgXJN5nqQAecUB UtVg== X-Gm-Message-State: AOAM533IlA3Z3K+2T+DWYgV5i3bPIRTUKqixBodQ3MGOWnQgC0b7d4Vh 2mzEhFV2P+1wVwNlC16UKJ9i4OKVLJByhkfd X-Google-Smtp-Source: ABdhPJwRogkY05VU9Y1LkJwAM7Oisn574vwGXScbZrpMXHJGJBpVQiK78bbLfBuM+lgEaVNS1B0NLA== X-Received: by 2002:a5d:690d:: with SMTP id t13mr1230073wru.410.1608248638775; Thu, 17 Dec 2020 15:43:58 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:58 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, kernel test robot , Dan Carpenter , Laurent Pinchart Subject: [PATCH v2 05/12] software_node: unregister software_nodes in reverse order Date: Thu, 17 Dec 2020 23:43:30 +0000 Message-Id: <20201217234337.1983732-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To maintain consistency with software_node_unregister_nodes(), reverse the order in which the software_node_unregister_node_group() function unregisters nodes. Reported-by: kernel test robot Reported-by: Dan Carpenter Reviewed-by: Laurent Pinchart Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes in v2: - Initialised i properly drivers/base/swnode.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index cfd1faea48a7..2b90d380039b 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -778,16 +778,22 @@ EXPORT_SYMBOL_GPL(software_node_register_node_group); * software_node_unregister_node_group - Unregister a group of software nodes * @node_group: NULL terminated array of software node pointers to be unregistered * - * Unregister multiple software nodes at once. + * Unregister multiple software nodes at once. The array will be unwound in + * reverse order (I.E. last entry first) and thus if any member of the array + * has its .parent member set then they should appear later in the array such + * that they are unregistered first. */ void software_node_unregister_node_group(const struct software_node **node_group) { - unsigned int i; + unsigned int i = 0; if (!node_group) return; - for (i = 0; node_group[i]; i++) + while (node_group[i]->name) + i++; + + while (i--) software_node_unregister(node_group[i]); } EXPORT_SYMBOL_GPL(software_node_unregister_node_group); From patchwork Thu Dec 17 23:43:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7262EC2BBCD for ; Thu, 17 Dec 2020 23:46:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D4B822B51 for ; Thu, 17 Dec 2020 23:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732388AbgLQXpO (ORCPT ); Thu, 17 Dec 2020 18:45:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732337AbgLQXpO (ORCPT ); Thu, 17 Dec 2020 18:45:14 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0F3C061248; Thu, 17 Dec 2020 15:44:01 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id c5so232302wrp.6; Thu, 17 Dec 2020 15:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gU5HhP1TeKrMyBxy7gnZuPRoeb13x3wsqwC/lwANoFU=; b=o0nqPDOoz78PdLm4/ZdIUMMVLu3XQvGP2Bp8YwXHCO9SWEIJ23FgNBp41yH5JZz8iJ Z1Nfq38KXTats2hEXlLkjowypJr6nbfSjq+bQ3/wQ6G8Om/O8yz07CudjoZO5Yt24p/d ep5Rv5Uxs7+9/eNzF8XPnZOTQVf0lKfQzkJSfjRmkqfNXRQJikHzAVbbpQfvoCV/JiZi yo0JtKsP5rnBwwSz+A/KS4JsZuSG1Z/eUDh2gzj9bUaPuOaMfews1PvSvt2FXqFHOqtF XK5U2K+m46yCq+LZrtyroRIFe1a+mbPhTkylwyTzJ/SB9PKozUu2H4uGZvTK8VV5+wVG jIOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gU5HhP1TeKrMyBxy7gnZuPRoeb13x3wsqwC/lwANoFU=; b=fcvW5S6zBiLXkn2Z3QcybwxhpXRzLDiJIG5a/hlWa+Wez7SYeuXfnUxwtei7+hTsRi B2wN9gGvsZOQ6kWWIc6FqX3+cCOTmAOncg0Iuh70ZiAsQPVY/Kh48XUnSUwCdkpcsQwU BNLBUDLNxQvD/PMediTPwy2BlNCfjO5vzc1elsjoJK16UkTdcp3WQ0aMBWazqBmE4dfb 7CxXKWq0E16jsg0J/1LabW0gbyQql7pQqcGxOB6skBdV7DbijNGpfzSGgiPcmN3ZLzvM 2+nn6amDa2MUD4EEslF2ouLPX10cp652un3BL3jq0SMWoOepjDIpzdf5hIIPJMVuojv/ 2TEg== X-Gm-Message-State: AOAM5314HmVAHsePkOWS9HFHN20e7YjR6QDTAG40jo20nvPDNsc2Ep8e WFcmJc2n2lnrXBr3437+Yr2YudENu22SmZVQ X-Google-Smtp-Source: ABdhPJy0Hiw1DqKEpVPX2hJdAPhEMPAAGgEu0x7pQTOCwMf1fsd4tWtZPbLEhnIPMlLHJ4ACfe5UuA== X-Received: by 2002:a5d:5401:: with SMTP id g1mr1221389wrv.93.1608248640141; Thu, 17 Dec 2020 15:44:00 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:43:59 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com Subject: [PATCH v2 06/12] software_node: Add support for fwnode_graph*() family of functions Date: Thu, 17 Dec 2020 23:43:31 +0000 Message-Id: <20201217234337.1983732-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Heikki Krogerus This implements the remaining .graph_* callbacks in the fwnode operations structure for the software nodes. That makes the fwnode_graph*() functions available in the drivers also when software nodes are used. The implementation tries to mimic the "OF graph" as much as possible, but there is no support for the "reg" device property. The ports will need to have the index in their name which starts with "port@" (for example "port@0", "port@1", ...) and endpoints will use the index of the software node that is given to them during creation. The port nodes can also be grouped under a specially named "ports" subnode, just like in DT, if necessary. The remote-endpoints are reference properties under the endpoint nodes that are named "remote-endpoint". Signed-off-by: Heikki Krogerus Co-developed-by: Daniel Scally Signed-off-by: Daniel Scally --- Changes in v2: - Changed commit to specify port name prefix as port@ - Accounted for that rename in *parse_endpoint() drivers/base/swnode.c | 110 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 2b90d380039b..0d14d5ebe441 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -540,6 +540,110 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode, return 0; } +static struct fwnode_handle * +swnode_graph_find_next_port(const struct fwnode_handle *parent, + struct fwnode_handle *port) +{ + struct fwnode_handle *old = port; + + while ((port = software_node_get_next_child(parent, old))) { + if (!strncmp(to_swnode(port)->node->name, "port", 4)) + return port; + old = port; + } + + return NULL; +} + +static struct fwnode_handle * +software_node_graph_get_next_endpoint(const struct fwnode_handle *fwnode, + struct fwnode_handle *endpoint) +{ + struct swnode *swnode = to_swnode(fwnode); + struct fwnode_handle *old = endpoint; + struct fwnode_handle *parent; + struct fwnode_handle *port; + + if (!swnode) + return NULL; + + if (endpoint) { + port = software_node_get_parent(endpoint); + parent = software_node_get_parent(port); + } else { + parent = software_node_get_named_child_node(fwnode, "ports"); + if (!parent) + parent = software_node_get(&swnode->fwnode); + + port = swnode_graph_find_next_port(parent, NULL); + } + + for (; port; port = swnode_graph_find_next_port(parent, port)) { + endpoint = software_node_get_next_child(port, old); + if (endpoint) { + fwnode_handle_put(port); + break; + } + + /* No more endpoints for that port, so stop passing old */ + old = NULL; + } + + fwnode_handle_put(parent); + + return endpoint; +} + +static struct fwnode_handle * +software_node_graph_get_remote_endpoint(const struct fwnode_handle *fwnode) +{ + struct swnode *swnode = to_swnode(fwnode); + const struct software_node_ref_args *ref; + const struct property_entry *prop; + + if (!swnode) + return NULL; + + prop = property_entry_get(swnode->node->properties, "remote-endpoint"); + if (!prop || prop->type != DEV_PROP_REF || prop->is_inline) + return NULL; + + ref = prop->pointer; + + return software_node_get(software_node_fwnode(ref[0].node)); +} + +static struct fwnode_handle * +software_node_graph_get_port_parent(struct fwnode_handle *fwnode) +{ + struct swnode *swnode = to_swnode(fwnode); + struct fwnode_handle *parent; + + if (!strcmp(swnode->parent->node->name, "ports")) + parent = &swnode->parent->parent->fwnode; + else + parent = &swnode->parent->fwnode; + + return software_node_get(parent); +} + +static int +software_node_graph_parse_endpoint(const struct fwnode_handle *fwnode, + struct fwnode_endpoint *endpoint) +{ + struct swnode *swnode = to_swnode(fwnode); + int ret; + + ret = kstrtou32(swnode->parent->node->name + 5, 10, &endpoint->port); + if (ret) + return ret; + + endpoint->id = swnode->id; + endpoint->local_fwnode = fwnode; + + return 0; +} + static const struct fwnode_operations software_node_ops = { .get = software_node_get, .put = software_node_put, @@ -551,7 +655,11 @@ static const struct fwnode_operations software_node_ops = { .get_parent = software_node_get_parent, .get_next_child_node = software_node_get_next_child, .get_named_child_node = software_node_get_named_child_node, - .get_reference_args = software_node_get_reference_args + .get_reference_args = software_node_get_reference_args, + .graph_get_next_endpoint = software_node_graph_get_next_endpoint, + .graph_get_remote_endpoint = software_node_graph_get_remote_endpoint, + .graph_get_port_parent = software_node_graph_get_port_parent, + .graph_parse_endpoint = software_node_graph_parse_endpoint, }; /* -------------------------------------------------------------------------- */ From patchwork Thu Dec 17 23:43:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B974C3527A for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67B95233FE for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732424AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732404AbgLQXpP (ORCPT ); Thu, 17 Dec 2020 18:45:15 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B017CC061257; Thu, 17 Dec 2020 15:44:02 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id y23so572821wmi.1; Thu, 17 Dec 2020 15:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NhV0D9xuOLKxtzOWkibLn3uvxzcSBCPiXhXcwXUTilM=; b=g2TSU9X4omWopl89Jo0LZ6GhwCl0vy3NOdWDxlgJzd9MJ4kD23p2lAXsB1ak/v9AYP p6bRMhpmRYZBdJeolDOkLPzHHvX/pTgW9VVmlM0Wu+bgvzoCI25B2SAJ5/o+0DDFRUH0 H3I86/Y7jKjQwjjWJ/Ph6ltdqzuWCO90o56tQ3/3YuuLvtuhL8SLBKO2rZVzzFzsp+b0 z88YNdTY+tW0TrDTHOfkgXS8to2MevQ3b4iZTRzqOyQKHVWs8x2xRrFqkjfxPPIqqbpP FVOuj99pHEpHNo+sT8r8SjpA6v9iNRevjFEd65ABKnSmx2wBIDucrf29f/+CM3svwdIl Z+1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NhV0D9xuOLKxtzOWkibLn3uvxzcSBCPiXhXcwXUTilM=; b=P5nO0nCbqTZ6IhFN9TdP9s7xMW76l/UtEtE39oBW6VWhX/I6w5IzcHcyTx/2TXpA3F BZ3deKqAIC3WTlpzfVt4z0CoEJ/sDxs4+hNGt6NsNt27/ND0vJET9TAT8rp/ZlBgeW8A 9hrP4CqPXU1IIN+QdnRcK+jKguhIvUjZ7W/t2uHJSaGSQRnSdfDpjQwkZbw0hvwztLZb xZn+kNf3moBhTvljLPv0uVveH/ho9A1io2lBWqj4OLkKM6Dh6r+3Gl9iSy6HoCPkK4HG Pph2yvFme2W8ZXr2fSOQ7prgNQD+a3HbB9KgcjZjGmm8/lyn/hlhhFxq/gg+JKLvicK8 nZog== X-Gm-Message-State: AOAM532pZEihYpKRu6QJuz9qH89m6gTscCy+qMW5ypFd0XY1oOrkuxeN ZT6A+n0ruLyUpDk8axy5zww47ENtpdJ9qn/9 X-Google-Smtp-Source: ABdhPJzs3MQAOJ62JKkc1AKPkounfyMsx9EiBFgBKAjwzggxEJ3tQ2zekKlfhxG7zlgfn4K0wTcz4w== X-Received: by 2002:a1c:6446:: with SMTP id y67mr1580311wmb.144.1608248641472; Thu, 17 Dec 2020 15:44:01 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:00 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 07/12] lib/test_printf.c: Use helper function to unwind array of software_nodes Date: Thu, 17 Dec 2020 23:43:32 +0000 Message-Id: <20201217234337.1983732-8-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Use the software_node_unregister_nodes() helper function to unwind this array in a cleaner way. Acked-by: Petr Mladek Reviewed-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Reviewed-by: Sergey Senozhatsky Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes in v2: - None lib/test_printf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 7ac87f18a10f..7d60f24240a4 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -644,9 +644,7 @@ static void __init fwnode_pointer(void) test(second_name, "%pfwP", software_node_fwnode(&softnodes[1])); test(third_name, "%pfwP", software_node_fwnode(&softnodes[2])); - software_node_unregister(&softnodes[2]); - software_node_unregister(&softnodes[1]); - software_node_unregister(&softnodes[0]); + software_node_unregister_nodes(softnodes); } static void __init From patchwork Thu Dec 17 23:43:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D96AC3527E for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F2F52255F for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732419AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732406AbgLQXpP (ORCPT ); Thu, 17 Dec 2020 18:45:15 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 156C5C0611C5; Thu, 17 Dec 2020 15:44:04 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id 91so229318wrj.7; Thu, 17 Dec 2020 15:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=riJVgL/vim4VKJ7ma+YNngc2fLrOooVQootWQpOsbu0=; b=PyYgXTgQAX8OhUliV1GLGVyJK3dV76O67chicHnX70h0b+MTbEVsTZwioRjocZAIF6 C5Azus/xjyd//3lFTTK4B1T6IyfBgSKVhfMcZ9QMPnsvEFIruYZy2Sp712dszlqwhNKU ncN2TaIXXgdLU1i3fecOc9/hqznOa12jJbB9IRA9TGkdVFwgfzaibE5NHVxh8YyvQEEa Wn7reJAO85dUVMOQI8S7SAH/XEAHDdGOYTu2dzeZILHuMBXUUfhe9QqwWZF/+uduO09i +fH2+0rqDwBE/i9hDyZET7UAKe4YQCXKuW1Cybx6Mor6zNaV6O16+LHOPbHPhKq2FN10 +tmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=riJVgL/vim4VKJ7ma+YNngc2fLrOooVQootWQpOsbu0=; b=LtfYMcCOZEqJOr58fkoUiHg4cCwLC86P8JuHTuNpagecX/gBfevJgidhwXV4dqEoxt DvZPOpv4tAcZwJzkemG6OsPhoOJbXUD2/TASWb69GthTLQTr4r9bKEsI56bqVXBf8kz1 2NZpEkhsfAml381XSitYnsgMjMw89iFDdp0r6xQ2t9ixFNEv6A64eXzH3v/PL+NcS+zv SrrDCCdiIJt2IzqUoPUOkBB/YX1jwtR3h4mmgo+Oi9hJQeyp6jJoeGYe4l09Hk1fdMVA qzv5ZLlEg/VGgoKWVUd7Yg+H49uCD6TJiCocEOu5VkjhaiIH6k0t3VxrZRj3OLZ+Blkc MTCg== X-Gm-Message-State: AOAM533QMx4cFWihO8rYL7FKucBNEHlo4r7ruyZKEKJCbV21kDB8e/4A q3Y5SsOE78r15HIFN9lPzqIayaVyq3LxzHOz X-Google-Smtp-Source: ABdhPJw1gsGoW8ANqps3uaXvZo3BgqwOBaKw48l5oJmW7aKdtqU5eCksb39kLZGmOV8Ax57c3BS5rQ== X-Received: by 2002:adf:dc08:: with SMTP id t8mr1210069wri.195.1608248642876; Thu, 17 Dec 2020 15:44:02 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:02 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 08/12] ipu3-cio2: Add T: entry to MAINTAINERS Date: Thu, 17 Dec 2020 23:43:33 +0000 Message-Id: <20201217234337.1983732-9-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Development for the ipu3-cio2 driver is taking place in media_tree, but there's no T: entry in MAINTAINERS to denote that - rectify that oversight Reviewed-by: Laurent Pinchart Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes in v2: - None MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 80881fb36404..16b544624577 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8946,6 +8946,7 @@ M: Bingbu Cao R: Tianshu Qiu L: linux-media@vger.kernel.org S: Maintained +T: git git://linuxtv.org/media_tree.git F: Documentation/userspace-api/media/v4l/pixfmt-srggb10-ipu3.rst F: drivers/media/pci/intel/ipu3/ From patchwork Thu Dec 17 23:43:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6744EC2BBCD for ; Thu, 17 Dec 2020 23:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BD0F22CA2 for ; Thu, 17 Dec 2020 23:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732466AbgLQXp2 (ORCPT ); Thu, 17 Dec 2020 18:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732426AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5101DC0611CA; Thu, 17 Dec 2020 15:44:05 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id m5so218712wrx.9; Thu, 17 Dec 2020 15:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HAUVeFRGMPGgWvoUIsXf/Ln2ZywCD/ZCvvMD4gyiyPw=; b=iRdYYEJbUgqpwQ6789Qs5EnCQIgdSi6OxHIEn98Yw7+TRgBCFPq348rXB7361XD28I Vj6kjUp20tygynb2BSeBF3o32AbR/PkJ3kxr3ImO1BhrEMoE0VPZLYTX8iuSz2pgLrZt SnZYXF5NEdfPilw2VkIhULR70yzsLxkzaJGMb9om6wO8DHClc22WLUO9cOP71PPr8mTg 23RkwWFyA/Zp5akQRkl074H9cm2h8cCinFTDn+VUnQ6xNsVT1K6JZzL8EZk03HpnksPl EujHkBWeSz92RmKFgw3+hRCYUhrIGyBksue0EyveIEsUslxrSZLSryDR8+ZAwTHAhwgI +ZYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HAUVeFRGMPGgWvoUIsXf/Ln2ZywCD/ZCvvMD4gyiyPw=; b=Ar99MfJP5Cu6CNgJgzsLdLCDySgcF073TBm+yWwLUlJe6beJcWP9V5MsqFK0bDUZH0 n1E2s1Vp6/K6GszaO+BaealqFqVvBCn2/YNBetYriCin7ud4gsUUJGTDwBTApgr6nMId caZf2eBWMqHgKEQJsE4lIAu20Wx+ojcfiYrz+F+wbUlpsgVH7rJyqlyreJDfvkcOBO90 kInW2fWLHAQdwLJzxgtt6t37cGXJbqS9XPmDTWACzmkeSCxPOQQHT8MWK8Sa/MqnYaEL xeANKjYlWNU7/mHlrTd/9+P74FbP++cg5sOILAu3eIEaN7UoBXipSm7OOHg34oKJsKAC mYGQ== X-Gm-Message-State: AOAM531HFmT9kk3vZv9QZuW3kqJkA6jl6AYJ4gF4ga0BjnGsJjQTmJW0 68WR9TlgpBYXwvKAq7M/ochyCjQLR2yrTtYq X-Google-Smtp-Source: ABdhPJzbp7Bd6bq61B3TPkoEHQkDOgyhtHhMLCgAUVlPnnabYOsofHDRP4oCXOI8EZxmggJ5uH2TUw== X-Received: by 2002:a05:6000:101:: with SMTP id o1mr1206735wrx.211.1608248644128; Thu, 17 Dec 2020 15:44:04 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:03 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 09/12] ipu3-cio2: Rename ipu3-cio2.c Date: Thu, 17 Dec 2020 23:43:34 +0000 Message-Id: <20201217234337.1983732-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ipu3-cio2 driver needs extending with multiple files; rename the main source file and specify the renamed file in Makefile to accommodate that. Suggested-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes in v2: - None drivers/media/pci/intel/ipu3/Makefile | 2 ++ drivers/media/pci/intel/ipu3/{ipu3-cio2.c => ipu3-cio2-main.c} | 0 2 files changed, 2 insertions(+) rename drivers/media/pci/intel/ipu3/{ipu3-cio2.c => ipu3-cio2-main.c} (100%) diff --git a/drivers/media/pci/intel/ipu3/Makefile b/drivers/media/pci/intel/ipu3/Makefile index 98ddd5beafe0..429d516452e4 100644 --- a/drivers/media/pci/intel/ipu3/Makefile +++ b/drivers/media/pci/intel/ipu3/Makefile @@ -1,2 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VIDEO_IPU3_CIO2) += ipu3-cio2.o + +ipu3-cio2-y += ipu3-cio2-main.o diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c similarity index 100% rename from drivers/media/pci/intel/ipu3/ipu3-cio2.c rename to drivers/media/pci/intel/ipu3/ipu3-cio2-main.c From patchwork Thu Dec 17 23:43:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F217DC3526C for ; Thu, 17 Dec 2020 23:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB4F722511 for ; Thu, 17 Dec 2020 23:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732478AbgLQXp3 (ORCPT ); Thu, 17 Dec 2020 18:45:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732422AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A28DAC0611CB; Thu, 17 Dec 2020 15:44:06 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id r3so250744wrt.2; Thu, 17 Dec 2020 15:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QxoF/I7GjnQos9P0XrAdNbghzE7MUAe2eW4mMwyagRA=; b=qV0/mL37jO+KmDWIDMJcAcXwHiw6GUsCZZiX1E1mWbt+CKDKTUCjsimECFkCHzU2xb oGgP7dOOxVuIJpccmebUs9NRjf9NNvsI/RofiS+YjbDKr7hgei+RcTOpK+TCDZyK1Y8e DGqI28OmbcFkYN8WtlnjDiyg1OsInh9sE2+YjGpxtgzttirRMtkQF+H8uiigNA5QOfp5 MLlROH2wqE3nBhBWGwM+k/hDR6MpHE82OKZdidjcTO8kKgK3Lcihw/p6DZPHe+JwiFM5 8ARI+hheGuzK/OkoxoULcPGtzhihQLLLk9AdcrDyrBmYlBhDcr//dEKC0DljJu7hFXRb DGGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QxoF/I7GjnQos9P0XrAdNbghzE7MUAe2eW4mMwyagRA=; b=kBbiAxDxcmhcoJzCbkcr1OARK7m/uRvQrzEEewCOpPfG2d9VueYfmUiuidTkz2/JxM TcdlTsiLKoP28f+sKn7Cqex5BIplwMSxa+Ffncdn9HDB4oem/I0Yuq9k+g+dOaZI0dnd wMDh6vxwXUJsIIHO09UjtbTz98MCO2aqF8O8oAkRkxhzTcB3jV7MZSpbqL/asKBeZ6Tg UkY6ejC9PYgai37y0sYXOoULOykqfzfHvgQqUkhhTqRplmzDvFQFVSGDs3QuN2ZkHoLb hhI+BkR1EqS48wuQGvZNneAdJb18HwhmKIX8F6D9UOCsa6RnXJ4DjzhNBpp21fNt+hs7 i5pg== X-Gm-Message-State: AOAM530c8Thzn5XgEp04g+ITUBJUUxflKSjb0oka29AQvwrDd+DeCOMy RtzXY+MjFLw+TaamGRTRtIXlF0lpwiBW2dP/ X-Google-Smtp-Source: ABdhPJzDyKCaJKHq6s9CdN5vYZ6BgtJ6VkOwN/2pZfZtcYbibNIvU/g2usqcXUqHxdpUex5JmyGIuQ== X-Received: by 2002:adf:9d49:: with SMTP id o9mr1218180wre.413.1608248645403; Thu, 17 Dec 2020 15:44:05 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:04 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com, Laurent Pinchart Subject: [PATCH v2 10/12] media: v4l2-core: v4l2-async: Check sd->fwnode->secondary in match_fwnode() Date: Thu, 17 Dec 2020 23:43:35 +0000 Message-Id: <20201217234337.1983732-11-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Where the fwnode graph is comprised of software_nodes, these will be assigned as the secondary to dev->fwnode. Check the v4l2_subdev's fwnode for a secondary and attempt to match against it during match_fwnode() to accommodate that possibility. Reviewed-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes in v2: - None drivers/media/v4l2-core/v4l2-async.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index e3ab003a6c85..9dd896d085ec 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -87,6 +87,14 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier, if (sd->fwnode == asd->match.fwnode) return true; + /* + * Check the same situation for any possible secondary assigned to the + * subdev's fwnode + */ + if (!IS_ERR_OR_NULL(sd->fwnode->secondary) && + sd->fwnode->secondary == asd->match.fwnode) + return true; + /* * Otherwise, check if the sd fwnode and the asd fwnode refer to an * endpoint or a device. If they're of the same type, there's no match. From patchwork Thu Dec 17 23:43:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DD81C3526D for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0916722511 for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732472AbgLQXp2 (ORCPT ); Thu, 17 Dec 2020 18:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732423AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE244C0611CC; Thu, 17 Dec 2020 15:44:07 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id r4so551955wmh.5; Thu, 17 Dec 2020 15:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oGCJxAGqtJJ26HP8mxtKtxXBUimDrY8TQdEbrQWGOTg=; b=SFKd7hJPiwwsi9WxaJalVzeYPdp+dyQu0SMIC1mFQ+rt/VYCT+mMRcT9mq9jklkUan Y2XxG4ie+mZEI6InRkZ52Sle2uCPIj067Tm0L7ITq67+DgaZyiu32VgZ2pYAXaomH/m9 4pBDx6hSho5NuOmutzoKS5jw3UPNem+/ci0QCUJ7Gmh7hozSkuJE6kySOndrvGcR5IDb Ri7nC5iBd/vtcj/XzcJt/eyRXRwR+qNywYwXKvYArjY4F7oTKp+oKOFMkTmJ8HsLVB03 1MfBIxTwZDixSQlIeler7NOI2Xfdfs2XsI9wbH/XJ95znl6ei4We3cUH7wSbRili9Cov Mqew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oGCJxAGqtJJ26HP8mxtKtxXBUimDrY8TQdEbrQWGOTg=; b=jRI/9e1KfvUqhGgq2K9FxQxZ02qkaieWRs1g3H5iJf30Qc3eB9cBwmuPcDlbuVsFAq R4gZkVFlZ8YL0JlSWAXGl6sA/SGUJji7fcj19eTH9lOQ2WZYbCVQwtXxPpwAwBHx6sp6 VqlEO65TJIy9gfdl3xPdg16KJ5wxahEuYe/WCMrnVdLtccSZkHpUOv/PnhQmco9krOkh CEvwSZALJVz6euIbsiec0baflvprWo/tzrni8eU1veUp3s7zBhe5Z5SZp2IrI5EWIcwu vsBu92h2Rzx3nRxukcFRelqxfQ+0IzQIZ2EBUeB1lN4B78zF5cwF/MSx3sYmvxSm/EkI cgfw== X-Gm-Message-State: AOAM53139wW9Hflh9nR2RuX90aup4i1lZpymG0J2d0XystEt9vnPKU84 IVHIBJ/4AVYlo9Fy1M0+N6nHPwdniHkIwURl X-Google-Smtp-Source: ABdhPJw8hXsE5DE2NHFLgnTB0R2jFYnUCfoREgxu17Q/Mason9sp6mst0v0EUFDx0fr9CB2mheLXZQ== X-Received: by 2002:a1c:220a:: with SMTP id i10mr1533796wmi.93.1608248646708; Thu, 17 Dec 2020 15:44:06 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:06 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com Subject: [PATCH v2 11/12] acpi: Add acpi_dev_get_next_match_dev() and helper macro Date: Thu, 17 Dec 2020 23:43:36 +0000 Message-Id: <20201217234337.1983732-12-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To ensure we handle situations in which multiple sensors of the same model (and therefore _HID) are present in a system, we need to be able to iterate over devices matching a known _HID but unknown _UID and _HRV - add acpi_dev_get_next_match_dev() to accommodate that possibility and change acpi_dev_get_first_match_dev() to simply call the new function with a NULL starting point. Add an iterator macro for convenience. Reviewed-by: Andy Shevchenko Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally Reviewed-by: Sakari Ailus --- Changes in v2: - None drivers/acpi/utils.c | 30 ++++++++++++++++++++++++++---- include/acpi/acpi_bus.h | 7 +++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index d5411a166685..c177165c8db2 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -843,12 +843,13 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) EXPORT_SYMBOL(acpi_dev_present); /** - * acpi_dev_get_first_match_dev - Return the first match of ACPI device + * acpi_dev_get_next_match_dev - Return the next match of ACPI device + * @adev: Pointer to the previous acpi_device matching this hid, uid and hrv * @hid: Hardware ID of the device. * @uid: Unique ID of the device, pass NULL to not check _UID * @hrv: Hardware Revision of the device, pass -1 to not check _HRV * - * Return the first match of ACPI device if a matching device was present + * Return the next match of ACPI device if another matching device was present * at the moment of invocation, or NULL otherwise. * * The caller is responsible to call put_device() on the returned device. @@ -856,8 +857,9 @@ EXPORT_SYMBOL(acpi_dev_present); * See additional information in acpi_dev_present() as well. */ struct acpi_device * -acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) +acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv) { + struct device *start = adev ? &adev->dev : NULL; struct acpi_dev_match_info match = {}; struct device *dev; @@ -865,9 +867,29 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) match.uid = uid; match.hrv = hrv; - dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb); + dev = bus_find_device(&acpi_bus_type, start, &match, acpi_dev_match_cb); return dev ? to_acpi_device(dev) : NULL; } +EXPORT_SYMBOL(acpi_dev_get_next_match_dev); + +/** + * acpi_dev_get_first_match_dev - Return the first match of ACPI device + * @hid: Hardware ID of the device. + * @uid: Unique ID of the device, pass NULL to not check _UID + * @hrv: Hardware Revision of the device, pass -1 to not check _HRV + * + * Return the first match of ACPI device if a matching device was present + * at the moment of invocation, or NULL otherwise. + * + * The caller is responsible to call put_device() on the returned device. + * + * See additional information in acpi_dev_present() as well. + */ +struct acpi_device * +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) +{ + return acpi_dev_get_next_match_dev(NULL, hid, uid, hrv); +} EXPORT_SYMBOL(acpi_dev_get_first_match_dev); /* diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a3abcc4b7d9f..0a028ba967d3 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -688,9 +688,16 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2); +struct acpi_device * +acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv); struct acpi_device * acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv); +#define for_each_acpi_dev_match(adev, hid, uid, hrv) \ + for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \ + adev; \ + adev = acpi_dev_get_next_match_dev(adev, hid, uid, hrv)) + static inline void acpi_dev_put(struct acpi_device *adev) { put_device(&adev->dev); From patchwork Thu Dec 17 23:43:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 11981035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77341C35270 for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50B3B2255F for ; Thu, 17 Dec 2020 23:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732463AbgLQXp2 (ORCPT ); Thu, 17 Dec 2020 18:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732427AbgLQXpS (ORCPT ); Thu, 17 Dec 2020 18:45:18 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EBC0C0611CD; Thu, 17 Dec 2020 15:44:09 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id g185so560783wmf.3; Thu, 17 Dec 2020 15:44:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GY38Ommxdt0MuxDp/P4qr28QYe1NhnpaVL1l+7wSres=; b=s9IBcd7KndwB8xXlF3FxailUy+qjll547di6SUaGQ1UzGjPHAu0sgqkX4NO8rkckv4 CCU+gXrJfUP7uq34t7I9H4cDwF6Gt1a9hFLtiwiM3lQ0cX/DjfC8OTQhYLhiORwoRSXD pi0Pka7v0utogZIIvgDYiQnrOrGeLIj1OoiOchwRkHIiM4ZCx3sLy/Y6JPsWN/HzNvls O1vVuctOsScKxoe/lkhFpRfmb384Mc/pTRTKFC3cNz6T9mOvdlgvfk+A0tqpmBHDV9wl sOLr/z18CDmRuFZogPJnSlwmb5bh4slFJFnk/1JdiiuUIcmPFeO+hmeoiaP6rcv23RqS x7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GY38Ommxdt0MuxDp/P4qr28QYe1NhnpaVL1l+7wSres=; b=c4r2QzO8gwFYQs+QzzYSegfrGoCHQcTl+/adHFabGYVgKsAPT9AUXq7YXKAkHCodjn 5V+QnjYBJGYxlimQ3DLZEzLVX/xp4UqPzXWpKGYZBwRh96RsCkvrBqqUfoCnjfy+V6i8 NmjyufNz8J2Wvc/BvpepzxLILo5n27g27Xo5CGTIMT0UTooHkLkhQLQTu4Rzo0KR/N2Y 3tnZNv7brMBajhpbHGwvf4RbF3iJ3hEMt6OCgfQQh/HwIBPHP4bT0+/zo/vWGUi8POAt vbCaUCtQ5qSrF/Aq19VUotbKx0OUkpEVpsTQyobFFzD4E0Es32d3JFeU0Abu5eWgn5M7 AxxA== X-Gm-Message-State: AOAM530TsTAbGyB8fBXeWipjXlyTut1iQb2IqDQ8W3UlmVJA1V1MKr01 oBx4bV7kwN5ptJI9M16GtxjkKtG/mDifa9kX X-Google-Smtp-Source: ABdhPJy6f8631qlIGF6d7DQ6Ge6eUohthbLeHXfKgMlLpvESkAXlJw0pApeFWItUS8IjQwHz+iG52Q== X-Received: by 2002:a1c:8d:: with SMTP id 135mr1535831wma.177.1608248648029; Thu, 17 Dec 2020 15:44:08 -0800 (PST) Received: from valhalla.home ([2.29.208.56]) by smtp.gmail.com with ESMTPSA id o3sm1873575wrc.93.2020.12.17.15.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:44:07 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com Subject: [PATCH v2 12/12] ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver Date: Thu, 17 Dec 2020 23:43:37 +0000 Message-Id: <20201217234337.1983732-13-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217234337.1983732-1-djrscally@gmail.com> References: <20201217234337.1983732-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently on platforms designed for Windows, connections between CIO2 and sensors are not properly defined in DSDT. This patch extends the ipu3-cio2 driver to compensate by building software_node connections, parsing the connection properties from the sensor's SSDB buffer. Suggested-by: Jordan Hand Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- Changes in v2: - Dropped some headers - Added support for specifying link-frequencies in the array of cio2_supported_sensors and added that property to the endpoint. - Replaced strcpy with strscpy (Laurent, I liked your change better stylistically but ofc the string literals are lost when the module is reloaded) - Named the ports/endpoints "port@%u" - Added an overflow check to cio2_bridge_connect_sensors() - A bunch of cosmetic changes For the cio2_supported_sensors array, specify link frequencies in this manner: CIO2_SENSOR_CONFIG("OVTI5648", 2, 16800000, 2100000) MAINTAINERS | 1 + drivers/media/pci/intel/ipu3/Kconfig | 18 ++ drivers/media/pci/intel/ipu3/Makefile | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 274 ++++++++++++++++++ drivers/media/pci/intel/ipu3/cio2-bridge.h | 122 ++++++++ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 34 +++ drivers/media/pci/intel/ipu3/ipu3-cio2.h | 6 + 7 files changed, 456 insertions(+) create mode 100644 drivers/media/pci/intel/ipu3/cio2-bridge.c create mode 100644 drivers/media/pci/intel/ipu3/cio2-bridge.h diff --git a/MAINTAINERS b/MAINTAINERS index 16b544624577..e7784b4bc8ea 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8943,6 +8943,7 @@ INTEL IPU3 CSI-2 CIO2 DRIVER M: Yong Zhi M: Sakari Ailus M: Bingbu Cao +M: Dan Scally R: Tianshu Qiu L: linux-media@vger.kernel.org S: Maintained diff --git a/drivers/media/pci/intel/ipu3/Kconfig b/drivers/media/pci/intel/ipu3/Kconfig index 82d7f17e6a02..dcf5c4b74673 100644 --- a/drivers/media/pci/intel/ipu3/Kconfig +++ b/drivers/media/pci/intel/ipu3/Kconfig @@ -16,3 +16,21 @@ config VIDEO_IPU3_CIO2 Say Y or M here if you have a Skylake/Kaby Lake SoC with MIPI CSI-2 connected camera. The module will be called ipu3-cio2. + +config CIO2_BRIDGE + bool "IPU3 CIO2 Sensors Bridge" + depends on VIDEO_IPU3_CIO2 + help + This extension provides an API for the ipu3-cio2 driver to create + connections to cameras that are hidden in SSDB buffer in ACPI. It + can be used to enable support for cameras in detachable / hybrid + devices that ship with Windows. + + Say Y here if your device is a detachable / hybrid laptop that comes + with Windows installed by the OEM, for example: + + - Microsoft Surface models (except Surface Pro 3) + - The Lenovo Miix line (for example the 510, 520, 710 and 720) + - Dell 7285 + + If in doubt, say N here. diff --git a/drivers/media/pci/intel/ipu3/Makefile b/drivers/media/pci/intel/ipu3/Makefile index 429d516452e4..933777e6ea8a 100644 --- a/drivers/media/pci/intel/ipu3/Makefile +++ b/drivers/media/pci/intel/ipu3/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_VIDEO_IPU3_CIO2) += ipu3-cio2.o ipu3-cio2-y += ipu3-cio2-main.o +ipu3-cio2-$(CONFIG_CIO2_BRIDGE) += cio2-bridge.o diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c new file mode 100644 index 000000000000..3f0e2d7eab20 --- /dev/null +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Dan Scally */ + +#include +#include +#include +#include + +#include "cio2-bridge.h" + +/* + * Extend this array with ACPI Hardware ID's of devices known to be working + * plus the number of link-frequencies expected by their drivers, along with + * the frequency values in hertz. This is somewhat opportunistic way of adding + * support for this for now in the hopes of a better source for the information + * (possibly some encoded value in the SSDB buffer that we're unaware of) + * becoming apparent in the future. + * + * Do not add an entry for a sensor that is not actually supported. + */ +static const struct cio2_sensor_config cio2_supported_sensors[] = { + CIO2_SENSOR_CONFIG("INT33BE", 0), + CIO2_SENSOR_CONFIG("OVTI2680", 0), +}; + +static int cio2_bridge_read_acpi_buffer(struct acpi_device *adev, char *id, + void *data, u32 size) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + acpi_status status; + int ret; + + status = acpi_evaluate_object(adev->handle, id, NULL, &buffer); + if (ACPI_FAILURE(status)) + return -ENODEV; + + obj = buffer.pointer; + if (!obj) { + dev_err(&adev->dev, "Couldn't locate ACPI buffer\n"); + return -ENODEV; + } + + if (obj->type != ACPI_TYPE_BUFFER) { + dev_err(&adev->dev, "Not an ACPI buffer\n"); + ret = -ENODEV; + goto out_free_buff; + } + + if (obj->buffer.length > size) { + dev_err(&adev->dev, "Given buffer is too small\n"); + ret = -EINVAL; + goto out_free_buff; + } + + memcpy(data, obj->buffer.pointer, obj->buffer.length); + ret = obj->buffer.length; + +out_free_buff: + kfree(buffer.pointer); + return ret; +} + +static void cio2_bridge_init_property_names(struct cio2_sensor *sensor) +{ + strscpy(sensor->prop_names.clock_frequency, "clock-frequency", + sizeof(sensor->prop_names.clock_frequency)); + strscpy(sensor->prop_names.rotation, "rotation", + sizeof(sensor->prop_names.rotation)); + strscpy(sensor->prop_names.bus_type, "bus-type", + sizeof(sensor->prop_names.bus_type)); + strscpy(sensor->prop_names.data_lanes, "data-lanes", + sizeof(sensor->prop_names.data_lanes)); + strscpy(sensor->prop_names.remote_endpoint, "remote-endpoint", + sizeof(sensor->prop_names.remote_endpoint)); + strscpy(sensor->prop_names.link_frequencies, "link-frequencies", + sizeof(sensor->prop_names.link_frequencies)); +} + +static void cio2_bridge_create_fwnode_properties(struct cio2_sensor *sensor, + const struct cio2_sensor_config *cfg) +{ + unsigned int i; + + cio2_bridge_init_property_names(sensor); + + for (i = 0; i < 4; i++) + sensor->data_lanes[i] = i + 1; + + sensor->local_ref[0].node = &sensor->swnodes[SWNODE_CIO2_ENDPOINT]; + sensor->remote_ref[0].node = &sensor->swnodes[SWNODE_SENSOR_ENDPOINT]; + + sensor->dev_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.clock_frequency, + sensor->ssdb.mclkspeed); + sensor->dev_properties[1] = PROPERTY_ENTRY_U8(sensor->prop_names.rotation, + sensor->ssdb.degree); + + sensor->ep_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.bus_type, 4); + sensor->ep_properties[1] = PROPERTY_ENTRY_U32_ARRAY_LEN(sensor->prop_names.data_lanes, + sensor->data_lanes, + sensor->ssdb.lanes); + sensor->ep_properties[2] = PROPERTY_ENTRY_REF_ARRAY(sensor->prop_names.remote_endpoint, + sensor->local_ref); + + if (cfg->nr_link_freqs > 0) + sensor->ep_properties[3] = PROPERTY_ENTRY_U64_ARRAY_LEN( + sensor->prop_names.link_frequencies, + cfg->link_freqs, + cfg->nr_link_freqs); + + sensor->cio2_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN(sensor->prop_names.data_lanes, + sensor->data_lanes, + sensor->ssdb.lanes); + sensor->cio2_properties[1] = PROPERTY_ENTRY_REF_ARRAY(sensor->prop_names.remote_endpoint, + sensor->remote_ref); +} + +static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor) +{ + snprintf(sensor->node_names.remote_port, 7, "port@%u", sensor->ssdb.link); + strscpy(sensor->node_names.port, "port@0", sizeof(sensor->node_names.port)); + strscpy(sensor->node_names.endpoint, "endpoint@0", sizeof(sensor->node_names.endpoint)); +} + +static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, + struct cio2_sensor *sensor) +{ + struct software_node *nodes = sensor->swnodes; + + cio2_bridge_init_swnode_names(sensor); + + nodes[SWNODE_SENSOR_HID] = NODE_SENSOR(sensor->name, + sensor->dev_properties); + nodes[SWNODE_SENSOR_PORT] = NODE_PORT(sensor->node_names.port, + &nodes[SWNODE_SENSOR_HID]); + nodes[SWNODE_SENSOR_ENDPOINT] = NODE_ENDPOINT(sensor->node_names.endpoint, + &nodes[SWNODE_SENSOR_PORT], + sensor->ep_properties); + nodes[SWNODE_CIO2_PORT] = NODE_PORT(sensor->node_names.remote_port, + &bridge->cio2_hid_node); + nodes[SWNODE_CIO2_ENDPOINT] = NODE_ENDPOINT(sensor->node_names.endpoint, + &nodes[SWNODE_CIO2_PORT], + sensor->cio2_properties); +} + +static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge) +{ + struct cio2_sensor *sensor; + unsigned int i; + + for (i = 0; i < bridge->n_sensors; i++) { + sensor = &bridge->sensors[i]; + software_node_unregister_nodes(sensor->swnodes); + acpi_dev_put(sensor->adev); + } +} + +static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge, + struct pci_dev *cio2) +{ + struct fwnode_handle *fwnode; + struct cio2_sensor *sensor; + struct acpi_device *adev; + unsigned int i; + int ret = 0; + + for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) { + const struct cio2_sensor_config *cfg = &cio2_supported_sensors[i]; + + for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { + if (bridge->n_sensors >= CIO2_NUM_PORTS) { + dev_warn(&cio2->dev, "Exceeded available CIO2 ports\n"); + /* overflow i so outer loop ceases */ + i = ARRAY_SIZE(cio2_supported_sensors); + break; + } + + if (!adev->status.enabled) + continue; + + sensor = &bridge->sensors[bridge->n_sensors]; + sensor->adev = adev; + strscpy(sensor->name, cfg->hid, sizeof(sensor->name)); + + ret = cio2_bridge_read_acpi_buffer(adev, "SSDB", + &sensor->ssdb, + sizeof(sensor->ssdb)); + if (ret < 0) + goto err_put_adev; + + if (sensor->ssdb.lanes > 4) { + dev_err(&adev->dev, + "Number of lanes in SSDB is invalid\n"); + goto err_put_adev; + } + + cio2_bridge_create_fwnode_properties(sensor, cfg); + cio2_bridge_create_connection_swnodes(bridge, sensor); + + ret = software_node_register_nodes(sensor->swnodes); + if (ret) + goto err_put_adev; + + fwnode = software_node_fwnode(&sensor->swnodes[SWNODE_SENSOR_HID]); + if (!fwnode) { + ret = -ENODEV; + goto err_free_swnodes; + } + + adev->fwnode.secondary = fwnode; + + dev_info(&cio2->dev, "Found supported sensor %s\n", + acpi_dev_name(adev)); + + bridge->n_sensors++; + } + } + + return ret; + +err_free_swnodes: + software_node_unregister_nodes(sensor->swnodes); +err_put_adev: + acpi_dev_put(sensor->adev); + + return ret; +} + +int cio2_bridge_init(struct pci_dev *cio2) +{ + struct device *dev = &cio2->dev; + struct fwnode_handle *fwnode; + struct cio2_bridge *bridge; + int ret; + + bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); + if (!bridge) + return -ENOMEM; + + strscpy(bridge->cio2_node_name, CIO2_HID, sizeof(bridge->cio2_node_name)); + bridge->cio2_hid_node.name = bridge->cio2_node_name; + + ret = software_node_register(&bridge->cio2_hid_node); + if (ret < 0) { + dev_err(dev, "Failed to register the CIO2 HID node\n"); + goto err_free_bridge; + } + + ret = cio2_bridge_connect_sensors(bridge, cio2); + if (ret || bridge->n_sensors == 0) + goto err_unregister_cio2; + + dev_info(dev, "Connected %d cameras\n", bridge->n_sensors); + + fwnode = software_node_fwnode(&bridge->cio2_hid_node); + if (!fwnode) { + dev_err(dev, "Error getting fwnode from cio2 software_node\n"); + ret = -ENODEV; + goto err_unregister_sensors; + } + + set_secondary_fwnode(dev, fwnode); + + return 0; + +err_unregister_sensors: + cio2_bridge_unregister_sensors(bridge); +err_unregister_cio2: + software_node_unregister(&bridge->cio2_hid_node); +err_free_bridge: + kfree(bridge); + + return ret; +} diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h new file mode 100644 index 000000000000..f89a8e33f82c --- /dev/null +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Author: Dan Scally */ +#ifndef __CIO2_BRIDGE_H +#define __CIO2_BRIDGE_H + +#include + +#define CIO2_HID "INT343E" +#define CIO2_NUM_PORTS 4 +#define MAX_NUM_LINK_FREQS 3 + +#define CIO2_SENSOR_CONFIG(_HID, _NR, ...) \ + { \ + .hid = _HID, \ + .nr_link_freqs = _NR, \ + .link_freqs = { __VA_ARGS__ } \ + } + +#define NODE_SENSOR(_HID, _PROPS) \ + ((const struct software_node) { \ + .name = _HID, \ + .properties = _PROPS, \ + }) + +#define NODE_PORT(_PORT, _SENSOR_NODE) \ + ((const struct software_node) { \ + _PORT, \ + _SENSOR_NODE, \ + }) + +#define NODE_ENDPOINT(_EP, _PORT, _PROPS) \ + ((const struct software_node) { \ + _EP, \ + _PORT, \ + _PROPS, \ + }) + +enum cio2_sensor_swnodes { + SWNODE_SENSOR_HID, + SWNODE_SENSOR_PORT, + SWNODE_SENSOR_ENDPOINT, + SWNODE_CIO2_PORT, + SWNODE_CIO2_ENDPOINT, + NR_OF_SENSOR_SWNODES +}; + +/* Data representation as it is in ACPI SSDB buffer */ +struct cio2_sensor_ssdb { + u8 version; /* 0000 */ + u8 sku; /* 0001 */ + u8 guid_csi2[16]; /* 0002 */ + u8 devfunction; /* 0003 */ + u8 bus; /* 0004 */ + u32 dphylinkenfuses; /* 0005 */ + u32 clockdiv; /* 0009 */ + u8 link; /* 0013 */ + u8 lanes; /* 0014 */ + u32 csiparams[10]; /* 0015 */ + u32 maxlanespeed; /* 0019 */ + u8 sensorcalibfileidx; /* 0023 */ + u8 sensorcalibfileidxInMBZ[3]; /* 0024 */ + u8 romtype; /* 0025 */ + u8 vcmtype; /* 0026 */ + u8 platforminfo; /* 0027 */ + u8 platformsubinfo; + u8 flash; + u8 privacyled; + u8 degree; + u8 mipilinkdefined; + u32 mclkspeed; + u8 controllogicid; + u8 reserved1[3]; + u8 mclkport; + u8 reserved2[13]; +} __packed; + +struct cio2_property_names { + char clock_frequency[16]; + char rotation[9]; + char bus_type[9]; + char data_lanes[11]; + char remote_endpoint[16]; + char link_frequencies[17]; +}; + +struct cio2_node_names { + char port[7]; + char endpoint[11]; + char remote_port[7]; +}; + +struct cio2_sensor_config { + const char *hid; + const u8 nr_link_freqs; + const u64 link_freqs[MAX_NUM_LINK_FREQS]; +}; + +struct cio2_sensor { + char name[ACPI_ID_LEN]; + struct acpi_device *adev; + + struct software_node swnodes[6]; + struct cio2_node_names node_names; + + u32 data_lanes[4]; + struct cio2_sensor_ssdb ssdb; + struct cio2_property_names prop_names; + struct property_entry ep_properties[5]; + struct property_entry dev_properties[3]; + struct property_entry cio2_properties[3]; + struct software_node_ref_args local_ref[1]; + struct software_node_ref_args remote_ref[1]; +}; + +struct cio2_bridge { + char cio2_node_name[ACPI_ID_LEN]; + struct software_node cio2_hid_node; + unsigned int n_sensors; + struct cio2_sensor sensors[CIO2_NUM_PORTS]; +}; + +#endif diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c index 36e354ecf71e..68ff28abc6a3 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c @@ -1702,11 +1702,28 @@ static void cio2_queues_exit(struct cio2_device *cio2) cio2_queue_exit(cio2, &cio2->queue[i]); } +static bool cio2_check_fwnode_graph(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *endpoint; + + if (IS_ERR_OR_NULL(fwnode)) + return false; + + endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (endpoint) { + fwnode_handle_put(endpoint); + return true; + } + + return cio2_check_fwnode_graph(fwnode->secondary); +} + /**************** PCI interface ****************/ static int cio2_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { + struct fwnode_handle *fwnode = dev_fwnode(&pci_dev->dev); struct cio2_device *cio2; int r; @@ -1715,6 +1732,23 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, return -ENOMEM; cio2->pci_dev = pci_dev; + /* + * On some platforms no connections to sensors are defined in firmware, + * if the device has no endpoints then we can try to build those as + * software_nodes parsed from SSDB. + */ + if (!cio2_check_fwnode_graph(fwnode)) { + if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) { + dev_err(&pci_dev->dev, + "fwnode graph has no endpoints connected\n"); + return -EINVAL; + } + + r = cio2_bridge_init(pci_dev); + if (r) + return r; + } + r = pcim_enable_device(pci_dev); if (r) { dev_err(&pci_dev->dev, "failed to enable device (%d)\n", r); diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h index ccf0b85ae36f..520a27c9cdad 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h @@ -437,4 +437,10 @@ static inline struct cio2_queue *vb2q_to_cio2_queue(struct vb2_queue *vq) return container_of(vq, struct cio2_queue, vbq); } +#if IS_ENABLED(CONFIG_CIO2_BRIDGE) +int cio2_bridge_init(struct pci_dev *cio2); +#else +int cio2_bridge_init(struct pci_dev *cio2) { return 0; } +#endif + #endif