From patchwork Wed Nov 1 09:07:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 741520 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 311646FDD for ; Wed, 1 Nov 2023 09:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Dpj9CZNK" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C93EF107 for ; Wed, 1 Nov 2023 02:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698829665; x=1730365665; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/vdIfbhMH/CuJP3bMUq8UwkevHnXHvj/UDmgJ39rw50=; b=Dpj9CZNKvoExE9/B8lOa3x/nce+rpysXdOFrblZUVeMkb3a8Wy4Xdpw1 oTqJo4IBhWvfzVtcq7mCCjA+Pf68Wk4oKTAVe3oU21KNtXzS7iWTTHita GQRp+J3n9tKz6higK57vAOnqRNBYUTFZvfHU+WGh7+y4VZoATfW0KzAoO VISMJFzIevto+VYV+dWMk6p8VqSndr/7RxlaOUYbBPkdrFJsgnEuJeokm ZFyphAp4JR6NpTnFMRWbZnrGXzf6XXSmCAXt+u8rDRU8Wctt/nza2orhs Yg/YDGv1vrdKuaFdoXSToF28U9c6JG5g2/GtivEEtK7woepWW7RBIE3zG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="1314619" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="1314619" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="1008052030" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="1008052030" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:41 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id CAFB311F9E8; Wed, 1 Nov 2023 11:07:38 +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 1/3] acpi: property: Let args be NULL in __acpi_node_get_property_reference Date: Wed, 1 Nov 2023 11:07:35 +0200 Message-Id: <20231101090737.1148303-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101090737.1148303-1-sakari.ailus@linux.intel.com> References: <20231101090737.1148303-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 --- drivers/acpi/property.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index d60ee0510311..fa473fc2617b 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -879,7 +879,8 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f * @propname: Name of the property * @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 + * @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 @@ -937,8 +938,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_STRING: @@ -949,8 +952,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, if (!ref_fwnode) return -EINVAL; - args->fwnode = ref_fwnode; - args->nargs = 0; + if (args) { + args->fwnode = ref_fwnode; + args->nargs = 0; + } return 0; case ACPI_TYPE_PACKAGE: From patchwork Wed Nov 1 09:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 741519 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 8CE20746B for ; Wed, 1 Nov 2023 09:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l/yHxh8j" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277DFF1 for ; Wed, 1 Nov 2023 02:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698829668; x=1730365668; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FlKHw1b9YO7rIlDQQa3rbDIiZQ6oaFI4czBtQ8o7KMA=; b=l/yHxh8juRFZsijKuc3kDPVUOjCr2kV1d2VYxbFJKB/QhPjlpW8GFS95 NY/rT6Cyx3CzgFjK0yO/UQHteTTuReGMeKoY4Tfd05k1M6nO1fTSjBJHo ID3GCmSoD4Y8vErfsqzD8ULfGkTJzVP+3nw0YXR8coZKla65pTeyRNiAN 8riqyiYRSJY1UXqgWXC6pE1uazgaku4psMcwILOdhLblMyIwf1droorWJ aKtRLClIhbe6KJq7eedZ0w0GgqpusL2CeiMmAnl6CXOvaVW+qDfEvg+8u 8YxHbLOwRSVN3OrOBHUiZb1KwZETMvzaL/HfGTQjr6+EVo2NcqOhuYUT6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="1314624" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="1314624" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="1008052031" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="1008052031" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:42 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 7EF9A1207DA; Wed, 1 Nov 2023 11:07:39 +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 2/3] software node: Let args be NULL in software_node_get_reference_args Date: Wed, 1 Nov 2023 11:07:36 +0200 Message-Id: <20231101090737.1148303-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101090737.1148303-1-sakari.ailus@linux.intel.com> References: <20231101090737.1148303-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. 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 09:07:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 740080 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 D43C96FDF for ; Wed, 1 Nov 2023 09:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fug97fgu" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A59E121 for ; Wed, 1 Nov 2023 02:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698829667; x=1730365667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lf2DeuIuVeem6mH16UyF2feA5lfIQF4u4qmvUR3qUw4=; b=fug97fguwY3DhIV0JznMgabCHbek3XPlWTH8Ln0fVK+D9xTVBkU0a7ce SRwBBK3etZID509qVCYuuPizjNch4tZJEPX0WWRF7ZvPEdGo8YHmnIqde gCVJdZltR4B/Vt0/cz8BwSKHcgi8sMdZKxhm4hcJMOsU5/08u3t7Ycooh 2+2IB2QaTbi8ZwqtzKvwkT9YiBsL1o+ccPA4hGi/5su7B8ZteQ23ZA5Sy FlY6XoZoBPuvANriLTXjAXJPVsvnJajshA+KBWGqD2rsRf7YdZw6t948c XSVOhKRslnxm39eEGz917CEyqWiRAgPziU5uuICbONaztAMpGYc1oo9JX w==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="7088617" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="7088617" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="884500010" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="884500010" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 02:07:44 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 800F1120BDC; Wed, 1 Nov 2023 11:07:40 +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 3/3] device property: fwnode_property_get_reference allows NULL args now Date: Wed, 1 Nov 2023 11:07:37 +0200 Message-Id: <20231101090737.1148303-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231101090737.1148303-1-sakari.ailus@linux.intel.com> References: <20231101090737.1148303-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 89a6e0833356..b39d3ae04877 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.