From patchwork Thu Nov 2 10:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 740492 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 E9C3A12B87 for ; Thu, 2 Nov 2023 10:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="m+nckL6N" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4E8128 for ; Thu, 2 Nov 2023 03:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698920005; x=1730456005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tGQmHILfY7P/U0hixDDVbuxsHPcdqb8ehiyBUAM3IU0=; b=m+nckL6NxwSMacGAk6lZrN9R7UOeoMt49cjkicgbBFaPW6CR6QVnzOfy 6w9EHy0w92kz/O+VyBSNiDccsGiTjeYNEbOSwhkW7L7/TOEVN5QEYtfth ItsC4Iejb6+OEkxTJd74tvohB3zUX3592aR9Px6stb6/ktlnLtYMNP2o0 5k4HnwID3k4ZUw1gM9QLCsTcmiEjQeP5kSWPkzfDSJhcKOPXR4jblVISS vMjSdW533hLwblK1qqZvuW+oJYBjR2DbnxIlQv5v3Bmal8WxaQFjJ8WA0 EVZyvK2pinEsKV6D06oReuDpCl84viYkSRBahy5O3LnF6mM0/Khjx6+E3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="7318637" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="7318637" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="904969780" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="904969780" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:21 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 43D2412055E; Thu, 2 Nov 2023 12:13:18 +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 v3 1/3] acpi: property: Let args be NULL in __acpi_node_get_property_reference Date: Thu, 2 Nov 2023 12:13:14 +0200 Message-Id: <20231102101316.1186215-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231102101316.1186215-1-sakari.ailus@linux.intel.com> References: <20231102101316.1186215-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 --- 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 Thu Nov 2 10:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 740493 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 5EB8B12B8C for ; Thu, 2 Nov 2023 10:13:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PzwFOI2l" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15D5B131 for ; Thu, 2 Nov 2023 03:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698920008; x=1730456008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Z/QjL4c11dFL7cYIx9QB1bsJdnkklZS2hx2d7+OSs4=; b=PzwFOI2l1n3dVMArQxH+IsH0LgiTCGl/TpJ2R84L/gTPiuxk7Iz05p01 3LA2tKzbFuiadY0yN1oGG6zfuVSZM1UVKi9vBL0ghRzMWFhtxKvlMAZSd sQj8h2iB8ROZJzUuCKz/10gpvcsHFhLFY7vimmVtX1vVx5y5EAl47l7YJ WtU6CwqB8j4OPb8m+25sA/Qu4+2ixfjtzWlTq2n0/T9QbOkWehmyr7v8W tMe8W8uczPMX5ssbILPhEykWV3RuI5hGmsZpNGFOuv0zrvVobNk9Jb+PT CEIGrGdr54I75llOtLtZktAhEGn5XcIsVEoEbQJDkMAsTsD5CpbsgHQmz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="7318643" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="7318643" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="904969781" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="904969781" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:22 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 466DE120819; Thu, 2 Nov 2023 12:13:19 +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 v3 2/3] software node: Let args be NULL in software_node_get_reference_args Date: Thu, 2 Nov 2023 12:13:15 +0200 Message-Id: <20231102101316.1186215-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231102101316.1186215-1-sakari.ailus@linux.intel.com> References: <20231102101316.1186215-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 --- 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 2 10:13:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 741513 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 762F812B92 for ; Thu, 2 Nov 2023 10:13:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Uj/B+wZA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A64133 for ; Thu, 2 Nov 2023 03:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698920008; x=1730456008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q1rFDdn055YhUM6w8twK1/O3m+2EDsWdczT++7HzALY=; b=Uj/B+wZAY4A5aK3Qj8KKDaqEfi8/JTA9cosxMbYjSroh+IpnIwZs0fSQ HlQh1wsS3Xdws/4a7zPSaPxWguvosvFrepqvq0bH+Mx6mqnZ8wE3izi54 MSsdQrMmT5CSqXl7151IVIVFJWAZM166lrWr6/jSDq9lCDh9u8kMJo0YK MRy4NAStlf+vFEdUsUeGlWcy26RtwAA9RhDomsr1J49pjfQ3bL3YS58Yv h3/Y/ixg/h4mI2ISJQ5MJ7eunIiYd+0mJxniZBOz6Q8JbD+4SQngAaNaZ dQttXJQMxig5hAq02q7dxgBfOmbSzsHM9kffRzOh9GTzljV3PoXEWED7r A==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="7318646" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="7318646" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="904969784" X-IronPort-AV: E=Sophos;i="6.03,271,1694761200"; d="scan'208";a="904969784" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 03:13:23 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 3534812098A; Thu, 2 Nov 2023 12:13:20 +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 v3 3/3] device property: fwnode_property_get_reference_args allows NULL args now Date: Thu, 2 Nov 2023 12:13:16 +0200 Message-Id: <20231102101316.1186215-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231102101316.1186215-1-sakari.ailus@linux.intel.com> References: <20231102101316.1186215-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 --- 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.