From patchwork Tue Jul 24 22:15:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 948872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Zt3h56bCz9s0R for ; Wed, 25 Jul 2018 08:16:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="VNDLb2yS"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Zt3h2wrLzDrJ5 for ; Wed, 25 Jul 2018 08:16:00 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="VNDLb2yS"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="VNDLb2yS"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41Zt3Q50y8zDrdf for ; Wed, 25 Jul 2018 08:15:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J1psddjeysDMcdi87FfMXGYCU1Jiz3mKa/maFF8kP78=; b=VNDLb2ySqNqlOpz7qME7pbO04 S31UkK7MkJHVNyb/Zz9giZZp5V1l+XQsGC5MmYszNOM6nMhf772K7zF3hP5uhZ+/s/3m5QEFLn/2d iCzT3A+iTK6XepxSyax/e0a9Lj7nvBgpNU8yY7zV9JR2J44D3831UWmE4L+BlzdUObL5HgOMaoEfd 7LQVpo+N4QnNbQ/i/Rd7E6onpRO7iuwBDNw1X/OiLgzC8+sRtZnMj5qWUQQwt2FG/rPk3xIcC6f2K jGSH20SrvN+NsVZ+MJsNhIroLseZ2dwRLIMliVPje/3fRrH1R5Zm/XCdFF4nf+aHe02yBr81ijfuC zzL8EU8tQ==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fi5ap-0004lK-2b; Tue, 24 Jul 2018 22:15:43 +0000 Message-Id: <3fadd55d223aa07f2f8daf9e4faa4d6c1f1b47be.1532469861.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 24 Jul 2018 15:03:16 -0700 Subject: [PATCH v1 20/30] discover/powerpc: Rearange save_config To: Samuel Mendoza-Jonas Date: Tue, 24 Jul 2018 22:15:43 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ge Song , Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" From: Ge Song Rearange update_config and save_config so that update_config only operates on the platform params list. Signed-off-by: Ge Song [Split from a larger patch and cleaned up] Signed-off-by: Geoff Levand --- discover/platform-powerpc.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index d7bd949..c7432fb 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -680,7 +680,7 @@ static void update_bootdev_config(struct platform_powerpc *platform, talloc_free(boot_str); } -static int update_config(struct platform_powerpc *platform, +static void update_config(struct platform_powerpc *platform, struct config *config, struct config *defaults) { char *tmp = NULL; @@ -698,14 +698,6 @@ static int update_config(struct platform_powerpc *platform, val = tmp = talloc_asprintf(platform, "%d", config->autoboot_timeout_sec); - if (config->ipmi_bootdev == IPMI_BOOTDEV_INVALID && - platform->clear_ipmi_bootdev) { - platform->clear_ipmi_bootdev(platform, - config->ipmi_bootdev_persistent); - config->ipmi_bootdev = IPMI_BOOTDEV_NONE; - config->ipmi_bootdev_persistent = false; - } - update_string_config(platform, "petitboot,timeout", val); if (tmp) talloc_free(tmp); @@ -732,8 +724,6 @@ static int update_config(struct platform_powerpc *platform, update_network_config(platform, config); update_bootdev_config(platform, config); - - return write_nvram(platform); } static void set_ipmi_bootdev(struct config *config, enum ipmi_bootdev bootdev, @@ -1154,15 +1144,22 @@ static int save_config(struct platform *p, struct config *config) { struct platform_powerpc *platform = to_platform_powerpc(p); struct config *defaults; - int rc; + + if (config->ipmi_bootdev == IPMI_BOOTDEV_INVALID && + platform->clear_ipmi_bootdev) { + platform->clear_ipmi_bootdev(platform, + config->ipmi_bootdev_persistent); + config->ipmi_bootdev = IPMI_BOOTDEV_NONE; + config->ipmi_bootdev_persistent = false; + } defaults = talloc_zero(platform, struct config); config_set_defaults(defaults); - rc = update_config(platform, config, defaults); + update_config(platform, config, defaults); talloc_free(defaults); - return rc; + return write_nvram(platform); } static void pre_boot(struct platform *p, const struct config *config)