From patchwork Mon Nov 30 13:31:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335404 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.8 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 631D9C83016 for ; Mon, 30 Nov 2020 13:32:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C27F21D46 for ; Mon, 30 Nov 2020 13:32:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aCL28tM5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbgK3Nci (ORCPT ); Mon, 30 Nov 2020 08:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgK3Ncg (ORCPT ); Mon, 30 Nov 2020 08:32:36 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD8CC0613D2; Mon, 30 Nov 2020 05:31:55 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id a3so25181444wmb.5; Mon, 30 Nov 2020 05:31: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=RJsQiHGqEJvDI1A950rE2xj0EG8wzsrrAHbyxhByNz0=; b=aCL28tM5Keans39iuF0yPmX8N2Zo6DPH4Ma7s7dw4MyY3eGABozdRLlf6DFDkUzn0k HsURvPU0p1ZOQwfMSn1dPSl7KUl4VQsA+pBuvR2GZQWvLyLTETkYDpW4pB50dJGEDAVT Gl6iinIuTEdutRdQFyoMROOJLR4pP0/11oJgm6QgsEmc0wK13XNqqHZKSO8HGXAOcBhP 4uCYVP6WetkhuOaHwSg9W0DMQni9jk5yjPGkx8IebTAGt+GcfUg9covZKsRMekzLILgF 3KA9ikRPV8GB3d3t7E+i3TsSm+P3yO8JCND8N8DtHxCJ8WPkOL/ZQN0kwVMVAMMUT/tV tkIw== 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=RJsQiHGqEJvDI1A950rE2xj0EG8wzsrrAHbyxhByNz0=; b=qkw/s5tU7x9ZX58R34bAXdSqcSsMcoCCbCx98ut4Kf3U7DUENYU/9oWNCyTP1WfwVG K3qiC+0YOVwu81v4SfuJi9JHLu0yiq/NvyHeWKua2sTpuqoeZrwq2FEaFrSmWmOQ/in1 dTqRns3EOWr+9oD7r8JoccWTtIFKA14XwTs+XTeLuH/S53vw0eMB0m5AkT8bcHV4alAN GBUWrFfNYpgIAoZPsETTyK+59mv8F1q2u27GAA6/ugV0RtpWaQvkaYUiVm5H+0ygrI48 22LYYyHe3Z8tJUMVJxHN8q8mLCKHWnR4are7A1c/MJQxFLpcC8StrNOQjCp52iKVhqYs h9WQ== X-Gm-Message-State: AOAM532QGq0W4IKF71YQNxv3rMxukllk4Tl+nwAU6iICi5bAsghFmrKz IPBNiRY0OVx9Wrr9WhXyX2UbvCWl89QW1hv4 X-Google-Smtp-Source: ABdhPJwPbNSwrCgOQ0IMIpkzz/7n/VoBoBA1eGQ5Ii7+/pXicjg96dORtNIdGwUWRytKAvCDAttg9A== X-Received: by 2002:a1c:99d3:: with SMTP id b202mr23640950wme.0.1606743113991; Mon, 30 Nov 2020 05:31:53 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:31:53 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com, Laurent Pinchart Subject: [PATCH 01/18] property: Return true in fwnode_device_is_available for node types that do not implement this operation Date: Mon, 30 Nov 2020 13:31:12 +0000 Message-Id: <20201130133129.1024662-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 Signed-off-by: Daniel Scally --- Changes since RFC v3: patch introduced drivers/base/property.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4c43d30145c6..a5ca2306796f 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -785,9 +785,14 @@ 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 Mon Nov 30 13:31:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335403 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.8 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,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 7A33EC83021 for ; Mon, 30 Nov 2020 13:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F72F20825 for ; Mon, 30 Nov 2020 13:32:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JVUuwkGJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbgK3Ncj (ORCPT ); Mon, 30 Nov 2020 08:32:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbgK3Nch (ORCPT ); Mon, 30 Nov 2020 08:32:37 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2452C0613D3; Mon, 30 Nov 2020 05:31:56 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id r3so16245414wrt.2; Mon, 30 Nov 2020 05:31:56 -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=pBmA2HioX2UOik7KR00ouIZb6c9//C/JEc7oIKLhFcY=; b=JVUuwkGJ4NaNb4HLNMLQMgIDISYvV/gUvh2+I8ROZLZfa2ArJ02t4klczA1AVqGmKA 8BhgJocg2bdn/9CLqAn59pwI/chqAFBGJitzVjZuNhPJokxYZvuiSwGIvR1kGAEPufBB 9h6zoAoKp0eoCsNVxTcNHvpcHUL1l4uT26DAtqXXhKdb3YhxrsJsn9nMR44YSaGuGqey gHJ/5b4FDD0yej47dY1G6SnhFpjVsCh4GkYVE16P9aI/K+sJ5wacNAoDQ2SnVzADnfSo QHY8qBwE9OdR/xrPm6iYuwsjLoNx2YrFmN/la1JTAMUNhTbAE+Qvr13cCPgSktyLSJ5C zZRg== 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=pBmA2HioX2UOik7KR00ouIZb6c9//C/JEc7oIKLhFcY=; b=UdF883nmhtYuFVlF4Fcei2VMg36joPnDTyJjXFpMlsDP0OLXygeFWqGGUHeSg7az1v Sz4wc57iGS1z2xhuftBKujQHtRH3gbpbAyuqetsY7TPYlmLDbSEpZfghD0BHIgaUQeCG csMrnp4o7V8Dx42GY99TRg9NDkWGZDede4zwybAQBBWk3747RPd6/OtAbJft0vupzQDK M07o+9UhqHoeHMOLcpcEhFEGwdalNxG+q+tvcAnctIgWgLb1t4Hga/X5b3czcoCKjYj8 XgXXEwkc+EzNBylL/kLFXu5CRFTKvQ5O7xsZ6RNwcPVPZFMXNbaGx2eNtjRA5YxxUCDk BIiQ== X-Gm-Message-State: AOAM5305HypKY2gFPuu2M+xF82HKllm8bPdjYB+52qEkP62gr1V8o0xm LZ6ymfcrfaRNGgzQawKEGWNBVn1zQDdYNQoW X-Google-Smtp-Source: ABdhPJwJReLGmQDmMBx5sI3o4Ddyr/ckN/oTbfZCoRx7mDtrmB/TSoplbGx15zWUvGD03E8J9yGkhA== X-Received: by 2002:adf:916e:: with SMTP id j101mr29144408wrj.55.1606743115428; Mon, 30 Nov 2020 05:31:55 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:31:54 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 02/18] property: Add support for calling fwnode_graph_get_endpoint_by_id() for fwnode->secondary Date: Mon, 30 Nov 2020 13:31:13 +0000 Message-Id: <20201130133129.1024662-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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. Signed-off-by: Daniel Scally --- Changes since RFC v3: Patch introduced. In discussion in the last submission I noted that the CIO2 device doesn't have an ACPI fwnode - that turns out to be true for _some_ devices but not others, so we need this function to check the secondary too. drivers/base/property.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index a5ca2306796f..4ece6b086e36 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1162,6 +1162,10 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, best_ep_id = fwnode_ep.id; } + if (!best_ep && fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) + return fwnode_graph_get_endpoint_by_id(fwnode->secondary, port, + endpoint, flags); + return best_ep; } EXPORT_SYMBOL_GPL(fwnode_graph_get_endpoint_by_id); From patchwork Mon Nov 30 13:31:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335402 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.8 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,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 37CFCC8300F for ; Mon, 30 Nov 2020 13:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5A57208DB for ; Mon, 30 Nov 2020 13:32:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dFB1ezxP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgK3Ncq (ORCPT ); Mon, 30 Nov 2020 08:32:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbgK3Ncj (ORCPT ); Mon, 30 Nov 2020 08:32:39 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70490C0613D4; Mon, 30 Nov 2020 05:31:58 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id z7so16225475wrn.3; Mon, 30 Nov 2020 05:31: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=Mt2fBAtoQbvZ5hTUX8F9k24XA25dZdnBW06oRQeyp3I=; b=dFB1ezxPwnCdWAf6tGcY9k4y1dMIQqV37aQcyTmKo+ChI4FAn8cddNVe0AGbAj5wVR nDSpSflBBGbemqkqKuAXsJBShrEB6yCD/7EEtaxB2YxiRSq3GEmuAy0xlerjftl8yaoT DgpKgRwk8m6W/+m+FFx0FPZwsy6LTl7ciuxSUvSvWku6slFkRPkpz83vRSxhSNfEcf6M m82SxlujXi6iMuANT8L3zlBzEz3f/STr8RfWVhjRbA0AkhoXNuSHDbQavOqdRRSiRgMl 9RTBoTebF3JgtQ45dng1RpuoEULMrKQFqzLT5mco1X/+RPLSleXuW+UXdNVA/iLxKpgx GODA== 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=Mt2fBAtoQbvZ5hTUX8F9k24XA25dZdnBW06oRQeyp3I=; b=r+gWCC254ZW5yabiLoCJY+O/9bRO9ORqS+1Y29Sr1Bj+0rTRve27HUeWvzsCmFHpLK h+brq/0rtaVHFKsRbUuV+yCbTIEFqAcKpJ3FK/iUDypsoC+8gWp3EI6Eaji5BMpuXjkr 89VFOYGeEO6rPzoVT4ucE6Z8vzF2fR+UKewm+TTyAPoBIgMFFsCt34y3/Qtvp3h4gl9O RrwR56dL45p40Rh32OkgZiPg4WHl15YzACeX4bEhSGt/iFrwNBB538bHIDoFT85ms2eI wsgpgQ3CcOcp3nUtmu5sK7xWE/Pp8hTbZd2R+nPSxbbXeIqKo5OPPsgFZI8lb2VGBMlM ZsCw== X-Gm-Message-State: AOAM5313/PCo6TaP6N3g/qiGTwaPmYUtFWYnkdEfQM8WWyJnUllK9plH sDnBiObgv6N+z16r8e79izhpEzY40xnuPzkl X-Google-Smtp-Source: ABdhPJyz97co4wzGWBGHdxBJZB5BhplZYCrWZgDWR717m1Ny05GyKxudg6DzlyUYknC3K2O2brL7nA== X-Received: by 2002:adf:f3c7:: with SMTP id g7mr28182991wrp.91.1606743116927; Mon, 30 Nov 2020 05:31:56 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:31:56 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 03/18] software_node: Fix failure to put() and get() references to children in software_node_get_next_child() Date: Mon, 30 Nov 2020 13:31:14 +0000 Message-Id: <20201130133129.1024662-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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. Signed-off-by: Daniel Scally --- Changes since RFC v3: Put reference to previous child. 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 Mon Nov 30 13:31:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334914 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.8 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 2FBFCC64E7B for ; Mon, 30 Nov 2020 13:32:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3CFA2087C for ; Mon, 30 Nov 2020 13:32:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PM/YOw7P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbgK3Ncl (ORCPT ); Mon, 30 Nov 2020 08:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbgK3Nck (ORCPT ); Mon, 30 Nov 2020 08:32:40 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E71C0613D6; Mon, 30 Nov 2020 05:31:59 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id z7so16225563wrn.3; Mon, 30 Nov 2020 05:31: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=FePnQn4sOjIUa7n1a1AkFBbevNR2+2SK//M9YhzxN2A=; b=PM/YOw7P5R3RYA3romGtkjPAxx82J5/HMMsPKt6mYIJpu9Cj2e4A1oSI0gf7rQzEmL EAvt7RDcCh9Yffz+57Ko1QRGhm4XwvBWdVNIE0aV6m0QIlZOidH7pTC+JlC9rw5krB60 mZr87CzJOLVm2pfldpJZhaCTvJwcpoaKLjIuRxzlB1oBuKJpLcPB8SALog27LXtuCaST 0/Y4lW/1Zy7pJ3BnuTOzNZwxmdaNUZAZKQ+/6I5qJ/wAZgMnqAX7wXQTQXGBgnlQ1h+2 BBxh8hDijrDng6sGFg5SKmPN8kDJvI24vfLUS2neisbfffKuC1Zsd/SDUrd4DmQlgldM SldQ== 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=FePnQn4sOjIUa7n1a1AkFBbevNR2+2SK//M9YhzxN2A=; b=NvrhkDYDtIF0AzCtdl7YbQARVAhp+4MbQkfthJbQ9EMenu7hMFO5K/E1YHsjEL7uGj 3ymTCvf5lwoyH/Q0Bb+utfWX4+kHgILatmnsqgObrvzZbEIVSgmjntdIl+sNVt9jpXsb 85dCbj+DwGYXVop9SsCViUd0Mq9y9m8y2XKfsHBE4l4mXAqg383VrzDInQfqy38LvdnW TkCqjHhLxZ9RJzS+xnsldfgrFMGNxQOMyMWvNXcOyxt9QrxCUjA+m5xDo8HV3GTxQp4B Gg492F4vGUyCGEkvGqRn84X7amqKdEVf5fxuRNBrJulkK2FYw2fdewZLFUXcWR2pIvgi DJIg== X-Gm-Message-State: AOAM531Nff8guToaVTAzKxRTIwy5P3hzw71kgQYfH8MuBvkL+YQxX5RW Zvv4xGeCEP0uEkHcjBv6ACwIsIeYqvXUFE2g X-Google-Smtp-Source: ABdhPJxcrjv1HcdEbv2OM0uY8wL3w4pWdRYFa2ZVlxXHKfJRC+d5brQXdT3aThuu9hFxcO1JjpV99g== X-Received: by 2002:adf:fd47:: with SMTP id h7mr29381616wrs.106.1606743118371; Mon, 30 Nov 2020 05:31:58 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:31:57 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 04/18] software_node: Enforce parent before child ordering of nodes array for software_node_register_nodes() Date: Mon, 30 Nov 2020 13:31:15 +0000 Message-Id: <20201130133129.1024662-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 to this function. Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes since RFC v3: Patch introduced drivers/base/swnode.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 615a0c93e116..af7930b3679e 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -700,14 +700,21 @@ int software_node_register_nodes(const struct software_node *nodes) int i; for (i = 0; nodes[i].name; i++) { + if (nodes[i].parent) + if (!software_node_to_swnode(nodes[i].parent)) { + ret = -EINVAL; + goto err_unregister_nodes; + } + ret = software_node_register(&nodes[i]); - if (ret) { - software_node_unregister_nodes(nodes); - return ret; - } + 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); From patchwork Mon Nov 30 13:31:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335396 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.8 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 C36D7C8302E for ; Mon, 30 Nov 2020 13:34:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F809207BC for ; Mon, 30 Nov 2020 13:34:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="plUqWbBC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727223AbgK3NeE (ORCPT ); Mon, 30 Nov 2020 08:34:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbgK3NdU (ORCPT ); Mon, 30 Nov 2020 08:33:20 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C34FC0617A6; Mon, 30 Nov 2020 05:32:01 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id r3so16245730wrt.2; Mon, 30 Nov 2020 05:32: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=J3yOjM1+/wwV5fdoMWqJFpfZ/FDOx9RThnGQ3iq7dmg=; b=plUqWbBCxH+vhzGu1befzPbYHZOK/zl7JXWO5KxV4Bhx5zzf/meAPDkoBGQYco5ZFu Q9ymtlbjpenLCw8Z5CJMJLHmJOLfeXIAMWvFg9MYmZrZIzNQEjnyiaISmzKVwMXrE4gy DnBsxnGSVE+Jh7KR5MTV+Deo6G1hI9m9qcleRk1p94RhzuIBgXCamTUepfHR4cXKZZ+o gFFpsHWf7mIm1bY+ICqMmUyUofStPupYaASEl1+B+ch/t7pE/J7Dqk+OkGTMIA7ZpoIk BBbMed4yBQCQKVRg1y4jnxqr0cOQAP5zKT+vOxVxFAwvugncBEq5+fjZxXUc/wRx3mXY MDJg== 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=J3yOjM1+/wwV5fdoMWqJFpfZ/FDOx9RThnGQ3iq7dmg=; b=Wz2mjr/D4Q6EtuUXpD5pAmHoggXczov2ZNJZq58g5djRKXaCUNZmxSBkKK1k+s6OwN 5vHhCbMGwC+pe/HRHcbF0tTSWjQO16wexsPQ7GUgufALBBmCox7GpB5vK4u5BRQfKx2p sEvFs9FgBLVJtYGz9oC2C3X53qrIYpiad2Vs38eBR4XlKcSIyJrLbKRMpgaxg+hVMRWT c5e5xvi97Ob2SFmWncZYPTXe7Bw87Xsh5f7A4GuiAb/KZUyIp5FU8/tfls8tkM4me2Es Bs95LLVnOeHM/QV8qdeqbRtYpGzXVGzOv8EfNKvPy8IND2CdkpH82KYdK8g/pM13dfM8 4k4g== X-Gm-Message-State: AOAM532+ov+BugwBKmEcKmn9TSZKACa6z/4nPGDPP9clv/81vtGgYE69 8EI2mqdAQDEXow9F3mr4XkqI+ICT3QzOELC1 X-Google-Smtp-Source: ABdhPJxmDOmkAli8PCxbBBWHn5U/bF5oL+V8iSg+mtHUYGvUsMa7e2ABUXizOD+UAW2e1G8PYRwGLw== X-Received: by 2002:a05:6000:1cf:: with SMTP id t15mr27503567wrx.321.1606743119922; Mon, 30 Nov 2020 05:31:59 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:31:59 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 05/18] software_node: Alter software_node_unregister_nodes() to unregister the array in reverse order Date: Mon, 30 Nov 2020 13:31:16 +0000 Message-Id: <20201130133129.1024662-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 this function unregisters software_nodes. Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes since RFC v3: Switched this functionality from a new function to replacing the existing software_nodes_unregister_nodes() drivers/base/swnode.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index af7930b3679e..d39e1c76d98d 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -720,20 +720,25 @@ 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. 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. * * Unregister multiple software nodes at once. * - * 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 Mon Nov 30 13:31:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334913 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.8 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 AABC7C8300F for ; Mon, 30 Nov 2020 13:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4690120825 for ; Mon, 30 Nov 2020 13:33:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntKHJ05P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbgK3NdP (ORCPT ); Mon, 30 Nov 2020 08:33:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgK3NdO (ORCPT ); Mon, 30 Nov 2020 08:33:14 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBB5BC0617A7; Mon, 30 Nov 2020 05:32:02 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id d3so15383938wmb.4; Mon, 30 Nov 2020 05:32: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=MQdwYeMzPseIpDXUiLIT9hkS7ClLsv/lm9CY7n8eprs=; b=ntKHJ05P7kwwej7B3/bM8gpGvw9px5edstK9WYOoikfPuhXRzvnrEdIzSdLQ183++J csaWbbzBeFIeE+Qu8pn/+Ja1p9NSv9A39w70AOC+XN9GTUx5ECILc+IexJH8Zr98HN71 8/0V/mO1noQAy2U80MBWRW6y2nVk4kq1Z9Ji3t2JVxmVptw66EXX2vy9UTSTzjYwfWoK Ncy2pqphfNUeyALQRDmcFee39rETI6qGDiM6Ds2g+TfAQmb83QXh7AX9hfxRcCzfU0FU oe0Yi6dfNEACMd+hVUVsUVfJzU/L0xXoTg91JVuVlNR05K0pbNMc1aWhTBfJ2SPgQoh4 vfXw== 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=MQdwYeMzPseIpDXUiLIT9hkS7ClLsv/lm9CY7n8eprs=; b=K5Hkei3wjLBXk/ZfP4Su8q4fwpqF4VU35XEyCPaPLxSbPfQALI3JM+vx0iBEpbjlpy 3r3zrtMRy8E5DwnTZbbSefvtHlXdKfPL5DS7gGpVgWbRaBKWbJlpioSp+hVci1duPH8y 8FoINJh0tzwXn4PWjX1gTDWd4Kc2SxoS2V97WkruzZdbUca6ry5/ewVwhsJhi5Esp6P7 XsAWHPi1UZ1F2AUmX7jn+hEABxk71mGmKoC/9v3G2VDFBVSalbF9YzX2r3KRfRHbFdKy Yd6pmQVECuP3P2nBIrWUWZRA+lciostvnCl5aiWkPCjk+KeZBSz8rep2bBBU3i6X8sQQ A9BA== X-Gm-Message-State: AOAM5321EOcUyXVkhT/NXK4xYUhvHc0k7R8NpZ0gW9JUdCd2TjBtl0zG GxWtI7VI/1AHoGvW2daxcbp39ChtgGpcf/kf X-Google-Smtp-Source: ABdhPJxHqd9qSFpaMcuFblPNdct1nYlwJkSKoY66tmWoUlL/S+cakZ0YUKByMejlo1eGSNUdopCTkQ== X-Received: by 2002:a7b:c0d7:: with SMTP id s23mr23332580wmh.54.1606743121413; Mon, 30 Nov 2020 05:32:01 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:00 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 06/18] software_node: amend software_node_unregister_node_group() to perform unregistration of array in reverse order to be consistent with software_node_unregister_nodes() Date: Mon, 30 Nov 2020 13:31:17 +0000 Message-Id: <20201130133129.1024662-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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. Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: Dan Carpenter --- Changes since v3: Patch introduced drivers/base/swnode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index d39e1c76d98d..9bd0bb77ad5b 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -782,7 +782,10 @@ void software_node_unregister_node_group(const struct software_node **node_group 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 Mon Nov 30 13:31:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335401 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.8 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 28211C83013 for ; Mon, 30 Nov 2020 13:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA6802087C for ; Mon, 30 Nov 2020 13:33:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lBnhvpDR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726956AbgK3NdT (ORCPT ); Mon, 30 Nov 2020 08:33:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbgK3NdS (ORCPT ); Mon, 30 Nov 2020 08:33:18 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 900AEC061A47; Mon, 30 Nov 2020 05:32:04 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id f190so22147865wme.1; Mon, 30 Nov 2020 05:32: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=v9hgkB45IAZvjm6wECtiA2RMiJReOpFXi8K4dGY5xEQ=; b=lBnhvpDR2OZilI5L1ubpeo4iuPqpqH1Xu/JaFgzgEkEpP+8cln503R/aEyo9lrCPz0 ZJK9Rae/iklw+x7E/+LJBE8tpd+PlZTK4mkth98JPSiUMwzVJyRo98+fZnwRHAfC6z16 gyQ+jRUrLYk2wo758TK7XuqFwG6Wp9fDzG8GePKFFeVhDQsZ1GIXRqAujU/ZzRl25Kdt Wo3HmXrTS3VGBclLstUuDBIRhk7rzyFhZaRDr4fb9RruJPUWkF5eTN7d4KogVnzt7rA0 zKs0K/iXyGP4E14Qt6BdMjoPrJMcS8bVib6bXm6G9ScTmQUM+SKHOitCnQahrvkcEP0u nZFQ== 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=v9hgkB45IAZvjm6wECtiA2RMiJReOpFXi8K4dGY5xEQ=; b=E5Bjy7AYaY/lasTJEmtVr05Cif/PYNXJqfvZnkuXUlNQcpPZpV5UONXQLpzc32Y5qo gUWctFO9mBHNt0LPOYwl+8N6lrAfZktBbPYM1nXRA2LXYrAjbrn2VSQYxPo9XZGpG+LQ A5twWWtwQgFB1scmU5wOnfRaa7xPyjmRqODe4nomSvZa0Y0Is5OyCEoTN8zpaE9aoeSx kic61ossUnmJEgtqtn1P4hPHZY9TCQILoKOjykmcvP3GEqwH7iMk/Cc/joilXVU//aGL SBf9T8tfi2eOXXJl0U79xPh5rlNISVWw+OXNX+oWIDgimRLswfKjXTGSA+9u2Dj5hUZ7 9i6Q== X-Gm-Message-State: AOAM533hOd8tK6/YCgtnjRzwkZg0tF5PS56NgD9ClkeAPO8jFyP2IkWe RZZczE+1BUePZhbFGq3ULIOThxIs3y3iIiuW X-Google-Smtp-Source: ABdhPJwoVt5eH9bGJUi3K8IZN8T56R8RDLI8GHjsiwuH8QBPp1iY9Z0IPNQD/xZFbvLY38CW9Gq4wg== X-Received: by 2002:a05:600c:229a:: with SMTP id 26mr23827131wmf.100.1606743122966; Mon, 30 Nov 2020 05:32:02 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:02 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 07/18] software_node: Add support for fwnode_graph*() family of functions Date: Mon, 30 Nov 2020 13:31:18 +0000 Message-Id: <20201130133129.1024662-8-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Heikki Krogerus From: Heikki Krogerus This implements the remaining .graph_* callbacks in the fwnode operations vector 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 "port0", "port1", ...) 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 since RFC v3: - Simplified software_node_get_next_endpoint() a little - Squared away references in software_node_get_next_endpoint() and swnode_graph_find_next_port(), since they were affected by the change to the earlier patch that had *get_next_child() also put the previous reference. - Dropped Andy's R-b, since the code changed. changes in RFC v3: - removed software_node_device_is_available - moved the change to software_node_get_next_child to a separate patch - switched to use fwnode_handle_put() in graph_get_next_endpoint() instead of software_node_put() changes in RFC v2: - added software_node_device_is_available - altered software_node_get_next_child to get references - altered software_node_get_next_endpoint to release references to ports and avoid passing invalid combinations of swnodes to software_node_get_next_child - altered swnode_graph_find_next_port to release port rather than old 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 9bd0bb77ad5b..0c7a8d6b9ea8 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 + 4, 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 Mon Nov 30 13:31:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335397 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.8 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 341CDC83028 for ; Mon, 30 Nov 2020 13:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3E46207BC for ; Mon, 30 Nov 2020 13:34:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HZf90MOp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbgK3NdU (ORCPT ); Mon, 30 Nov 2020 08:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgK3NdS (ORCPT ); Mon, 30 Nov 2020 08:33:18 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C11C061A48; Mon, 30 Nov 2020 05:32:05 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id a3so25182137wmb.5; Mon, 30 Nov 2020 05:32: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=Lrl33MwSXvMl0DHbqDMcSOWgFCmI1fsujcf0HrXSVMw=; b=HZf90MOpm4UrGQruq1FslBdjyHHJXBUpQs/+ByhkIk7fFQ6nnsiPwK5sjNVmxBNsPl GSSMpIEP1xzOtFmJA1UqlE31YHI1WyGGIOAsNq+fdUJVto3fIYNm4DujPVSOZ1nPD6wu c2CORb81pqdoXCYkd22uUWvRNQn9HMZV93W+RPpND0omHzAAUmuUUWBBV5keMl6mz1rU St+OnX6NSbau/bQr/PqRbQucbqtaD4ZserNkN05zLm1JY+DlS2WcWyi9VbZvvSwRaYQ9 yviTBPAFKTKsQW2Em2dzkE+mBF7OQQ23E8bV2tV7hT6zedqk/JMidKFLYONdoBopJQhR b8Vw== 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=Lrl33MwSXvMl0DHbqDMcSOWgFCmI1fsujcf0HrXSVMw=; b=fZELRtQ7ycX8OzAskPE63P+7kB0/mLeC1bE1AtFPVpfXdCbbceGfBKGxKfZokqmdIG MWwtocyH/0KAGmdMYXpy3+j8CqI7gU4MXShtUZ3pAPwauwJp4orzIVkjlZgfb0yh9Dcw x6MiuiHVUaqPzFpUucJ2T323OfCBSUEioAe1Vq9g2IT0bwSOUNvIMDMoDDEjHvNkHfi1 l16tZI4hIcicZmSRlHBstotwQ5li6cC3lC2UF2VfAr17vw+9B+TPw5pBmfyBk6XD89Kv BSNOU3yEPVXpjoHqFu9OboIDwjfJX1bfzPCTR+5OifuDRDNtVOh60tptHv1H4RslEPwI Rreg== X-Gm-Message-State: AOAM530ceWnww04AIzTD1hPu80dwaREQBf2I0JSbeYg3VTUuXXDJo/o2 NJemfFlXKPgRNQL5EDYAjGIVFlY22swvXrdi X-Google-Smtp-Source: ABdhPJzCENcFwsD92T2J5i7GBfndY1f6FvmXomxK1QDwSugBH+f6xf6WvbLaWfVDIDSX5bobRKn1nA== X-Received: by 2002:a1c:43c6:: with SMTP id q189mr10089468wma.7.1606743124434; Mon, 30 Nov 2020 05:32:04 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:03 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 08/18] lib/test_printf.c: Use helper function to unwind array of software_nodes Date: Mon, 30 Nov 2020 13:31:19 +0000 Message-Id: <20201130133129.1024662-9-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes since RFC v3: Changed the called function name - didn't drop the tags since it's such a trivial change, hope that's alright! 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 Mon Nov 30 13:31:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334909 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.8 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 20FB8C8300F for ; Mon, 30 Nov 2020 13:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2C1420870 for ; Mon, 30 Nov 2020 13:34:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GqMT/RMn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgK3NdV (ORCPT ); Mon, 30 Nov 2020 08:33:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbgK3NdT (ORCPT ); Mon, 30 Nov 2020 08:33:19 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76FBFC061A49; Mon, 30 Nov 2020 05:32:07 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id h21so25172414wmb.2; Mon, 30 Nov 2020 05:32: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=tkjtpuVB3caYnMIACCsSyZ57OV1NCqyYvqb38eMikT8=; b=GqMT/RMnWZAbeKEBXyR2jAXpmfIZnGU+oC+bb63+ape3x2Vh8p3/6MqOZ3mNCT0vAq gf5dU+aXbnyaLa1e14gT6Wj2RfJXrDqnASeRpyKPxc3+PENIHlM2wzjdan05XOOqDFkS F+liFzChojXT+rwa30YFUY0qPOABajn9ep6aN8A77rTe77QxNF9/rYGqFtTP4vMQmNve SQXEROCwzHvMTgEUrFi3gs55lGMHXEbBKtmu2cTLUN10R119VDiMkRHqFwmNd0OxZEN2 uMgBeuy8aUqw+60XQGp8kof+NLaSgGfsgWeheQ7Kj8vtl78TrJxY4ysVAu8HeSuGExcu GCWA== 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=tkjtpuVB3caYnMIACCsSyZ57OV1NCqyYvqb38eMikT8=; b=DjLtIeDV1RMftNYMsY0Nq8p2nonTlNOfG+3V7qQbHdMnCVuGSTCt5/spVSqTxkuC0m Zbf5fMpLQxN0oPlyx5vn9uUPpw7FEs4+x5xtPd28VAGsoz8jXtf+sry+EgQ5h2DBLFHp 2wuUhpxZzUf/Ovys7SbpkWcLCmiojdhWjPiaFSQJ0j9ZmhEKthKjaLLsL37ppqQYPgSb aUkA37hT2Oe3L0MpHWN9jHCbYEOK+ADk4bHqmH8Iy301CBGz4DX8bC36oKTKByt/u4hy UXOiryN39yR5JqG3QkD++bRO7liNos6w6ZO6A9jb1x9lQIw8BfQmodIuDRXtVv1OyN7N sNIA== X-Gm-Message-State: AOAM532pjcB6IUgtsobzQv60hKVWt649zmhOctFBEfTE/tZGQKAeplPm LuxsXu2j95WaWxz6SB/+Jf0JdUbOXNzHbBN5 X-Google-Smtp-Source: ABdhPJz1vJSOOkD6d9W1EvlioA+pIqkPYCN2O5X8bSU4tLQTitlvde+GyrVb8QOnLlSlqBjuYGRRfA== X-Received: by 2002:a1c:9901:: with SMTP id b1mr23284287wme.18.1606743125982; Mon, 30 Nov 2020 05:32:05 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:05 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com, Laurent Pinchart Subject: [PATCH 09/18] ipu3-cio2: Add T: entry to MAINTAINERS Date: Mon, 30 Nov 2020 13:31:20 +0000 Message-Id: <20201130133129.1024662-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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: Andy Shevchenko Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes since RFC v3: - None MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index e3a828249c8c..9702b886d6a4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8930,6 +8930,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 Mon Nov 30 13:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 335395 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.8 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 74F87C83035 for ; Mon, 30 Nov 2020 13:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 132AC2085B for ; Mon, 30 Nov 2020 13:34:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ChBEr66A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbgK3NeJ (ORCPT ); Mon, 30 Nov 2020 08:34:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbgK3NdT (ORCPT ); Mon, 30 Nov 2020 08:33:19 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E523C061A4A; Mon, 30 Nov 2020 05:32:09 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id p8so16244124wrx.5; Mon, 30 Nov 2020 05:32:08 -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=lLPC5gReMpBQQOjOEOK+BC7l1m2aD+CFv1l1upZuyWU=; b=ChBEr66AN5CJJiiJQBZ6+iTU5ba9fDPZ4wh6Y2LJroWiyvvs8jWWsSfm0nVsNTFrmm iIQSQSR6mkP3DSzhsZPm1Trv4qs4G2OokUvsbt28cJozO1//Fg274H2TFE5azshO7AF9 MPuBmPPrPCyacfwX/hsbmd4RU+OaWnroJgJGw0gEOBGY2ojipKSGhoi4fAlyyv6FXlCv JhNI+HHHoE5fiBND0/neF5o+s5b5/JL2G/oz5DlVFyxRpwTDZV6sdgREBOazot2Tcrjw 4oRRtTheATA05iC4gSyDYzEu/PGLZnT5YX7leawx/crhZQDDzywkqwyxdxiFcNUvG2up aItQ== 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=lLPC5gReMpBQQOjOEOK+BC7l1m2aD+CFv1l1upZuyWU=; b=pxk2LtzwHt1rfUHyi4TZjzpXzHA1r45ZZ8TrmClBq5MRrfpwtVeLCnJKoxUzVg2lKF mutHv/9ZRwbfPqAIlrA6OZJPf7eU4Xej/+D7KDD0nDhCv1Yc2nJUucpM8YbcyCL14Y9+ kSwzpyEBC9YEYc63zCn/8k23Ql2Qi/fLZ6AychxFStAUVyTLFq/0KXVpqBUY4EIy7WEm 5eSdNroW5v7ndf3YvJ+N1bnKNJv0Dg75R+9scf9l5pdq16YoU/7dktPnl0YgJDub2Y2/ 20pPLtvyK7BBNd/1O9J9Gg7+zkbArt948eNcsFsdwF43+D64Fi2iFbptnK1wmQph6jHs F9/w== X-Gm-Message-State: AOAM531r/F1dIhZwkOO1H8sgfyiGVQfMxvrOaGkzeX/AzXrOOxNKZxAW hffdz41yWm+rxgWXgHqF5PTmARIP6Ai6dYEt X-Google-Smtp-Source: ABdhPJwdHT47DB4kBktF0O94g86AmqcC/kfAYNDEByp+i5WkpdWbz4M15u6JP6DBwO3wwJQKJfZhQw== X-Received: by 2002:a5d:4585:: with SMTP id p5mr28223911wrq.65.1606743127500; Mon, 30 Nov 2020 05:32:07 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:06 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com, Laurent Pinchart Subject: [PATCH 10/18] ipu3-cio2: Rename ipu3-cio2.c to allow module to be built from multiple source files retaining ipu3-cio2 name Date: Mon, 30 Nov 2020 13:31:21 +0000 Message-Id: <20201130133129.1024662-11-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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: Andy Shevchenko Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes since RFC v3: - 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 Mon Nov 30 13:31:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334911 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.8 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,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 31E3AC83014 for ; Mon, 30 Nov 2020 13:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA611207BC for ; Mon, 30 Nov 2020 13:34:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U5BTjckr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbgK3Nda (ORCPT ); Mon, 30 Nov 2020 08:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbgK3NdZ (ORCPT ); Mon, 30 Nov 2020 08:33:25 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89174C061A4B; Mon, 30 Nov 2020 05:32:10 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id d3so15384325wmb.4; Mon, 30 Nov 2020 05:32:10 -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=PU5pzfp9qjZchwd6gQsD9rYDZy2eDuXuRH5bJdGJC0I=; b=U5BTjckr0oVrRYN6a8BJ119QQdABZbwQdy24f0+UzrNFCi+R7C4G/6NODwrPu7MDtt KCpEwMGcMNV2PKLkKA7CVVtBqi46SBHHbCRInZs0SkyQVs1WJMFqAQ5u59viPRCOgY4F kWa8w2arggByNI+erKsz0V+8Dh4+gu2dBBAB2uvMHbCTlU5m9tSzdRnhIubV1HBjM4Jq w7bQ6C2zE0Jk9x/Z8eRcGA2s4w2jbViGjyajCUdD2mS3RwnOjywUh6AxkS7woGqkZ46x GzDPLz1HlQZcKrLMmqXONjniAZtdaMu1RkXvngFhrZb29ZKb66JpdC4szonBwTEkRkzi wCeQ== 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=PU5pzfp9qjZchwd6gQsD9rYDZy2eDuXuRH5bJdGJC0I=; b=Ilr3Ag7HJr30sPWiURNe813MbHY2IlFWXMOMvh+xpgARj2xmCOnyQy02ikIjSKlf5Y 4A38VmnTRMqPHQaRqw3LBksQ54GnSfwhrJBBxUnIJL8HA9lmyVGW1m/DmnDxysm7bDQ0 Pj7ELVvMePlAe5E1SMXYfrcSkmr4fsligYqqHIRg4BkiBAIpzAhgdOR0XKkpXVsK0zRY 9LzRrKFPu45Z/QcJ0p90EVwDMJ7k3DpSr830g6iLsG2byRJUXYJMCD2CkXC7FnmaKOpP 2z6kA3XQBWIe4BJ6IOzxphI00zEaoeQkMCHJMx9hxPeEWwJ/0G5H5EkxzeMcFHErWXgl ZynA== X-Gm-Message-State: AOAM532gMQivEkY4rbMDXEu7S9aPVO5pUEkV1pcJ7WvMUqfotf+0PcSZ 27a0wMTixu0ybSSNFw1w2MuGZRtluGrmeCyB X-Google-Smtp-Source: ABdhPJyWcNS8XvtotcTFst6kuSUA2Ai5YGD+Pmneu3wpVLru3nUAkbKboDh9puEegNK+LTUazenVCg== X-Received: by 2002:a1c:4d13:: with SMTP id o19mr23183796wmh.58.1606743128982; Mon, 30 Nov 2020 05:32:08 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:08 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 11/18] media: v4l2-core: v4l2-async: Check possible match in match_fwnode based on sd->fwnode->secondary Date: Mon, 30 Nov 2020 13:31:22 +0000 Message-Id: <20201130133129.1024662-12-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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. Signed-off-by: Daniel Scally --- Changes since RFC v3: - 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..6486dbde784f 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 Mon Nov 30 13:31:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334912 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.8 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 DFA73C83013 for ; Mon, 30 Nov 2020 13:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A073020727 for ; Mon, 30 Nov 2020 13:34:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pth4rsTA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726950AbgK3Nd3 (ORCPT ); Mon, 30 Nov 2020 08:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbgK3Nd0 (ORCPT ); Mon, 30 Nov 2020 08:33:26 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDD8C061A4C; Mon, 30 Nov 2020 05:32:12 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id a3so25182525wmb.5; Mon, 30 Nov 2020 05:32:12 -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=1qZxQUVXboQ5crtln8dmuzp3bJm0oO37ggxavzFk5EY=; b=pth4rsTAOYyO3nOYNkmd0bEgCSufvk4P5pfvzoPTqAB7P226N5XLUiQe2Gvz2DqYlD SerdQB4+DhYCZbxujz67ARtSE7l6TfTnonxQefIF5anJ0rk0P6l6EgpjxnKLIUDSGSz1 xkC0wi9gVvz2xC8HVZnQq2dQmfS5y56BDFSDlwgNDBe9lL+5lXtRz7Hut6kToiK611TB NunVEkcje6I/kmHsL6Lh1lRc5S9MiDNI7baEbiYvyp7/Bb28IVAn9Rc+Uo3jMR20MDas wKqhZQWKmsYRk/F1ZFtD4DFMApjMiRJko2/FBs30BeardCq/tNPuoO441MuMSuNEUyrs Ms2Q== 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=1qZxQUVXboQ5crtln8dmuzp3bJm0oO37ggxavzFk5EY=; b=JypXlso3WB/BYY/cnRYUZCLBCHX45AHQ/Ol6IzdzLMbR6rQGMFASGNNNE/Qci7tJTb xr9I3HWEZnrbnInars/v0P289FCxOgVXt4z0xO00IlB5Eh/B+e1vSSOjmFbZeZ4emVaS wWzD3EWBfrqc2O4cEQhtG6c9dUBYNVaOGlpr03iJygoXaizqKgfIGVNqiXe891MWTRuq lFQrBAFLSCzIItm3yXGOpXHI1qtG8/TjStJBhDJ3wFrVc8ClG29zNbkFyvga5x5Bkc8A Jh2f0dB3hczuXtDP1fSZhZfkir7YKbRtAHd6uvkyK5O6Ek71AA5BeWUxVJuJzHAkTeBg tp3w== X-Gm-Message-State: AOAM530DgLIsQNBjxRP30FxyD1P9puPQelofk3nay8oeGXd86xFNlG26 wEJx67YptsFeD56lLdcVRGMfdT9tuU+1Or5v X-Google-Smtp-Source: ABdhPJxtLZvNBS/munaHOwK41hIYsQV7c/T+h5/DalrVRqJdU9cHqO1a9xMnQXZQoTWmdtn6AzVBXg== X-Received: by 2002:a7b:c0d7:: with SMTP id s23mr23333228wmh.54.1606743130456; Mon, 30 Nov 2020 05:32:10 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:09 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 12/18] acpi: Add acpi_dev_get_next_match_dev() and macro to iterate through acpi_devices matching a given _HID Date: Mon, 30 Nov 2020 13:31:23 +0000 Message-Id: <20201130133129.1024662-13-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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. Suggested-by: Andy Shevchenko Signed-off-by: Daniel Scally Reviewed-by: Andy Shevchenko --- Changes since RFC v3: - Patch introduced 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 Mon Nov 30 13:31:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334908 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.8 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 2B730C83026 for ; Mon, 30 Nov 2020 13:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C211420855 for ; Mon, 30 Nov 2020 13:34:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q4yKKY0b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727178AbgK3Ndy (ORCPT ); Mon, 30 Nov 2020 08:33:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgK3NdV (ORCPT ); Mon, 30 Nov 2020 08:33:21 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0EAC061A4F; Mon, 30 Nov 2020 05:32:14 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id x22so18477112wmc.5; Mon, 30 Nov 2020 05:32:13 -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=rkRq171/EbhRrWzA9o1up4NODhQMUK0ZntCVybIjLcA=; b=Q4yKKY0bMW/qXTwUPcZS1H3nXE/o9694YGto0ZqiTaXFOHwzeyT+hly2Gslw6CGSG0 4XP5zn+SRkZXV4vVCFdZVv2q8g2XMj16Dlwo6mczblN67lrVrc/BUvxHGGS39KIPq13g Rg6SSKJYgTdPImBHQfbtffIPzCqXpKYuRJSPmvWwyIQMn7Nz7yGuKZu5J4GNOpMw2+dm 7S0VMEOKxt+wwREw4maVruKt6/tm5NcRIVu02XWO6Tmt3zoQ7jUS8/qGjvUFT5nlwzyq o6KMVy/9IKXXjiDhjGVtLzywKk8jYuOfq5AgKj27pBkPVj+QfNR7QTLTLko4wqd+fwTk EG2A== 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=rkRq171/EbhRrWzA9o1up4NODhQMUK0ZntCVybIjLcA=; b=TlOM2mNQ4SiWrURw035MnAW3hKLUnWaWtfaIP5gOjaxHERMK8ZsIq64Anlc3fVYc8G joWt+Pw+X0Zuusgb2aczmRKmL/7asBEvA8T1b9dRcoXU02HaE3tnjHweSs7GKLrDxZFY hfHCVEMJbrNQ1nIuRhFWmZfKmr8g81K5nycdbgn8Umz8zerLyybp5zn4/mkrk+qxO0FF pn8FxUCdoDqZqbs1LHbURHFAn9nnBEd2cEw1/uyA0+KHcZ/ANmrLUh1Eo5k2BER2eC69 H6EzDyM7OHyGjw2+ypQIieDEX/hEQW5Px9NnfHaMd0RRgk5AV/GpbP+Jm3gX03+wbLU9 YLJw== X-Gm-Message-State: AOAM533v2ZLxv6ZJTOg9hqBK9cMVC2LEQSrY9VK6ADRdXgdT9u3cIdYL vRVmnYedIC1CG90DzQO3KWd1QuKsz6CrbH5L X-Google-Smtp-Source: ABdhPJzPmRqy1SOVGB1510Z+u/UmLBQCc6UxCb0Na8Tvfr1paiJ2azTl1in4riIXMqk4aUYhk2k3QQ== X-Received: by 2002:a7b:cf08:: with SMTP id l8mr3361049wmg.189.1606743132058; Mon, 30 Nov 2020 05:32:12 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:11 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 13/18] ipu3-cio2: Add functionality allowing software_node connections to sensors on platforms designed for Windows Date: Mon, 30 Nov 2020 13:31:24 +0000 Message-Id: <20201130133129.1024662-14-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 --- Changes since RFC v3: - Removed almost all global variables, dynamically allocated the cio2_bridge structure, plus a bunch of associated changes like - Added a new function to ipu3-cio2-main.c to check for an existing fwnode_graph before calling cio2_bridge_init() - Prefixed cio2_bridge_ to any variables and functions that lacked it - Assigned the new fwnode directly to the sensor's ACPI device fwnode as secondary. This removes the requirement to delay until the I2C devices are instantiated before ipu3-cio2 can probe, but it has a side effect, which is that those devices then grab a ref to the new software_node. This effectively prevents us from unloading the driver, because we can't free the memory that they live in whilst the device holds a reference to them. The work around at the moment is to _not_ unregister the software_nodes when ipu3-cio2 is unloaded; this becomes a one-time 'patch', that is simply skipped if the module is reloaded. - Moved the sensor's SSDB struct to be a member of cio2_sensor - Replaced ints with unsigned ints where appropriate - Iterated over all ACPI devices of a matching _HID rather than just the first to ensure we handle a device with multiple sensors of the same model. MAINTAINERS | 1 + drivers/media/pci/intel/ipu3/Kconfig | 18 ++ drivers/media/pci/intel/ipu3/Makefile | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 260 ++++++++++++++++++ drivers/media/pci/intel/ipu3/cio2-bridge.h | 108 ++++++++ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 27 ++ drivers/media/pci/intel/ipu3/ipu3-cio2.h | 6 + 7 files changed, 421 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 9702b886d6a4..188559a0a610 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8927,6 +8927,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..2b3350d042be 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..fd3f8ba07274 --- /dev/null +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Dan Scally */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cio2-bridge.h" + +/* + * Extend this array with ACPI Hardware ID's of devices known to be working. + * Do not add a HID for a sensor that is not actually supported. + */ +static const char * const cio2_supported_devices[] = { + "INT33BE", + "OVTI2680", +}; + +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) +{ + strcpy(sensor->prop_names.clock_frequency, "clock-frequency"); + strcpy(sensor->prop_names.rotation, "rotation"); + strcpy(sensor->prop_names.bus_type, "bus-type"); + strcpy(sensor->prop_names.data_lanes, "data-lanes"); + strcpy(sensor->prop_names.remote_endpoint, "remote-endpoint"); +} + +static void cio2_bridge_create_fwnode_properties(struct cio2_sensor *sensor) +{ + unsigned int i; + + cio2_bridge_init_property_names(sensor); + + for (i = 0; i < 4; i++) + sensor->data_lanes[i] = i + 1; + + /* + * Can't use PROPERTY_ENTRY_REF because it creates a new variable to + * point to, which doesn't survive the function. + */ + sensor->local_ref[0] = (struct software_node_ref_args){ + .node = &sensor->swnodes[SWNODE_CIO2_ENDPOINT] + }; + sensor->remote_ref[0] = (struct software_node_ref_args){ + .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, 5); + 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); + + 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, 6, "port%u", sensor->ssdb.link); + strcpy(sensor->node_names.port, "port0"); + strcpy(sensor->node_names.endpoint, "endpoint0"); +} + +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 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_devices); i++) { + const char *this_device = cio2_supported_devices[i]; + + for_each_acpi_dev_match(adev, this_device, NULL, -1) { + if (!adev || !(adev->status.present && adev->status.enabled)) + continue; + + sensor = &bridge->sensors[bridge->n_sensors]; + sensor->adev = adev; + strscpy(sensor->name, this_device, 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); + 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(&bridge->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 = (const struct software_node){ bridge->cio2_node_name }; + bridge->cio2 = pci_dev_get(cio2); + + ret = software_node_register(&bridge->cio2_hid_node); + if (ret < 0) { + dev_err(dev, "Failed to register the CIO2 HID node\n"); + goto err_put_cio2; + } + + ret = cio2_bridge_connect_sensors(bridge); + 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_put_cio2: + pci_dev_put(bridge->cio2); + + 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..96f5c8a12be0 --- /dev/null +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h @@ -0,0 +1,108 @@ +/* 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 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; + u8 sku; + u8 guid_csi2[16]; + u8 devfunction; + u8 bus; + u32 dphylinkenfuses; + u32 clockdiv; + u8 link; + u8 lanes; + u32 csiparams[10]; + u32 maxlanespeed; + u8 sensorcalibfileidx; + u8 sensorcalibfileidxInMBZ[3]; + u8 romtype; + u8 vcmtype; + u8 platforminfo; + 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]; +}; + +struct cio2_node_names { + char port[6]; + char endpoint[10]; + char remote_port[6]; +}; + +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[4]; + 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 { + struct pci_dev *cio2; + 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..0d69b593e9f0 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c @@ -1702,6 +1702,22 @@ 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, @@ -1715,6 +1731,17 @@ 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(dev_fwnode(&pci_dev->dev))) { + 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 From patchwork Mon Nov 30 13:31:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 334907 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.8 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,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 0F323C8302F for ; Mon, 30 Nov 2020 13:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A831320855 for ; Mon, 30 Nov 2020 13:34:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f0hTX38W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgK3NdU (ORCPT ); Mon, 30 Nov 2020 08:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgK3NdS (ORCPT ); Mon, 30 Nov 2020 08:33:18 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1539CC061A51; Mon, 30 Nov 2020 05:32:16 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id r3so16246791wrt.2; Mon, 30 Nov 2020 05:32:16 -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=g3BMXw9JzXtFm16YDoDU8hR3/fKFvazRWYpnvqcHgAY=; b=f0hTX38WWoYFOqduIv8btPWQeeYXnpvQT0AKV2DDZ116iEm5JP+YpIbA3czDOvy1oI obkFPRnUjDfiJaPS9g4M7+yHNIeMXc6tWNwgTi/ZCp/2wvvVoavHx5mJ3+T+YhlVDH4Y UlWwoPadkMAF/1W74cggIXpoD8Rx6+r1IG0mm0NLiRssof/Oo2HjpJLpfJt36TLWGCkl uvQcBwzlh794D+3V/6d4aOGSKMFglZbKF2hCdd8CJElgla5M2GilkvV6sSwXqpW/MAL8 F9sqikgb2+/DBlTINJ+Zpb0DiEHAecd+4i+A5U3QiFYX7LloHZYnR6VWHLpKkhasrEkY yYSQ== 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=g3BMXw9JzXtFm16YDoDU8hR3/fKFvazRWYpnvqcHgAY=; b=T/fL5sa8bTL1QNUlynW360oRyFWrk2BBmksnygFm4Rqpi4khfZnDg5SeAU2xzma3RR njkfpoSFmujQYz/f/5iOGwHuZkZzOUh/jXE0UNckdoqlTc7ZTFgC0Is1net1FYj+G/Iv r59HEnIb+sTvuC6NsHJmcRJOX+bwfi9oZzx/puwvO4o4ohnlHSAHETCFi5tclvSk6+gu 6DAQ6HukHCWT9QC2/XzdfurmdHBEsQSyQ6onzCkgrTkgwSxTjov+Lc0SeLhahWUCjdYH +UOA19D7ly09VKrv649VMuo6U7Y9dt/O9KABozPfef6h5fNrMX3XoQbCLFOeEA8VrXnh 9jDQ== X-Gm-Message-State: AOAM531c9/rs7WGkW1fuONtjh3Pc4BrdvlW5NED3/E0vWdGG6QH/vJw7 3CPS7qeGM/TVf1gDpnjDXGzctqmh9Ik9A/5G X-Google-Smtp-Source: ABdhPJzDCcxaoTO342dCdUscQv15sIxKHbckb9UWSMvt9SP2Hs4Rezs8wWCAwD8sNCiCr+Mm4eFlHA== X-Received: by 2002:adf:ecc9:: with SMTP id s9mr28663695wro.246.1606743133595; Mon, 30 Nov 2020 05:32:13 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:12 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 14/18] acpi: utils: Add function to fetch dependent acpi_devices Date: Mon, 30 Nov 2020 13:31:25 +0000 Message-Id: <20201130133129.1024662-15-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org ACPI devices declare themselves dependent on other devices via the _DEP buffer. Fetching the dependee from dependent is a matter of parsing _DEP, but currently there's no method to fetch dependent from dependee. Add one, so we can parse sensors dependent on a PMIC from the PMIC's acpi_driver. Signed-off-by: Daniel Scally --- Changes since RFC v3: - Patch introduced drivers/acpi/utils.c | 68 +++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 2 ++ 2 files changed, 70 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index c177165c8db2..7099529121db 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -807,6 +807,52 @@ static int acpi_dev_match_cb(struct device *dev, const void *data) return hrv == match->hrv; } +static int acpi_dev_match_by_dep(struct device *dev, const void *data) +{ + struct acpi_device *adev = to_acpi_device(dev); + const struct acpi_device *dependee = data; + struct acpi_handle_list dep_handles; + struct acpi_device *candidate; + acpi_handle handle; + acpi_status status; + unsigned int i; + int ret; + + handle = adev->handle; + + if (!acpi_has_method(handle, "_DEP")) + return 0; + + status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_handles); + if (ACPI_FAILURE(status)) + return 0; + + for (i = 0; i < dep_handles.count; i++) { + struct acpi_device_info *info; + + status = acpi_get_object_info(dep_handles.handles[i], &info); + if (ACPI_FAILURE(status)) + continue; + + if (info->valid & ACPI_VALID_HID) { + ret = acpi_bus_get_device(dep_handles.handles[i], &candidate); + if (ret || !candidate) { + kfree(info); + continue; + } + + if (candidate == dependee) { + acpi_dev_put(candidate); + kfree(info); + return 1; + } + + kfree(info); + } + } + return 0; +} + /** * acpi_dev_present - Detect that a given ACPI device is present * @hid: Hardware ID of the device. @@ -842,6 +888,28 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) } EXPORT_SYMBOL(acpi_dev_present); +/** + * acpi_dev_get_next_dep_dev - Return next ACPI device dependent on input dev + * @adev: Pointer to the dependee device + * @prev: Pointer to the previous dependent device (or NULL for first match) + * + * Return the next ACPI device which declares itself dependent on @adev in + * the _DEP buffer. + * + * The caller is responsible to call put_device() on the returned device. + */ +struct acpi_device *acpi_dev_get_next_dep_dev(struct acpi_device *adev, + struct acpi_device *prev) +{ + struct device *start = prev ? &prev->dev : NULL; + struct device *dev; + + dev = bus_find_device(&acpi_bus_type, start, adev, acpi_dev_match_by_dep); + + return dev ? to_acpi_device(dev) : NULL; +} +EXPORT_SYMBOL(acpi_dev_get_next_dep_dev); + /** * 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 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 0a028ba967d3..f5dfeb030b9c 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -688,6 +688,8 @@ 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_dep_dev(struct acpi_device *adev, struct acpi_device *prev); struct acpi_device * acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv); struct acpi_device * From patchwork Mon Nov 30 13:31: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: 334910 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.8 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, 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 731A8C8301D for ; Mon, 30 Nov 2020 13:34:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C062207BC for ; Mon, 30 Nov 2020 13:34:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZboWROXt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbgK3Ndp (ORCPT ); Mon, 30 Nov 2020 08:33:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbgK3Ndn (ORCPT ); Mon, 30 Nov 2020 08:33:43 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF1EC061A52; Mon, 30 Nov 2020 05:32:16 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id d3so15384645wmb.4; Mon, 30 Nov 2020 05:32:16 -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=jx3a1AHoq9drKHNXIr2dchc7sTh/KrOlq0lIEE/z1CM=; b=ZboWROXtaYKvtFfbq1ELckUauK4Mg57diLs3Qv1A6o05u5TDqN1trpGRVnVwmDA2Un SiNshu4YDMyXU4JlSy8q4o+4eu7AlE2Jc2Qmismx9q6nmdOG+zqdjtgKyTGr7YDzUw+b XNeYV398+vuk/rlJOHvGzsCkduBMna71C1rSCws2UBc8YIa28o0+GhwTaLiG6jeZMlk0 pmgZJpKnXt3pwOyYyxnqr9ANWChZ25eJaGAmWhRbyyRGKwR7PN0JZVRz06pRVQc/L4bP zcd96HYbJ6O0aEGKleab0G0W2SjJ8BEL1Fm8Q0JWNQnDH3s875wXNx2vN7RkwDbV+JvN PckQ== 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=jx3a1AHoq9drKHNXIr2dchc7sTh/KrOlq0lIEE/z1CM=; b=jRtJ5bu+jiZl8kpXwGjSHA1fsvWhsg5vgYY8Ku/P+kLSpC4ZCVlvksR82FDZIIaP6W 8mBFf0DttrBVWTKQpinExHhTxR4oD2cKRFHTZejvWjzvi6r2lHE0U73J6VtQBk3oM6bO DmamO1Wgs80lqM55YgCumQVWiuLvJhAg+aOczjbbHlKNum5VSwJ0xlX1zEFS4fgeaXOW jF09eArFpsb+LSuffe7qXQ7bF8tRs6g4c2EK6z1KOuqdCDk/J3xzB18thmFgWsJUZExl 2LSWZJUPcv1oAPn1Gh3498kMIF2+I3U8IHd+hDZppqm3AMY5T0/SpuqqaT4b8D8e5xwp QTpw== X-Gm-Message-State: AOAM5337VrQmSN6Mq1yTebV//2BLXwwwWiRxWkBJzj3e4gfbOFHVBe6S LE5SFuazbDSmalYyMB8gHYK73KS0Awb+FqS/ X-Google-Smtp-Source: ABdhPJx2XYmLEhxwD4GDyLxa/m/rn9eBir8T7DakT9rLA4kl14HeBZiBELU2jlYYE18zHPxm/56vow== X-Received: by 2002:a7b:c00b:: with SMTP id c11mr23965371wmb.175.1606743135351; Mon, 30 Nov 2020 05:32:15 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:14 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 15/18] i2c: i2c-core-acpi: Add i2c_acpi_dev_name() Date: Mon, 30 Nov 2020 13:31:26 +0000 Message-Id: <20201130133129.1024662-16-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some places in the kernel allow users to map resources to a device using device name (for example, gpiod_lookup_table). Currently this involves waiting for the i2c_client to have been registered so we can use dev_name(&client->dev). Adding this function means that we can achieve the same thing without having to wait to the i2c device. Signed-off-by: Daniel Scally --- Changes since RFC v3: - Patch introduced drivers/i2c/i2c-core-acpi.c | 14 ++++++++++++++ include/linux/i2c.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 37c510d9347a..d3a653eac79e 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -497,6 +497,20 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, } EXPORT_SYMBOL_GPL(i2c_acpi_new_device); +/** + * i2c_acpi_dev_name - Construct i2c device name for devs sourced from ACPI + * @adev: ACPI device to construct the name for + * + * Prefixes "i2c-" to the ACPI device name, for use in i2c_dev_set_name() and + * also anywhere else in the kernel that needs to refer to an i2c device by + * name but before they have been instantiated. + */ +char *i2c_acpi_dev_name(struct acpi_device *adev) +{ + return kasprintf(GFP_KERNEL, "i2c-%s", acpi_dev_name(adev)); +} +EXPORT_SYMBOL_GPL(i2c_acpi_dev_name); + #ifdef CONFIG_ACPI_I2C_OPREGION static int acpi_gsb_i2c_read_bytes(struct i2c_client *client, u8 cmd, u8 *data, u8 data_len) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 56622658b215..ab0e505b2ca6 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -995,6 +995,7 @@ bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, u32 i2c_acpi_find_bus_speed(struct device *dev); struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, struct i2c_board_info *info); +char *i2c_acpi_dev_name(struct acpi_device *adev); struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle); #else static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, @@ -1011,6 +1012,10 @@ static inline struct i2c_client *i2c_acpi_new_device(struct device *dev, { return ERR_PTR(-ENODEV); } +static inline char *i2c_acpi_dev_name(struct acpi_device *adev) +{ + return NULL; +} static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) { return NULL; From patchwork Mon Nov 30 13:31: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: 335400 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.8 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,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 97B83C83018 for ; Mon, 30 Nov 2020 13:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D32E207BC for ; Mon, 30 Nov 2020 13:34:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IStKaWOi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727077AbgK3Ndb (ORCPT ); Mon, 30 Nov 2020 08:33:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbgK3Nda (ORCPT ); Mon, 30 Nov 2020 08:33:30 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B1E8C061A53; Mon, 30 Nov 2020 05:32:18 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id u12so16269477wrt.0; Mon, 30 Nov 2020 05:32:18 -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=511mzKiIywlNQYNwh+9h5lxXxDhZYNjRCyGYr9Xu0us=; b=IStKaWOiny1B/u+cgJ2LRmq2JrnYDg/dGle+7gzHXLBwYdMIXZW29V/uLypqm0eTPo qrvitPzpPhRonnvZRF52o95OdAeIlbOP1iSKfS4WXFOQ8Wq5a3Qo+vwJFono4qnqsR2Y eWDJ+gDq0UoZOK6Jh6B/SK3Gk11h69peJz4vbW/ausArC7j8ihoxiYt0rpU8lWWz3kEg 3g4Fb16amSnXdBKSGBqPuKGFRSBO33a5yjbQ7CH+bjICTludUiT8cHDShViWtX+3x/sE u7xrGB8kgvEwDVgYOdeId9xC6/v9nGi5kCFgDI2/w6T8B8Oq7Ij5Bq9LUUWj6gKl38yq nFGw== 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=511mzKiIywlNQYNwh+9h5lxXxDhZYNjRCyGYr9Xu0us=; b=aLyyxQ2JmEgJ6/ry92boHfQrImLxThar5ibNPhKyynqdlgIgtK+rrXBFKSPOApC/93 aIhzsra6+geZRBoJhr4LVtoQYFkMOyZt0MT0DobOwG9aO6x1FVRNUJ2xFOUmeQTrssXn U/dAE4pe5hYsB7UxtdjMlCGlsdrIXyQY9iTHP/ShgT0QGudyKtZon3i6lwFHUCmjkx/p sb25FcUUNgx6ofWMsQ/eFHasKyMPuNG+2iEeFPlnFsX0ChnBCjVziZ/TVoNlg7HgyAvC Txb2HsLNEYMJyYwa+6NbEd2S96Vs0rzd7oKdIUpA+P9i2qjgReZuQRiYX8TvVOM5oVsz XlhQ== X-Gm-Message-State: AOAM532Xci+9ZZj7OSE9XPNpxjf+1ndHmAsrhWe6PW2G1Wd76dS4nD32 4vEaveYHzZ+UlW9aHQ+z+FBi9/aDnmIfzlTc X-Google-Smtp-Source: ABdhPJx4y/GNSZAZsHXT6kjUa2vcBJ/Pkj3oERILRxY3uLrk1+veimpUUUK/NR8/2AY/Mxf8b9Byeg== X-Received: by 2002:adf:d188:: with SMTP id v8mr27895510wrc.167.1606743136993; Mon, 30 Nov 2020 05:32:16 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:16 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com, Dan Scally Subject: [PATCH 16/18] i2c: i2c-core-base: Use the new i2c_acpi_dev_name() in i2c_set_dev_name() Date: Mon, 30 Nov 2020 13:31:27 +0000 Message-Id: <20201130133129.1024662-17-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Dan Scally To make sure the new i2c_acpi_dev_name() always reflects the name of i2c devices sourced from ACPI, use it in i2c_set_dev_name(). Signed-off-by: Dan Scally --- Changes since RFC v3: - Patch introduced drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 573b5da145d1..a6d4ceb01077 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -814,7 +814,7 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, } if (adev) { - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); + dev_set_name(&client->dev, i2c_acpi_dev_name(adev)); return; } From patchwork Mon Nov 30 13:31: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: 335398 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.8 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,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 33BDFC83024 for ; Mon, 30 Nov 2020 13:34:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAA07207BC for ; Mon, 30 Nov 2020 13:34:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KrwSbRpk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbgK3Nd4 (ORCPT ); Mon, 30 Nov 2020 08:33:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgK3Ndz (ORCPT ); Mon, 30 Nov 2020 08:33:55 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDABEC061A54; Mon, 30 Nov 2020 05:32:19 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id l1so16212740wrb.9; Mon, 30 Nov 2020 05:32:19 -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=89ez14xq7f3eSpkmNmdtRshRAe/5L4lRl0ct9tMiZwI=; b=KrwSbRpkuu4BSm67PVspA3L973/nhfUNUj1LnrJbs+oClFQV1BrpYP88f3Tzyy/pWk S5NBRj2mZaoNXTpLnnYfPH2CZwHqnzwC5dKJDBGXb4TU0KmS/aKJ77BBi60vVxoBkE4N 8RpohPYtH2vluyjhc+Czpsk+ut8KuwuqdbRQtvfHmgxhKGWlUoioGMDYIX25ylVdkchX ujLCdCYhd56UKF876AjE7xWErdGerktBRLDrcIicF1Bp5afBX+CIRrMiJBLKbXLMr2vb zkNdXUQzblbe0w7rYpZexs7Nn+MLgLASnrmLhDzDYmZYOHd0eRBoBtddZn0RuBZ627fr hClw== 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=89ez14xq7f3eSpkmNmdtRshRAe/5L4lRl0ct9tMiZwI=; b=P+KNA+iNxTOCERFUWXtkeiZknXY9xtituPGXlRhMA0OUsiw3ROmbQLCmsp/Mud8+ww yOV8+YmL9/2QwEIOtZPA46c3IZcC+klhanUepZY6vIghneOcM+6dhgj9GTJ8yF3bfsi9 zrB6I6mLc8Q3uUAyjdgGbsErMuM1o/6iiF7MTdxFWSpVK9zRtGhHlGjXfnj6+zlmNDor 9CA+SzKmyzxCATYj75vNH2mNVdqXc08iUWX7sSGbGoncPC7K4MZM+KTB2hU/lQz5O1oB Xbwif+FyOAJJSsafXmxpGEKms1TyICVkTwJnZn2xN15xoDKKfsSzLVbxZwf6oDwum04w fuxw== X-Gm-Message-State: AOAM531lL9P8Hj8yVl4eNby1VYZIvAJDm2oQSJK2od5kRpWi2DRsACPj efC+DhVgsoK53HEkKSVzhED/eUoqm8eij7ba X-Google-Smtp-Source: ABdhPJzBAM0ozhvZLf9maCK2gtBJuXaIs+4FGjkWJeME4XV8dzgsQK5BHE8ux3fhzPVaBH11vNi02Q== X-Received: by 2002:adf:c452:: with SMTP id a18mr28980463wrg.189.1606743138401; Mon, 30 Nov 2020 05:32:18 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:17 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com Subject: [PATCH 17/18] gpio: gpiolib-acpi: Export acpi_get_gpiod() Date: Mon, 30 Nov 2020 13:31:28 +0000 Message-Id: <20201130133129.1024662-18-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org I need to be able to translate GPIO resources in an acpi_device's _CRS into gpio_descs. Those are represented in _CRS as a pathname to a GPIO device plus the pin's index number: this function is perfect for that purpose. Signed-off-by: Daniel Scally --- Changes since RFC v3: - Patch introduced drivers/gpio/gpiolib-acpi.c | 3 ++- include/linux/acpi.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 834a12f3219e..cfadbc263475 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -111,7 +111,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) * controller does not have GPIO chip registered at the moment. This is to * support probe deferral. */ -static struct gpio_desc *acpi_get_gpiod(char *path, int pin) +struct gpio_desc *acpi_get_gpiod(char *path, int pin) { struct gpio_chip *chip; acpi_handle handle; @@ -127,6 +127,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin) return gpiochip_get_desc(chip, pin); } +EXPORT_SYMBOL_GPL(acpi_get_gpiod); static irqreturn_t acpi_gpio_irq_handler(int irq, void *data) { diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 39263c6b52e1..737115a93138 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1066,6 +1066,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index); +struct gpio_desc *acpi_get_gpiod(char *path, int pin); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio) @@ -1076,6 +1077,10 @@ static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { return -ENXIO; } +struct gpio_desc *acpi_get_gpiod(char *path, int pin) +{ + return NULL; +} #endif /* Device properties */ From patchwork Mon Nov 30 13:31: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: 335399 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.8 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 BC52BC8301C for ; Mon, 30 Nov 2020 13:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61A4E20727 for ; Mon, 30 Nov 2020 13:34:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aZl6ANtB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgK3Ndf (ORCPT ); Mon, 30 Nov 2020 08:33:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgK3Nde (ORCPT ); Mon, 30 Nov 2020 08:33:34 -0500 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 09DF6C061A55; Mon, 30 Nov 2020 05:32:22 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id g25so5676165wmh.1; Mon, 30 Nov 2020 05:32:21 -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=rV7CHkG5wAxwFl+AqTH2VVVjZLQmG8MfJPPhuV61gVM=; b=aZl6ANtBKeuutB812ayQ+cysTTYPZgvfhP/d/ZuYsP7oS4xXjwSYx5C+fW8WUFD671 DYseBQlRDzFNB5/x0VGDN4OfgzU5ngnqhBn3JDBnRpRNxY4qpJT6J0dgNAnRpQW5JDoe Ib3Cg4rYXr3CQIojR0hv7TGNPiWbyu07Ys6LnGc/CE3l7Z8apwmznuDZHPlhURBTCJv0 dLT3T4cWcs8cKwOc1hx39qd94pjpCnHzd2FoG6icedVkLUQGPn5yhLCWrk6DJr+r8/F9 CUgmA3bRGWc4TIOHCMVssjkHNBub7Ib6WFBj5yqGta0ZUirBVATaajlVsIkLUix7EgoN BCjg== 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=rV7CHkG5wAxwFl+AqTH2VVVjZLQmG8MfJPPhuV61gVM=; b=m4fRPvkTheDVjH+7zRNQHZumnuIeqyJDZDnrCeBi/DwZK18YueI7jNNPM+Irp7Lhm9 xvmX0KkwFdf2wYc2h7wk9YlvaFjS7PT9GHXkjiW+ySozA6Y6aalAp35krK7xkumtcjk+ z7pAVUGzUlHyq5nYiHCYUG6AHOhrfXDN3j1+svWLdpgiNbgdDUHoPBCsVjj7fOmgpdXq SjUae2JystYle09w5hea5o8WWHxvFMfpYN6fJW8BgJblTeiZOdmugPBB2foeCluvy4o4 CboGe6lguWOENsUshIPN7lgfFxE13TUuMBXlJWlFQuKgwYLV0tDnDDuC9AcEcnSzj/Mt DxMQ== X-Gm-Message-State: AOAM531tIt3M6i0YJnO+4Swtdjwoh7dG0FZ+G0aZS8pu6O/3vcFaUweX nEUG1AF0W/KTKerRhBRURvgZQmUExBj1lwRX X-Google-Smtp-Source: ABdhPJxQyQwiR9uc69AxalIPdALusKCqQS9zU0BH7goMtWjVpybkXYmVbKnAo/XyZm6nkdguyJ5Mzw== X-Received: by 2002:a7b:c24b:: with SMTP id b11mr23247129wmj.109.1606743139970; Mon, 30 Nov 2020 05:32:19 -0800 (PST) Received: from valhalla.home ([2.31.224.80]) by smtp.gmail.com with ESMTPSA id g192sm7452333wme.48.2020.11.30.05.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:32:19 -0800 (PST) From: Daniel Scally To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org Cc: rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.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, linux@rasmusvillemoes.dk, kieran.bingham+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, laurent.pinchart+renesas@ideasonboard.com, jorhand@linux.microsoft.com, kitakar@gmail.com, heikki.krogerus@linux.intel.com, Laurent Pinchart Subject: [PATCH 18/18] ipu3: Add driver for dummy INT3472 ACPI device Date: Mon, 30 Nov 2020 13:31:29 +0000 Message-Id: <20201130133129.1024662-19-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130133129.1024662-1-djrscally@gmail.com> References: <20201130133129.1024662-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org On platforms where ACPI is designed for use with Windows, resources that are intended to be consumed by sensor devices are sometimes in the _CRS of a dummy INT3472 device upon which the sensor depends. This driver binds to the dummy acpi device (which does not represent a physical PMIC) and maps them into GPIO lines and regulators for use by the sensor device instead. Suggested-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes since RFC v3: - Patch introduced This patch contains the bits of this process that we're least sure about. The sensors in scope for this work are called out as dependent (in their DSDT entry's _DEP) on a device with _HID INT3472. These come in at least 2 kinds; those with an I2cSerialBusV2 entry (which we presume therefore are legitimate tps68470 PMICs that need handling by those drivers - work on that in the future). And those without an I2C device. For those without an I2C device they instead have an array of GPIO pins defined in _CRS. So for example, my Lenovo Miix 510's OVTI2680 sensor is dependent on one of the _latter_ kind of INT3472 devices, with this _CRS: Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Name (SBUF, ResourceTemplate () { GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, , ) { // Pin list 0x0079 } GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, , ) { // Pin list 0x007A } GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, , ) { // Pin list 0x008F } }) Return (SBUF) /* \_SB_.PCI0.PMI1._CRS.SBUF */ } and the same device has a _DSM Method, which returns 32-bit ints where the second lowest byte we noticed to match the pin numbers of the GPIO lines: Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method { If ((Arg0 == ToUUID ("79234640-9e10-4fea-a5c1-b5aa8b19756f"))) { If ((Arg2 == One)) { Return (0x03) } If ((Arg2 == 0x02)) { Return (0x01007900) } If ((Arg2 == 0x03)) { Return (0x01007A0C) } If ((Arg2 == 0x04)) { Return (0x01008F01) } } Return (Zero) } We know that at least some of those pins have to be toggled active for the sensor devices to be available in i2c, so the conclusion we came to was that those GPIO entries assigned to the INT3472 device actually represent GPIOs and regulators to be consumed by the sensors themselves. Tsuchiya noticed that the lowest byte in the return values of the _DSM method seemed to represent the type or function of the GPIO line, and we confirmed that by testing on each surface device that GPIO lines where the low byte in the _DSM entry for that pin was 0x0d controlled the privacy LED of the cameras. We're guessing as to the exact meaning of the function byte, but I conclude they're something like this: 0x00 - probably a reset GPIO 0x01 - regulator for the sensor 0x0c - regulator for the sensor 0x0b - regulator again, but for a VCM or EEPROM 0x0d - privacy led (only one we're totally confident of since we can see it happen!) After much internal debate I decided to write this as a standalone acpi_driver. Alternative options we considered: 1. Squash all this into the cio2-bridge code, which I did originally write but decided I didn't like. 2. Extend the existing tps68470 mfd driver...they share an ACPI ID so this kinda makes sense, but ultimately given there is no actual physical tps68470 in the scenario this patch handles I decided I didn't like this either. MAINTAINERS | 7 + drivers/media/pci/intel/ipu3/Kconfig | 14 + drivers/media/pci/intel/ipu3/Makefile | 1 + drivers/media/pci/intel/ipu3/int3472.c | 381 +++++++++++++++++++++++++ drivers/media/pci/intel/ipu3/int3472.h | 96 +++++++ 5 files changed, 499 insertions(+) create mode 100644 drivers/media/pci/intel/ipu3/int3472.c create mode 100644 drivers/media/pci/intel/ipu3/int3472.h diff --git a/MAINTAINERS b/MAINTAINERS index 188559a0a610..d73471f9c2a3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8753,6 +8753,13 @@ L: linux-crypto@vger.kernel.org S: Maintained F: drivers/crypto/inside-secure/ +INT3472 ACPI DEVICE DRIVER +M: Daniel Scally +L: linux-media@vger.kernel.org +S: Maintained +F: drivers/media/pci/intel/ipu3/int3472.c +F: drivers/media/pci/intel/ipu3/int3472.h + INTEGRITY MEASUREMENT ARCHITECTURE (IMA) M: Mimi Zohar M: Dmitry Kasatkin diff --git a/drivers/media/pci/intel/ipu3/Kconfig b/drivers/media/pci/intel/ipu3/Kconfig index 2b3350d042be..9dd3b280f821 100644 --- a/drivers/media/pci/intel/ipu3/Kconfig +++ b/drivers/media/pci/intel/ipu3/Kconfig @@ -34,3 +34,17 @@ config CIO2_BRIDGE - Dell 7285 If in doubt, say N here. + +config INT3472 + tristate "INT3472 Dummy ACPI Device Driver" + depends on VIDEO_IPU3_CIO2 + depends on ACPI && REGULATOR && GPIOLIB + help + This module provides an ACPI driver for INT3472 devices that do not + represent an actual physical tps68470 device. + + Say Y here if your device is a detachable / hybrid laptop that comes + with Windows installed by the OEM. + The module will be called int3472. + + If in doubt, say N here. diff --git a/drivers/media/pci/intel/ipu3/Makefile b/drivers/media/pci/intel/ipu3/Makefile index 933777e6ea8a..2285947b2bd2 100644 --- a/drivers/media/pci/intel/ipu3/Makefile +++ b/drivers/media/pci/intel/ipu3/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VIDEO_IPU3_CIO2) += ipu3-cio2.o +obj-$(CONFIG_INT3472) += int3472.o ipu3-cio2-y += ipu3-cio2-main.o ipu3-cio2-$(CONFIG_CIO2_BRIDGE) += cio2-bridge.o diff --git a/drivers/media/pci/intel/ipu3/int3472.c b/drivers/media/pci/intel/ipu3/int3472.c new file mode 100644 index 000000000000..6b0be75f7f35 --- /dev/null +++ b/drivers/media/pci/intel/ipu3/int3472.c @@ -0,0 +1,381 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Dan Scally */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "int3472.h" + +/* + * The regulators have to have .ops to be valid, but the only ops we actually + * support are .enable and .disable which are handled via .ena_gpiod. Pass an + * empty struct to clear the check without lying about capabilities. + */ +static const struct regulator_ops int3472_gpio_regulator_ops = { 0 }; + +static int int3472_map_gpio_to_sensor(struct int3472_device *int3472, + struct acpi_resource *ares, char *func) +{ + char *path = ares->data.gpio.resource_source.string_ptr; + struct gpiod_lookup table_entry; + struct acpi_device *adev; + acpi_handle handle; + acpi_status status; + int ret; + + /* Make sure we don't overflow, and leave room for a terminator */ + if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) { + dev_warn(&int3472->sensor->dev, "Too many GPIOs mapped\n"); + return -EINVAL; + } + + /* Fetch ACPI handle for the GPIO chip */ + status = acpi_get_handle(NULL, path, &handle); + if (ACPI_FAILURE(status)) + return -EINVAL; + + ret = acpi_bus_get_device(handle, &adev); + if (ret) + return -ENODEV; + + table_entry = (struct gpiod_lookup)GPIO_LOOKUP_IDX(acpi_dev_name(adev), + ares->data.gpio.pin_table[0], + func, 0, GPIO_ACTIVE_HIGH); + + memcpy(&int3472->gpios.table[int3472->n_sensor_gpios], &table_entry, + sizeof(table_entry)); + int3472->n_sensor_gpios++; + + return 0; +} + +static struct int3472_sensor_regulator_map * +int3472_get_sensor_supply_map(struct int3472_device *int3472) +{ + struct int3472_sensor_regulator_map *ret; + union acpi_object *obj; + unsigned int i; + + /* + * Sensor modules seem to be identified by a unique string. We use that + * to make sure we pass the right device and supply names to the new + * regulator's consumer_supplies + */ + obj = acpi_evaluate_dsm_typed(int3472->sensor->handle, + &cio2_sensor_module_guid, 0x00, + 0x01, NULL, ACPI_TYPE_STRING); + + if (!obj) { + dev_err(&int3472->sensor->dev, + "Failed to get sensor module string from _DSM\n"); + return ERR_PTR(-ENODEV); + } + + if (obj->string.type != ACPI_TYPE_STRING) { + dev_err(&int3472->sensor->dev, + "Sensor _DSM returned a non-string value\n"); + ret = ERR_PTR(-EINVAL); + goto out_free_obj; + } + + ret = ERR_PTR(-ENODEV); + for (i = 0; i < ARRAY_SIZE(int3472_sensor_regulator_maps); i++) { + if (!strcmp(int3472_sensor_regulator_maps[i].sensor_module_name, + obj->string.pointer)) { + ret = &int3472_sensor_regulator_maps[i]; + goto out_free_obj; + } + } + +out_free_obj: + ACPI_FREE(obj); + return ret; +} + +static int int3472_register_regulator(struct int3472_device *int3472, + struct acpi_resource *ares) +{ + char *path = ares->data.gpio.resource_source.string_ptr; + struct int3472_sensor_regulator_map *regulator_map; + struct regulator_init_data init_data = { }; + struct int3472_gpio_regulator *regulator; + struct regulator_config cfg = { }; + int ret; + + /* + * We lookup supply names from machine specific tables, based on a + * unique identifier in the sensor's _DSM + */ + regulator_map = int3472_get_sensor_supply_map(int3472); + if (IS_ERR_OR_NULL(regulator_map)) { + dev_err(&int3472->sensor->dev, + "Found no supplies defined for this sensor\n"); + return PTR_ERR(regulator_map); + } + + if (int3472->n_regulators >= regulator_map->n_supplies) { + dev_err(&int3472->sensor->dev, + "All known supplies are already mapped\n"); + return -EINVAL; + } + + init_data.supply_regulator = NULL; + init_data.constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS; + init_data.num_consumer_supplies = 1; + init_data.consumer_supplies = ®ulator_map->supplies[int3472->n_regulators]; + + regulator = kmalloc(sizeof(*regulator), GFP_KERNEL); + if (!regulator) + return -ENOMEM; + + snprintf(regulator->regulator_name, GPIO_REGULATOR_NAME_LENGTH, + "gpio-regulator-%d", int3472->n_regulators); + snprintf(regulator->supply_name, GPIO_REGULATOR_SUPPLY_NAME_LENGTH, + "supply-%d", int3472->n_regulators); + + regulator->rdesc = INT3472_REGULATOR(regulator->regulator_name, + regulator->supply_name, + int3472->n_regulators, + &int3472_gpio_regulator_ops); + + regulator->gpio = acpi_get_gpiod(path, ares->data.gpio.pin_table[0]); + if (IS_ERR(regulator->gpio)) { + ret = PTR_ERR(regulator->gpio); + goto err_free_regulator; + } + + cfg.dev = &int3472->adev->dev; + cfg.init_data = &init_data; + cfg.ena_gpiod = regulator->gpio; + + regulator->rdev = regulator_register(®ulator->rdesc, &cfg); + if (IS_ERR(regulator->rdev)) { + ret = PTR_ERR(regulator->rdev); + goto err_free_gpio; + } + + list_add(®ulator->list, &int3472->regulators); + int3472->n_regulators++; + + return 0; + +err_free_gpio: + gpiod_put(regulator->gpio); +err_free_regulator: + kfree(regulator); + + return ret; +} + +static int int3472_handle_gpio_resources(struct acpi_resource *ares, + void *data) +{ + struct int3472_device *int3472 = data; + union acpi_object *obj; + int ret = 0; + + if (ares->type != ACPI_RESOURCE_TYPE_GPIO || + ares->data.gpio.connection_type != ACPI_RESOURCE_GPIO_TYPE_IO) + return EINVAL; /* Deliberately positive */ + + /* + * n_gpios + 2 because the index of this _DSM function is 1-based and + * the first function is just a count. + */ + obj = acpi_evaluate_dsm_typed(int3472->adev->handle, + &int3472_gpio_guid, 0x00, + int3472->n_gpios + 2, + NULL, ACPI_TYPE_INTEGER); + + if (!obj) { + dev_warn(&int3472->adev->dev, + "No _DSM entry for this GPIO pin\n"); + return ENODEV; + } + + switch (obj->integer.value & 0xff) { /* low byte holds type data */ + case 0x00: /* Purpose unclear, possibly a reset GPIO pin */ + ret = int3472_map_gpio_to_sensor(int3472, ares, "reset"); + if (ret) + dev_warn(&int3472->adev->dev, + "Failed to map reset pin to sensor\n"); + + break; + case 0x01: /* Power regulators (we think) */ + case 0x0c: + ret = int3472_register_regulator(int3472, ares); + if (ret) + dev_warn(&int3472->adev->dev, + "Failed to map regulator to sensor\n"); + + break; + case 0x0b: /* Power regulators, but to a device separate to sensor */ + ret = int3472_register_regulator(int3472, ares); + if (ret) + dev_warn(&int3472->adev->dev, + "Failed to map regulator to sensor\n"); + + break; + case 0x0d: /* Indicator LEDs */ + ret = int3472_map_gpio_to_sensor(int3472, ares, "indicator-led"); + if (ret) + dev_warn(&int3472->adev->dev, + "Failed to map indicator led to sensor\n"); + + break; + default: + /* if we've gotten here, we're not sure what they are yet */ + dev_warn(&int3472->adev->dev, + "GPIO type 0x%llx unknown; the sensor may not work\n", + (obj->integer.value & 0xff)); + ret = EINVAL; + } + + int3472->n_gpios++; + ACPI_FREE(obj); + return abs(ret); +} + +static void int3472_parse_crs(struct int3472_device *int3472) +{ + struct list_head resource_list; + + INIT_LIST_HEAD(&resource_list); + + acpi_dev_get_resources(int3472->adev, &resource_list, + int3472_handle_gpio_resources, int3472); + + acpi_dev_free_resource_list(&resource_list); + gpiod_add_lookup_table(&int3472->gpios); +} + +static int int3472_add(struct acpi_device *adev) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct int3472_device *int3472; + struct int3472_cldb cldb; + union acpi_object *obj; + acpi_status status; + int ret = 0; + + /* + * This driver is only intended to support "dummy" INT3472 devices + * which appear in ACPI designed for Windows. These are distinguishable + * from INT3472 entries representing an actual tps68470 PMIC through + * the presence of a CLDB buffer with a particular value set. + */ + status = acpi_evaluate_object(adev->handle, "CLDB", NULL, &buffer); + if (ACPI_FAILURE(status)) + return -ENODEV; + + obj = buffer.pointer; + if (!obj) { + dev_err(&adev->dev, "ACPI device has no CLDB object\n"); + return -ENODEV; + } + + if (obj->type != ACPI_TYPE_BUFFER) { + dev_err(&adev->dev, "CLDB object is not an ACPI buffer\n"); + ret = -EINVAL; + goto out_free_buff; + } + + if (obj->buffer.length > sizeof(cldb)) { + dev_err(&adev->dev, "The CLDB buffer is too large\n"); + ret = -EINVAL; + goto out_free_buff; + } + + memcpy(&cldb, obj->buffer.pointer, obj->buffer.length); + + /* + * control_logic_type = 1 indicates this is a dummy INT3472 device of + * the kind we're looking for. If any other value then we shouldn't try + * to handle it + */ + if (cldb.control_logic_type != 1) { + ret = -EINVAL; + goto out_free_buff; + } + + /* Space for 4 GPIOs - one more than we've seen so far plus a null */ + int3472 = kzalloc(sizeof(*int3472) + + ((INT3472_MAX_SENSOR_GPIOS + 1) * sizeof(struct gpiod_lookup)), + GFP_KERNEL); + if (!int3472) { + ret = -ENOMEM; + goto out_free_buff; + } + + int3472->adev = adev; + adev->driver_data = int3472; + + int3472->sensor = acpi_dev_get_next_dep_dev(adev, NULL); + if (!int3472->sensor) { + dev_err(&adev->dev, + "This INT3472 entry seems to have no dependents.\n"); + ret = -ENODEV; + goto out_free_int3472; + } + + int3472->gpios.dev_id = i2c_acpi_dev_name(int3472->sensor); + + INIT_LIST_HEAD(&int3472->regulators); + + int3472_parse_crs(int3472); + + goto out_free_buff; + +out_free_int3472: + kfree(int3472); +out_free_buff: + kfree(buffer.pointer); + return ret; +} + +static int int3472_remove(struct acpi_device *adev) +{ + struct int3472_gpio_regulator *reg; + struct int3472_device *int3472; + + int3472 = acpi_driver_data(adev); + + acpi_dev_put(int3472->sensor); + gpiod_remove_lookup_table(&int3472->gpios); + + list_for_each_entry(reg, &int3472->regulators, list) { + gpiod_put(reg->gpio); + regulator_unregister(reg->rdev); + } + + kfree(int3472); + + return 0; +} + +static const struct acpi_device_id int3472_device_id[] = { + { "INT3472", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, int3472_device_id); + +static struct acpi_driver int3472_driver = { + .name = "int3472", + .ids = int3472_device_id, + .ops = { + .add = int3472_add, + .remove = int3472_remove, + }, + .owner = THIS_MODULE, +}; + +module_acpi_driver(int3472_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Dan Scally "); +MODULE_DESCRIPTION("ACPI Driver for Discrete type INT3472 ACPI Devices"); diff --git a/drivers/media/pci/intel/ipu3/int3472.h b/drivers/media/pci/intel/ipu3/int3472.h new file mode 100644 index 000000000000..6964726e8e1f --- /dev/null +++ b/drivers/media/pci/intel/ipu3/int3472.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Author: Dan Scally */ +#include + +#define INT3472_MAX_SENSOR_GPIOS 3 +#define GPIO_REGULATOR_NAME_LENGTH 17 +#define GPIO_REGULATOR_SUPPLY_NAME_LENGTH 9 + +#define INT3472_REGULATOR(_NAME, _SUPPLY, _ID, _OPS) \ + ((const struct regulator_desc) { \ + .name = _NAME, \ + .supply_name = _SUPPLY, \ + .id = _ID, \ + .type = REGULATOR_VOLTAGE, \ + .ops = _OPS, \ + .owner = THIS_MODULE, \ + }) + +const guid_t int3472_gpio_guid = GUID_INIT(0x79234640, 0x9e10, 0x4fea, + 0xa5, 0xc1, 0xb5, 0xaa, 0x8b, + 0x19, 0x75, 0x6f); + +const guid_t cio2_sensor_module_guid = GUID_INIT(0x822ace8f, 0x2814, 0x4174, + 0xa5, 0x6b, 0x5f, 0x02, 0x9f, + 0xe0, 0x79, 0xee); + +struct int3472_cldb { + u8 version; + /* + * control logic type + * 0: UNKNOWN + * 1: DISCRETE(CRD-D) + * 2: PMIC TPS68470 + * 3: PMIC uP6641 + */ + u8 control_logic_type; + u8 control_logic_id; + u8 sensor_card_sku; + u8 reserved[28]; +}; + +struct int3472_device { + struct acpi_device *adev; + struct acpi_device *sensor; + + unsigned int n_gpios; /* how many GPIOs have we seen */ + + unsigned int n_regulators; + struct list_head regulators; + + unsigned int n_sensor_gpios; /* how many have we mapped to sensor */ + struct gpiod_lookup_table gpios; +}; + +struct int3472_gpio_regulator { + char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; + char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH]; + struct gpio_desc *gpio; + struct regulator_dev *rdev; + struct regulator_desc rdesc; + struct list_head list; +}; + +struct int3472_sensor_regulator_map { + char *sensor_module_name; + unsigned int n_supplies; + struct regulator_consumer_supply *supplies; +}; + +/* + * Here follows platform specific mapping information that we can pass to + * regulator_init_data when we register our regulators. They're just mapped + * via index, I.E. the first regulator pin that the code finds for the + * i2c-OVTI2680:00 device is avdd, the second is dovdd and so on. + */ + +static struct regulator_consumer_supply miix_510_ov2680[] = { + { "i2c-OVTI2680:00", "avdd" }, + { "i2c-OVTI2680:00", "dovdd" }, +}; + +static struct regulator_consumer_supply surface_go2_ov5693[] = { + { "i2c-INT33BE:00", "avdd" }, + { "i2c-INT33BE:00", "dovdd" }, +}; + +static struct regulator_consumer_supply surface_book_ov5693[] = { + { "i2c-INT33BE:00", "avdd" }, + { "i2c-INT33BE:00", "dovdd" }, +}; + +static struct int3472_sensor_regulator_map int3472_sensor_regulator_maps[] = { + { "GNDF140809R", 2, miix_510_ov2680 }, + { "YHCU", 2, surface_go2_ov5693 }, + { "MSHW0070", 2, surface_book_ov5693 }, +};