From patchwork Fri Nov 3 08:36:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13444402 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 E432463CA for ; Fri, 3 Nov 2023 08:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jAzz9iR7" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD3CD43 for ; Fri, 3 Nov 2023 01:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699000592; x=1730536592; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zd3Fwb15RsOsNN7qFCEwrfeBzsFm0lpTGIjSI1S97A0=; b=jAzz9iR7WNY8jqIl/cy98qg2IGHGbn0ygom5kFW0WGu77uWiZQyUDup9 qrIZnybqozoxbWwPmNby1xaQPU1rJpjjAq1cbpDXYkLfhCR8eMKbvq6dr zP1z0QjJgvkQzjecViMGNK/itWEgaSBwxALOerTDdzaG3TS7t9rpQqIsm VwBN+foww/QELoA05TXzuGft3ji7DqPewQWM19JGHXgWvbmv4rljswG1e TP7+B1oltCLQfNwQuH7QEcAq33gGCQ5QV8NzsP8HSMllaT8LuEBXznapD eBypqULhH4Pp4fonMe+BMg2A4t44SMYsTKdhs0HYEuDo1uwZpNL1aQO2v Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="373943764" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="373943764" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="878574860" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="878574860" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:30 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 68279120F5D; Fri, 3 Nov 2023 10:36:27 +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 v4 1/3] acpi: property: Let args be NULL in __acpi_node_get_property_reference Date: Fri, 3 Nov 2023 10:36:23 +0200 Message-Id: <20231103083625.1229008-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103083625.1229008-1-sakari.ailus@linux.intel.com> References: <20231103083625.1229008-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: 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 Fri Nov 3 08:36:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13444403 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 892CA6FA3 for ; Fri, 3 Nov 2023 08:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="F/sVcho+" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1B1D42 for ; Fri, 3 Nov 2023 01:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699000596; x=1730536596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Z/QjL4c11dFL7cYIx9QB1bsJdnkklZS2hx2d7+OSs4=; b=F/sVcho++rZLDvEVtWrlPML9R4jgZHk8X11S39Hu+Cj7x+Pm6WxGgL54 5ixwHb6EsEHuwTFo9SpT/CK98+ve9XbpaX9QLUAFqjmfeYBydLMQamBVG owVih84JRmYI7Zi64ch4PKyznnNUGJ5YSKmLfuvjb0Tyk2vmK2N7EiG9q 6AX3bXCmc1M7N8Gf/iKcfgam0VyPkf4E7aIsNtm2ND/6Qhg5IzfF4SCg7 myjNaFuNeizIvtDjr6hkYFrQJoKLj99sQQUiBw2EKp8yPMC13NMGpR+UD kcpdOXkEJPni+mM1dJoEZBYYn/URh26Kr+AFM//fQMEKYADQ4finkjpzn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="373943769" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="373943769" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="878574864" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="878574864" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:31 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 57497120F62; Fri, 3 Nov 2023 10:36:28 +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 v4 2/3] software node: Let args be NULL in software_node_get_reference_args Date: Fri, 3 Nov 2023 10:36:24 +0200 Message-Id: <20231103083625.1229008-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103083625.1229008-1-sakari.ailus@linux.intel.com> References: <20231103083625.1229008-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: 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 Fri Nov 3 08:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 13444404 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 C07D06FB5 for ; Fri, 3 Nov 2023 08:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AIe/8oeE" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39900D44 for ; Fri, 3 Nov 2023 01:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699000596; x=1730536596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q1rFDdn055YhUM6w8twK1/O3m+2EDsWdczT++7HzALY=; b=AIe/8oeEe9sF93RTx9r2SLvx/YhnABA82/Me+s3WGgRaDWehBPJUWWew xYQOk6+cK0t68UFYmyXjV+Xw4PqCmw69c76ltiIbSMhvNlRseT+6HsOVt 4yCtfcJehD9LsPpofhLznbaC/hZsIWDGJcDO4z6R5nU7lg9advP/6/24R JAse+ChFEnVnV9b1jZWizFtK9+o1KewCn8IisIaS+SLfxzX3eN8u9/jfM ObSwYszCELwjOP84gkFybIQyz1GVjIwLZAuSHatjzULxn/61Zu5Egpo6a GFtndjHoVvHNOTJv5cvmOE+4aYzODVR9TISJC131sUYzd0tDr9/wsimI1 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="373943774" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="373943774" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="878574868" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="878574868" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:36:32 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 3A573120FB1; Fri, 3 Nov 2023 10:36:29 +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 v4 3/3] device property: fwnode_property_get_reference_args allows NULL args now Date: Fri, 3 Nov 2023 10:36:25 +0200 Message-Id: <20231103083625.1229008-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103083625.1229008-1-sakari.ailus@linux.intel.com> References: <20231103083625.1229008-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: 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.