Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp85712rdb; Thu, 25 Jan 2024 08:58:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgqsRjuzAQgP5hEWiPPuW3T75N2RxKvh13TwmhBrMLsBE92w9nUNR09CtrCZlIgyEnyTDp X-Received: by 2002:a05:6a20:9c9a:b0:19c:537c:767e with SMTP id mj26-20020a056a209c9a00b0019c537c767emr1408757pzb.33.1706201881484; Thu, 25 Jan 2024 08:58:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706201881; cv=pass; d=google.com; s=arc-20160816; b=fT2tNH0eK6mVPXTQ18/cHrWpAcVbg4RIZw6n3XCd7Hjhh03Rc0oK1xq1xjYH7T1U3/ HbgbUZ2/Kg6vGh93OQSnWb+JwUcAXX3GC5Sj6Kt4EB9YcivSIhh8gswXtvjoDiNmNQ0m 9EVxQ8c01t8HRuKUiXq0fo6sMgEP/mopulYaxBt8bJP1U7bapAY71YaLwIYRwyWnbErT TefkF9TCrsb8LJxOSOT0LXrddm+CDr2r0YRrbiIVIchv7+tzaQUgDsv8ZvXBdTr95kDD FOAx8P/6Pq3Tl6ORa/Q7B6WHrHWOCFBGDodT2aBQUTnUEkRjV/2fLU4UEbHLdFpZ1lfW C5Gg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NpYeGi9fgLVXYL5ZAmgZfJeaprEEibWMkt8xw+gQ3Wc=; fh=ON0oQ90Z4xnjbNCGsyMgiRbLR29nyOKvbeaw6TmRihk=; b=MelVxo3RVa6N5JrMsso1L83yVzkKYWpxU4c1ZJ/VKRenC/hf++Q/cK45kIRlRdugGL HLKJ5g/HG6lcBRYz2GNQ+KRghIWC/BH2frb8zbmR2QJ2UpfKxS+BJFir4fHgH8OXscg+ x+p+mUEJ/JPk7CgwwByWd4gZzI0g4IvbYVeRRWCQCjDaYaQFeVvMBVyrzj6eLf3u2+Mg V3DXVTiLImvtM64rMdRy2YW+/xmqyZCqsTE+qXMLNjm48K1ZF+QlK5fhRHzEP2WaDlxv uOSTYU/DBoxnbDbVdEMe3hJsj7ejtGA/Z92qX+dWK6Buyh8ke+KBBCxjjeN2/E5MGGxl 4NVA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f3-20020a635543000000b005d735e164b3si272307pgm.901.2024.01.25.08.58.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:58:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DED28B21A7A for ; Thu, 25 Jan 2024 16:49:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8164513BEB4; Thu, 25 Jan 2024 16:44:16 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BC161339BA; Thu, 25 Jan 2024 16:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201055; cv=none; b=Fe8jbOPRBGULVbKcttZ+en0iUgdlQq22Ud8EjBRDgtg2QVb6oI9tYD0tg3utYiBPcLW8xmQsWpwjtBtLXFwYLxPNCsnRLbbabgLLqWVausT+mEMxk05PYoj5Wzj3q4fuy1yI+U4D+vAzBE/nXhWv+0rctE68BiTfVbvFevMWrGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201055; c=relaxed/simple; bh=7/IUb3XLktUN45V9JyajrdKMq9EZsYTVNnF5KRHa0mo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RrSv7I40ltwjMpiJJODirVCL+wr0RaLJ/CISXYhDP+Zn2gki4wkeonhKUculqDJmesiDXcIL2FT9ONiAUZD1MBSFmOXrWBkcmBbPZr/zBDwxKCyAbBC4qEOmIXFUUEAvTjmNzczHTiReSPxjwTTJGzwu2fHLyVjiV6iMt/fCum8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 48AE015BF; Thu, 25 Jan 2024 08:44:58 -0800 (PST) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5846F3F5A1; Thu, 25 Jan 2024 08:44:08 -0800 (PST) From: Alexandru Elisei To: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com Cc: pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH RFC v3 15/35] of: fdt: Add of_flat_read_u32() Date: Thu, 25 Jan 2024 16:42:36 +0000 Message-Id: <20240125164256.4147-16-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125164256.4147-1-alexandru.elisei@arm.com> References: <20240125164256.4147-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add the function of_flat_read_u32() to return the value of a property as an u32. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, suggested by Rob Herring. drivers/of/fdt.c | 21 +++++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bf502ba8da95..dfcd79fd5fd9 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -755,6 +755,27 @@ const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, return fdt_getprop(initial_boot_params, node, name, size); } +/* + * of_flat_read_u32 - Return the value of the given property as an u32. + * + * @node: device node from which the property value is to be read + * @propname: name of the property + * @out_value: the value of the property + * @return: 0 on success, -EINVAL if property does not exist + */ +int __init of_flat_read_u32(unsigned long node, const char *propname, + u32 *out_value) +{ + const __be32 *reg; + + reg = of_get_flat_dt_prop(node, propname, NULL); + if (!reg) + return -EINVAL; + + *out_value = be32_to_cpup(reg); + return 0; +} + /** * of_fdt_is_compatible - Return true if given node from the given blob has * compat in its compatible list diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 0e26f8c3b10e..d7901699061b 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -57,6 +57,8 @@ extern const void *of_get_flat_dt_prop(unsigned long node, const char *name, extern int of_flat_dt_is_compatible(unsigned long node, const char *name); extern unsigned long of_get_flat_dt_root(void); extern uint32_t of_get_flat_dt_phandle(unsigned long node); +extern int of_flat_read_u32(unsigned long node, const char *propname, + u32 *out_value); extern int early_init_dt_scan_chosen(char *cmdline); extern int early_init_dt_scan_memory(void); -- 2.43.0