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: