From patchwork Thu Nov 9 10:10:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13450870 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 CFC2E15EB6 for ; Thu, 9 Nov 2023 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J5wRoCmS" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 639072D65 for ; Thu, 9 Nov 2023 02:10:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699524619; x=1731060619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NA/sJdCrLqbFypsfbxjkXbC8FskGu2awhv9fbmjjLzo=; b=J5wRoCmSadeiAeaYWU9u4K53BkCBypevKeZnVYRsVS6HRbpwucaDCAHi xe6YjKT9nLBQMQIDeVzoPjNBCP/oLuVgzi6diVUy+7lKJcmkIFI+1YlRY w0PpJ728x7RPCDO13HJXuvZpo2Jt1T4je5UB36iSeBBq0HMd/U0cYYqEI lSYaHl4Q7OcQ+1jqcCw/QSfILOZv4O8aSKG1J4pf7vmYtUQJOnd6npKOO o+Ji0U+tVJ4zIqDnDtiqayQsx88Azyz5firHikZ5EAwXUjUCjfVWSMyTg TOqvQYp2rLdqJyeLoROqcgyB4+U/h4XdP3rD8KCt0JOTKQSf1tK2gRXsv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="369289673" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="369289673" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="756841700" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="756841700" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:17 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2B62B11FC11; Thu, 9 Nov 2023 12:10:14 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" , Greg Kroah-Hartman Subject: [RESEND PATCH v4 1/3] acpi: property: Let args be NULL in __acpi_node_get_property_reference Date: Thu, 9 Nov 2023 12:10:08 +0200 Message-Id: <20231109101010.1329587-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109101010.1329587-1-sakari.ailus@linux.intel.com> References: <20231109101010.1329587-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_args() 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. Fixes: 977d5ad39f3e ("ACPI: Convert ACPI reference args to generic fwnode reference args") Signed-off-by: Sakari Ailus Reviewed-by: Andy Shevchenko Reviewed-by: Heikki Krogerus --- drivers/acpi/property.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..93608714b652 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,6 +908,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, if (!device) return -EINVAL; + if (!args) + return 0; + args->fwnode = acpi_fwnode_handle(device); args->nargs = 0; return 0; From patchwork Thu Nov 9 10:10:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13450871 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 80D3E16418 for ; Thu, 9 Nov 2023 10:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ROHxM4Eo" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5AB2D78 for ; Thu, 9 Nov 2023 02:10:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699524620; x=1731060620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IHpMNOCrEKGmJCvVxepQRrs3+NvigcRXWywvKZ/CPns=; b=ROHxM4EoPUoC+TZYhA3UZqixhL4oABD+IkemZj6LzoAEd/JFcxUQBbQe hIOjVI1QFgRUpeWOWruDABDoxthFaf5IWWRRfWRNhhd8il1fj6biAipHI 9B0atq84WwbJDBWXn603qlOi5gYA+4LNc1GPZjFiZsB7Tp4YAIe5hrb3z 3iP1yyDFD1RQfrcGCCHC5V13PtNVRMey3YeQKkP3+tbkkx6m9OOkogf/w aV5zbykTtWhajUGQsx1v3mc8kd4EGh8eDZDSEJzXf9sxM9qJUm5ZzfmEI mbCrdwHSUXdx0ccvoDaao+qHNyfZX4Qkkj/5KR8ePk1/hLlH3yOE/ianZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="369289678" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="369289678" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="756841703" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="756841703" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:18 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 285C511FC2C; Thu, 9 Nov 2023 12:10:15 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" , Greg Kroah-Hartman Subject: [RESEND PATCH v4 2/3] software node: Let args be NULL in software_node_get_reference_args Date: Thu, 9 Nov 2023 12:10:09 +0200 Message-Id: <20231109101010.1329587-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109101010.1329587-1-sakari.ailus@linux.intel.com> References: <20231109101010.1329587-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_args() 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 Reviewed-by: Andy Shevchenko Reviewed-by: Heikki Krogerus --- 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 Thu Nov 9 10:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13450872 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 7F8B9A38 for ; Thu, 9 Nov 2023 10:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="L5xXrLBQ" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A08D2D51 for ; Thu, 9 Nov 2023 02:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699524621; x=1731060621; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/2raFpHjB2PaP6prUEiUv6WGseg5qiXtp3vlEzsRSH0=; b=L5xXrLBQW1jclprmY+RIJnRBFz4vSUQZ3LM4+vUrFnWO1HA1PX/3AWLv NOAP+rBf/U6ny7wifceovi//BxVqUCqnKSyM6IeuxDk8kImDmUdgOUBIS JvS8K9zgzwiOO/JnfvzygrsNNxM1tkYOEGj/bJv3BwPl6F1X2Lb5XFzcW vXpFJYTtvDrh+JoQsVr45ZIQI2z0131L9PTb+AzA/tsipl9Dm/50N1TXa rhAgr68PzH17Cj+H136n2AcYYDEeSmPhBdAtbyXyYDZ/0odBH2JDkUiRM 09ypAfYL7aNm20TQksvKgzSGj94QNP8vUV5rxghe6opLygF7WRSTylvQA A==; X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="369289683" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="369289683" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="756841705" X-IronPort-AV: E=Sophos;i="6.03,289,1694761200"; d="scan'208";a="756841705" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2023 02:10:19 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 1857111FC2D; Thu, 9 Nov 2023 12:10:16 +0200 (EET) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" , Greg Kroah-Hartman Subject: [RESEND PATCH v4 3/3] device property: fwnode_property_get_reference_args allows NULL args now Date: Thu, 9 Nov 2023 12:10:10 +0200 Message-Id: <20231109101010.1329587-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109101010.1329587-1-sakari.ailus@linux.intel.com> References: <20231109101010.1329587-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_args() implemantations now allow args argument to be NULL. Document this. Signed-off-by: Sakari Ailus Reviewed-by: Andy Shevchenko Reviewed-by: Heikki Krogerus --- 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.