From patchwork Wed Nov 1 10:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 741517 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C08A379E6 for ; Wed, 1 Nov 2023 10:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VT3KSCrT" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB91610C for ; Wed, 1 Nov 2023 03:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698835869; x=1730371869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bfpydvJ3kBqg+Sjvm3/inasxtr6mpue1JJ1FUNGH1ss=; b=VT3KSCrTC2ng3vIGoabQgC01OD7Nj/JG6clmT9q2UOS2f+AXd69BoaUB DEhtT/5Q6nJBUlkVZWO2pt8/HLiCD5IYyXHP2+uiCHv2jgfDTLsP74K/s 8+usBh5UMO23E43mhcgYlwX1gl8Ef48UUDn+7SN3VpSwgVUn0lCLXFiB3 pY6N+qmIwdnLHkYmTomE1sbsqwmvHQ95jn1AD5+r57j/pvrZ4uX+WVdya wMTU5C8mKAf0pDx7JKobBf5IGV3W035BvUP+VrtNnHsVZZpMQgWUcKxpA tG9yDQKgZOaJxdLxfr7z5r4IId4Ib4/xDfXTcOkS08L5t0MWPPiNWqRtN w==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="368682691" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="368682691" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="760902864" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="760902864" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:06 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2B53312098A; Wed, 1 Nov 2023 12:51:03 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" Subject: [PATCH v2 1/3] acpi: property: Let args be NULL in __acpi_node_get_property_reference Date: Wed, 1 Nov 2023 12:51:00 +0200 Message-Id: <20231101105102.1154620-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> References: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 fwnode_get_property_reference() may not be called with args argument NULL on ACPI, OF already supports this. Add the missing NULL checks and document this. The purpose is to be able to count the references. Signed-off-by: Sakari Ailus Fixes: 977d5ad39f3e ("ACPI: Convert ACPI reference args to generic fwnode reference args") --- drivers/acpi/property.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..9ff24d9c19f1 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -851,6 +851,7 @@ static int acpi_get_ref_args(struct fwnode_reference_args *args, * @index: Index of the reference to return * @num_args: Maximum number of arguments after each reference * @args: Location to store the returned reference with optional arguments + * (may be NULL) * * Find property with @name, verifify that it is a package containing at least * one object reference and if so, store the ACPI device object pointer to the @@ -907,8 +908,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, if (!device) return -EINVAL; - args->fwnode = acpi_fwnode_handle(device); - args->nargs = 0; + if (args) { + args->fwnode = acpi_fwnode_handle(device); + args->nargs = 0; + } return 0; case ACPI_TYPE_PACKAGE: /* From patchwork Wed Nov 1 10:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 740077 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B85E1079D for ; Wed, 1 Nov 2023 10:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fJFLxzCL" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1448C118 for ; Wed, 1 Nov 2023 03:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698835872; x=1730371872; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NI0pY1bRqiaMjrT3kfnkep6s61xU5gVy8tAflJrv8IY=; b=fJFLxzCLRENNI+yHBWiP06EQxUTSBB5zk0IBCp83w0zKioJdx/IweU79 /uAi1hd1bnxNaIvmjtait1kFqzGVeDmOX3aA1Fsf0B5MwPD/QYPpQQ9Qb g81+y+Tkll8cNPCeZOTMBKxXZYRI5wdqhbXrlY4D0lwQzMDw7viKZbymT DvnW9UGDInOOagR3Op+l+GnWh+pESmbxoDwOC9o/gaQRh5ufrDPVZDSxy WcU7KxA39UmYkMYJUdHA9KfbkY3guoZf6gbWFVI+ZAiw2wVZbS04L44ai lsngf9+SaAh+eT/JLRqC9l65EAu4a6gSoY5NLhhRM6a03IFoAJyqOkXcQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="368682696" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="368682696" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="760902865" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="760902865" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:06 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2B7481209FB; Wed, 1 Nov 2023 12:51:03 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" Subject: [PATCH v2 2/3] software node: Let args be NULL in software_node_get_reference_args Date: Wed, 1 Nov 2023 12:51:01 +0200 Message-Id: <20231101105102.1154620-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> References: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 fwnode_get_property_reference() may not be called with args argument NULL and while OF already supports this. Add the missing NULL check. The purpose is to be able to count the references. Fixes: b06184acf751 ("software node: Add software_node_get_reference_args()") Signed-off-by: Sakari Ailus --- drivers/base/swnode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 1886995a0b3a..079bd14bdedc 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -541,6 +541,9 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode, if (nargs > NR_FWNODE_REFERENCE_ARGS) return -EINVAL; + if (!args) + return 0; + args->fwnode = software_node_get(refnode); args->nargs = nargs; From patchwork Wed Nov 1 10:51:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 740078 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B7A81079B for ; Wed, 1 Nov 2023 10:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H4Q/NStV" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29089119 for ; Wed, 1 Nov 2023 03:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698835872; x=1730371872; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YKFzF32oVi7oNhOUD5npF4DwwVaEgqx+4gwIyc8RAIg=; b=H4Q/NStVptArjg844KXfPh47UgMxQ3laE8Pu5JNQsE1CEVeestsj5tNo zXpzk6DxEYgekEfMCq31pTKVlPrYyNVrDxWSecNrOeaM6a277iq6zJKvP KyzJ/AwCZ06q0YYYnpBYcgjHRWUmbfcSIVwOhIFIKNtcVQ9EuZPQVX+6a RyB4N95zPvqvLFcn9Ycsg5CZgt1qT5qXsQeMRCweoX5LVpO7WaE7o3XSo aP5SeyMLSYVWfM6ZjdH6SPK4VqozLFh/Q94hOIYFN68ayAPzb+vu51J1O Zt7L8NFvzI91cQ38FmGMge0fYq3xYUIURWWrz+Y/aiAN2uk2EL/0baWUn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="368682699" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="368682699" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="760902866" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="760902866" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:51:07 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id DEB11120BD3; Wed, 1 Nov 2023 12:51:04 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" Subject: [PATCH v2 3/3] device property: fwnode_property_get_reference allows NULL args now Date: Wed, 1 Nov 2023 12:51:02 +0200 Message-Id: <20231101105102.1154620-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> References: <20231101105102.1154620-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All three fwnode_property_get_reference() now allow args argument to be NULL. Document this. Signed-off-by: Sakari Ailus --- drivers/base/property.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 8c40abed7852..8667b13639d2 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -508,6 +508,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string); * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL. * @index: Index of the reference, from zero onwards. * @args: Result structure with reference and integer arguments. + * May be NULL. * * Obtain a reference based on a named property in an fwnode, with * integer arguments.