Skip to contentSkip to conversation

ARM: EXYNOS: Constify list of retention registers

PATCH In review Krzysztof Kozlowski 2 participants 8 messages Dec 10, 2016 – Dec 12, 2016

Subsystems (3)
lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

PATCH 1/7 ARM: EXYNOS: Constify list of retention registers

The list of retention registers (release_ret_regs field of struct exynos_pm_data and arrays with values) are not modified and can be made const to improve the const safeness.

---
 arch/arm/mach-exynos/suspend.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-exynos/suspend.c +4 -4
index 73df9f3ffbf7..d0e6ac7938f3 100644
@@ -55,7 +55,7 @@ struct exynos_wkup_irq {
 struct exynos_pm_data {
 	const struct exynos_wkup_irq *wkup_irq;
 	unsigned int wake_disable_mask;
-	unsigned int *release_ret_regs;
+	const unsigned int *release_ret_regs;
 
 	void (*pm_prepare)(void);
 	void (*pm_resume_prepare)(void);
@@ -93,7 +93,7 @@ static const struct exynos_wkup_irq exynos5250_wkup_irq[] = {
 	{ /* sentinel */ },
 };
 
-static unsigned int exynos_release_ret_regs[] = {
+static const unsigned int exynos_release_ret_regs[] = {
 	S5P_PAD_RET_MAUDIO_OPTION,
 	S5P_PAD_RET_GPIO_OPTION,
 	S5P_PAD_RET_UART_OPTION,
@@ -104,7 +104,7 @@ static unsigned int exynos_release_ret_regs[] = {
 	REG_TABLE_END,
 };
 
-static unsigned int exynos3250_release_ret_regs[] = {
+static const unsigned int exynos3250_release_ret_regs[] = {
 	S5P_PAD_RET_MAUDIO_OPTION,
 	S5P_PAD_RET_GPIO_OPTION,
 	S5P_PAD_RET_UART_OPTION,
@@ -117,7 +117,7 @@ static unsigned int exynos3250_release_ret_regs[] = {
 	REG_TABLE_END,
 };
 
-static unsigned int exynos5420_release_ret_regs[] = {
+static const unsigned int exynos5420_release_ret_regs[] = {
 	EXYNOS_PAD_RET_DRAM_OPTION,
 	EXYNOS_PAD_RET_MAUDIO_OPTION,
 	EXYNOS_PAD_RET_JTAG_OPTION,
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 2/7 ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init

The pointers to __iomem sysram and exynos_pm_data are set only during initcalls. Later the pointers itself are used only in read-only way so we can mark them __ro_after_init to increase code safeness.

---
 arch/arm/mach-exynos/exynos.c      | 4 ++--
 arch/arm/mach-exynos/mcpm-exynos.c | 2 +-
 arch/arm/mach-exynos/suspend.c     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-exynos/exynos.c +2 -2
index fa08ef99b4ad..a863f8ec0f7a 100644
@@ -36,8 +36,8 @@ static struct platform_device exynos_cpuidle = {
 	.id                = -1,
 };
 
-void __iomem *sysram_base_addr;
-void __iomem *sysram_ns_base_addr;
+void __iomem *sysram_base_addr __ro_after_init;
+void __iomem *sysram_ns_base_addr __ro_after_init;
 
 void __init exynos_sysram_init(void)
 {
arch/arm/mach-exynos/mcpm-exynos.c +1 -1
index f086bf615b29..038fd8c993d0 100644
@@ -32,7 +32,7 @@
 #define EXYNOS5420_USE_ARM_CORE_DOWN_STATE	BIT(29)
 #define EXYNOS5420_USE_L2_COMMON_UP_STATE	BIT(30)
 
-static void __iomem *ns_sram_base_addr;
+static void __iomem *ns_sram_base_addr __ro_after_init;
 
 /*
  * The common v7_exit_coherency_flush API could not be used because of the
arch/arm/mach-exynos/suspend.c +1 -1
index d0e6ac7938f3..339fe011d658 100644
@@ -64,7 +64,7 @@ struct exynos_pm_data {
 	int (*cpu_suspend)(unsigned long);
 };
 
-static const struct exynos_pm_data *pm_data;
+static const struct exynos_pm_data *pm_data __ro_after_init;
 
 static int exynos5420_cpu_state;
 static unsigned int exynos_pmu_spare3;
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH 3/7 ARM: s3c24xx: Constify few integer tables

In reply to Krzysztof Kozlowski

These arrays are not modified so they can be made const.

---
 arch/arm/mach-s3c24xx/bast-irq.c         | 4 ++--
 arch/arm/mach-s3c24xx/iotiming-s3c2410.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-s3c24xx/bast-irq.c +2 -2
index 2bb08961e934..ad8f4cd7c327 100644
@@ -44,7 +44,7 @@
 /* table of ISA irq nos to the relevant mask... zero means
  * the irq is not implemented
 */
-static unsigned char bast_pc104_irqmasks[] = {
+static const unsigned char bast_pc104_irqmasks[] = {
 	0,   /* 0 */
 	0,   /* 1 */
 	0,   /* 2 */
@@ -63,7 +63,7 @@ static unsigned char bast_pc104_irqmasks[] = {
 	0,   /* 15 */
 };
 
-static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
+static const unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
 
 static void
 bast_pc104_mask(struct irq_data *data)
arch/arm/mach-s3c24xx/iotiming-s3c2410.c +1 -1
index 65e5f9cb650f..b7970f1fa3d5 100644
@@ -249,7 +249,7 @@ static int s3c2410_calc_bank(struct s3c_cpufreq_config *cfg,
 	return 0;
 }
 
-static unsigned int tacc_tab[] = {
+static const unsigned int tacc_tab[] = {
 	[0]	= 1,
 	[1]	= 2,
 	[2]	= 3,
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

RFC 4/7 ARM: s3c64xx: Annotate external clock frequencies __ro_after_init

In reply to Krzysztof Kozlowski

The xtal_f and xusbxti_f static variables are modified only through __init accessors (like s3c64xx_set_xtal_freq()). Later these variables are used only in read-only way so we can mark them __ro_after_init to increase code safeness.

---

Looks safe, but not tested.

---
 arch/arm/mach-s3c64xx/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-s3c64xx/common.c +2 -1
index 7c66ce1a6bb6..9843eb4dd04e 100644
@@ -56,7 +56,8 @@
 #include "watchdog-reset.h"
 
 /* External clock frequency */
-static unsigned long xtal_f = 12000000, xusbxti_f = 48000000;
+static unsigned long xtal_f __ro_after_init = 12000000;
+static unsigned long xusbxti_f __ro_after_init = 48000000;
 
 void __init s3c64xx_set_xtal_freq(unsigned long freq)
 {
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH 5/7 ARM: SAMSUNG: Constify array of wake irqs passed to samsung_sync_wakemask

In reply to Krzysztof Kozlowski

The samsung_sync_wakemask() iterates over passed array of wake irqs but does not modify it.

---
 arch/arm/plat-samsung/include/plat/wakeup-mask.h | 2 +-
 arch/arm/plat-samsung/wakeup-mask.c              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/include/plat/wakeup-mask.h +1 -1
index 43e4acd2e1c6..bbfa84b0505a 100644
@@ -38,7 +38,7 @@ struct samsung_wakeup_mask {
  * required to be correct before we enter sleep.
  */
 extern void samsung_sync_wakemask(void __iomem *reg,
-				  struct samsung_wakeup_mask *masks,
+				  const struct samsung_wakeup_mask *masks,
 				  int nr_masks);
 
 #endif /* __PLAT_WAKEUP_MASK_H */
arch/arm/plat-samsung/wakeup-mask.c +1 -1
index 20c3d9117cc2..b9de6b543330 100644
@@ -20,7 +20,7 @@
 #include <plat/pm.h>
 
 void samsung_sync_wakemask(void __iomem *reg,
-			   struct samsung_wakeup_mask *mask, int nr_mask)
+			   const struct samsung_wakeup_mask *mask, int nr_mask)
 {
 	struct irq_data *data;
 	u32 val;
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

PATCH 6/7 ARM: s3c24xx: Constify wake_irqs

In reply to Krzysztof Kozlowski

samsung_sync_wakemask() accepts pointer to const data so wake_irqs can be made const to increase safeness.

---
 arch/arm/mach-s3c24xx/pm-s3c2412.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-s3c24xx/pm-s3c2412.c +1 -1
index d75f95e487ee..0ae4d47a4663 100644
@@ -53,7 +53,7 @@ static int s3c2412_cpu_suspend(unsigned long arg)
 }
 
 /* mapping of interrupts to parts of the wakeup mask */
-static struct samsung_wakeup_mask wake_irqs[] = {
+static const struct samsung_wakeup_mask wake_irqs[] = {
 	{ .irq = IRQ_RTC,	.bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
 };
 
Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH 7/7 ARM: s3c64xx: Constify wake_irqs

In reply to Krzysztof Kozlowski

samsung_sync_wakemask() accepts pointer to const data so wake_irqs can be made const to increase safeness.

---
 arch/arm/mach-s3c64xx/pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-s3c64xx/pm.c +1 -1
index 59d91b83b03d..b0be382ff6bb 100644
@@ -285,7 +285,7 @@ static int s3c64xx_cpu_suspend(unsigned long arg)
 }
 
 /* mapping of interrupts to parts of the wakeup mask */
-static struct samsung_wakeup_mask wake_irqs[] = {
+static const struct samsung_wakeup_mask wake_irqs[] = {
 	{ .irq = IRQ_RTC_ALARM,	.bit = S3C64XX_PWRCFG_RTC_ALARM_DISABLE, },
 	{ .irq = IRQ_RTC_TIC,	.bit = S3C64XX_PWRCFG_RTC_TICK_DISABLE, },
 	{ .irq = IRQ_PENDN,	.bit = S3C64XX_PWRCFG_TS_DISABLE, },
Signature · 1 line
2.7.4
Reviewed-by on v1 1/7
#7 lore raw
In reply to Krzysztof Kozlowski

Hi,

Quoted 5 lines · Krzysztof Kozlowski

The list of retention registers (release_ret_regs field of struct exynos_pm_data and arrays with values) are not modified and can be made const to improve the const safeness.

for patches #1-7

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics