[PATCH 2/4] ARM: at91: pm: move "atmel.pm_modes" parsing into a common file
Clément Léger
clement.leger at bootlin.com
Tue Feb 22 07:08:44 PST 2022
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 <clement.leger at bootlin.com>
---
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 <linux/parser.h>
+
+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 <linux/kernel.h>
+#include <linux/parser.h>
+#include <linux/string.h>
+
+#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;
+}
--
2.34.1
More information about the linux-arm-kernel
mailing list