From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43CA7C71153 for ; Tue, 29 Aug 2023 20:37:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A4CC86543; Tue, 29 Aug 2023 22:37:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="rjq4qg2X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D7868653E; Tue, 29 Aug 2023 22:37:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id 6D0D586507 for ; Tue, 29 Aug 2023 22:37:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanedmond@linux.microsoft.com Received: from ovlvm106.redmond.corp.microsoft.com (unknown [131.107.147.185]) by linux.microsoft.com (Postfix) with ESMTPSA id A905A2129BF3; Tue, 29 Aug 2023 13:37:11 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A905A2129BF3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1693341431; bh=edg4vBdNF6GgHSHKlJsbhB7EYSRRgl0qNDcj6+6Rm8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjq4qg2XmK1OGIXUKjkA0cfPXf+YxyxMPNJSE7HD92F6Xg+iAYeUaEl/iTwijD0w2 lkltTYH7wBtZFp/FkKWpH5HHQzI/cKd5nVhI5GE7DOuonKV98xWVbYbCHR0iceIP5c 7n29Say44EwpOBHIFaX7wvynAanYqD5hIL77ME98= From: seanedmond@linux.microsoft.com To: u-boot@lists.denx.de Cc: dphadke@linux.microsoft.com, macromorgan@hotmail.com, sjg@chromium.org Subject: [PATCH v2 3/4] cmd: kaslrseed: Use common API to fixup FDT Date: Tue, 29 Aug 2023 13:37:09 -0700 Message-Id: <20230829203710.84201-4-seanedmond@linux.microsoft.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230829203710.84201-1-seanedmond@linux.microsoft.com> References: <20230829203710.84201-1-seanedmond@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Sean Edmond Use the newly introduced common API fdt_fixup_kaslr_seed() in the kaslrseed command. Signed-off-by: Sean Edmond --- cmd/kaslrseed.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/cmd/kaslrseed.c b/cmd/kaslrseed.c index 8a1d8120cd..c65607619b 100644 --- a/cmd/kaslrseed.c +++ b/cmd/kaslrseed.c @@ -19,7 +19,7 @@ static int do_kaslr_seed(struct cmd_tbl *cmdtp, int flag, int argc, char *const size_t n = 0x8; struct udevice *dev; u64 *buf; - int nodeoffset; + ofnode root; int ret = CMD_RET_SUCCESS; if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { @@ -45,21 +45,15 @@ static int do_kaslr_seed(struct cmd_tbl *cmdtp, int flag, int argc, char *const return CMD_RET_FAILURE; } - ret = fdt_check_header(working_fdt); - if (ret < 0) { - printf("fdt_chosen: %s\n", fdt_strerror(ret)); - return CMD_RET_FAILURE; - } - - nodeoffset = fdt_find_or_add_subnode(working_fdt, 0, "chosen"); - if (nodeoffset < 0) { - printf("Reading chosen node failed\n"); - return CMD_RET_FAILURE; + ret = root_ofnode_from_fdt(working_fdt, &root); + if (ret) { + printf("ERROR: Unable to get root ofnode\n"); + goto CMD_RET_FAILURE; } - ret = fdt_setprop(working_fdt, nodeoffset, "kaslr-seed", buf, sizeof(buf)); - if (ret < 0) { - printf("Unable to set kaslr-seed on chosen node: %s\n", fdt_strerror(ret)); + ret = fdt_fixup_kaslr_seed(root, buf, sizeof(buf)); + if (ret) { + printf("ERROR: failed to add kaslr-seed to fdt\n"); return CMD_RET_FAILURE; } -- 2.40.0