From patchwork Tue Feb 22 15:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 12755395 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8ABB9C433EF for ; Tue, 22 Feb 2022 15:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HniOoEdVPY1wBko4DV0+mxOB0UOCXhrrXOzRbvfoLCA=; b=a4NhKkHVkB70Pg RZQ6EEJybIKdfk+5VoqPlegURb/+5Fmbl3v8SulALhcWYbOcwWlj0gScucbVJ5UPjgcYAEOmMWpP0 1rVN8bHzxtFpdpRenGf+hvsAp/191NH81AITxrS1sbYJIEbUOQW65aql8hgToFRfz4nWX9UGJkkL/ c/S922urQ+i9C462TrRbEYW1w2zaAqsFmZUYiw3ecAjKoY7yr/64F7WKlCT+Jx5A2ayZ/s6ZICD12 aw6HCYLYJ+atTcNSZRzBMzAjNxb3TZRcJtNmoqyybuz9s5ARY5KS4zShBGJ7USfQHQavziptZSDMP bfbP21LCLBlkBNziEsAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMWut-00A93p-QS; Tue, 22 Feb 2022 15:17:28 +0000 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMWoQ-00A5qy-TP for linux-arm-kernel@lists.infradead.org; Tue, 22 Feb 2022 15:10:50 +0000 Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 0614AFF808; Tue, 22 Feb 2022 15:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1645542643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CtKL8F/Jq2zYU6K+/py9GTxpMsuM+hyFjUkbGMfpBM8=; b=fpCxi/gpQB8ymagHFzpSGHRh9evnDJfs8mijFq206mD+Yy/+eAZpotSk6Q7xmKRtKC7vsL 55v7gXCYcoCZ4WHRhrcnQX20PDTtRSc5GPGEf2AdetXvvvxPIz6byxlThuvejkgAyOLXKR 7uk48uZSRIKDZOeDP/VAwyeMJlZR1T9lJGs3SEgCkYtDuWAodQLkcbhbUAqQ10tlquglkw G70LtGtP2N0o+XEKKN28HP3TU249JHgbG1Hytv+wiyNRruTH08VjaPozBBG4e552gObvzh H7SSg3MRhTJtW6BKWxeewGMMeoUrVHK3CZ9ZfMSg779uR76bT3Ka0HItU0CI/g== From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Russell King , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , =?utf-8?b?Q2zDqW1lbnQgTMOp?= =?utf-8?b?Z2Vy?= Subject: [PATCH 2/4] ARM: at91: pm: move "atmel.pm_modes" parsing into a common file Date: Tue, 22 Feb 2022 16:08:44 +0100 Message-Id: <20220222150846.255307-3-clement.leger@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220222150846.255307-1-clement.leger@bootlin.com> References: <20220222150846.255307-1-clement.leger@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_071047_334199_A861095D X-CRM114-Status: GOOD ( 17.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to add secure suspend support, split out code that will be reused to parse the boot argument "atmel.pm_modes". Signed-off-by: Clément Léger Reported-by: kernel test robot --- arch/arm/mach-at91/Makefile | 2 +- arch/arm/mach-at91/pm.c | 31 ++------------------------- arch/arm/mach-at91/pm.h | 7 ++++++ arch/arm/mach-at91/pm_common.c | 39 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 arch/arm/mach-at91/pm_common.c diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index 0dcc37180588..23620ccf7ab6 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_SAMA7) += sama7.o obj-$(CONFIG_SOC_SAMV7) += samv7.o # Power Management -obj-$(CONFIG_ATMEL_PM) += pm.o pm_suspend.o +obj-$(CONFIG_ATMEL_PM) += pm.o pm_suspend.o pm_common.o ifeq ($(CONFIG_CPU_V7),y) AFLAGS_pm_suspend.o := -march=armv7-a diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index dd6f4ce3f766..b575304ccf63 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -99,15 +99,6 @@ static struct at91_soc_pm soc_pm = { }, }; -static const match_table_t pm_modes __initconst = { - { AT91_PM_STANDBY, "standby" }, - { AT91_PM_ULP0, "ulp0" }, - { AT91_PM_ULP0_FAST, "ulp0-fast" }, - { AT91_PM_ULP1, "ulp1" }, - { AT91_PM_BACKUP, "backup" }, - { -1, NULL }, -}; - #define at91_ramc_read(id, field) \ __raw_readl(soc_pm.data.ramc[id] + field) @@ -1243,25 +1234,7 @@ void __init sama7_pm_init(void) static int __init at91_pm_modes_select(char *str) { - char *s; - substring_t args[MAX_OPT_ARGS]; - int standby, suspend; - - if (!str) - return 0; - - s = strsep(&str, ","); - standby = match_token(s, pm_modes, args); - if (standby < 0) - return 0; - - suspend = match_token(str, pm_modes, args); - if (suspend < 0) - return 0; - - soc_pm.data.standby_mode = standby; - soc_pm.data.suspend_mode = suspend; - - return 0; + return at91_pm_common_modes_select(str, &soc_pm.data.standby_mode, + &soc_pm.data.suspend_mode); } early_param("atmel.pm_modes", at91_pm_modes_select); diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h index 53bdc9000e44..e9f7f9841afd 100644 --- a/arch/arm/mach-at91/pm.h +++ b/arch/arm/mach-at91/pm.h @@ -40,6 +40,13 @@ struct at91_pm_data { unsigned int pmc_mckr_offset; unsigned int pmc_version; }; + +#include + +extern const match_table_t pm_modes; + +int at91_pm_common_modes_select(char *str, int *standby_mode, int *suspend_mode); + #endif #endif diff --git a/arch/arm/mach-at91/pm_common.c b/arch/arm/mach-at91/pm_common.c new file mode 100644 index 000000000000..45b74fb0a211 --- /dev/null +++ b/arch/arm/mach-at91/pm_common.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include +#include + +#include "pm.h" + +const match_table_t pm_modes __initconst = { + { AT91_PM_STANDBY, "standby" }, + { AT91_PM_ULP0, "ulp0" }, + { AT91_PM_ULP0_FAST, "ulp0-fast" }, + { AT91_PM_ULP1, "ulp1" }, + { AT91_PM_BACKUP, "backup" }, + { -1, NULL }, +}; + +int at91_pm_common_modes_select(char *str, int *standby_mode, int *suspend_mode) +{ + char *s; + substring_t args[MAX_OPT_ARGS]; + int standby, suspend; + + if (!str) + return 0; + + s = strsep(&str, ","); + standby = match_token(s, pm_modes, args); + if (standby < 0) + return 0; + + suspend = match_token(str, pm_modes, args); + if (suspend < 0) + return 0; + + *standby_mode = standby; + *suspend_mode = suspend; + + return 0; +}