linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers
@ 2016-12-10 13:47 Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 2/7] ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init Krzysztof Kozlowski
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 arch/arm/mach-exynos/suspend.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
index 73df9f3ffbf7..d0e6ac7938f3 100644
--- a/arch/arm/mach-exynos/suspend.c
+++ b/arch/arm/mach-exynos/suspend.c
@@ -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,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 3/7] ARM: s3c24xx: Constify few integer tables Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 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(-)

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index fa08ef99b4ad..a863f8ec0f7a 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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)
 {
diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c
index f086bf615b29..038fd8c993d0 100644
--- a/arch/arm/mach-exynos/mcpm-exynos.c
+++ b/arch/arm/mach-exynos/mcpm-exynos.c
@@ -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
diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
index d0e6ac7938f3..339fe011d658 100644
--- a/arch/arm/mach-exynos/suspend.c
+++ b/arch/arm/mach-exynos/suspend.c
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] ARM: s3c24xx: Constify few integer tables
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 2/7] ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-10 13:47 ` [RFC 4/7] ARM: s3c64xx: Annotate external clock frequencies __ro_after_init Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 arch/arm/mach-s3c24xx/bast-irq.c         | 4 ++--
 arch/arm/mach-s3c24xx/iotiming-s3c2410.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-s3c24xx/bast-irq.c b/arch/arm/mach-s3c24xx/bast-irq.c
index 2bb08961e934..ad8f4cd7c327 100644
--- a/arch/arm/mach-s3c24xx/bast-irq.c
+++ b/arch/arm/mach-s3c24xx/bast-irq.c
@@ -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)
diff --git a/arch/arm/mach-s3c24xx/iotiming-s3c2410.c b/arch/arm/mach-s3c24xx/iotiming-s3c2410.c
index 65e5f9cb650f..b7970f1fa3d5 100644
--- a/arch/arm/mach-s3c24xx/iotiming-s3c2410.c
+++ b/arch/arm/mach-s3c24xx/iotiming-s3c2410.c
@@ -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,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 4/7] ARM: s3c64xx: Annotate external clock frequencies __ro_after_init
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 2/7] ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 3/7] ARM: s3c24xx: Constify few integer tables Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 5/7] ARM: SAMSUNG: Constify array of wake irqs passed to samsung_sync_wakemask Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Looks safe, but not tested.
---
 arch/arm/mach-s3c64xx/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c64xx/common.c b/arch/arm/mach-s3c64xx/common.c
index 7c66ce1a6bb6..9843eb4dd04e 100644
--- a/arch/arm/mach-s3c64xx/common.c
+++ b/arch/arm/mach-s3c64xx/common.c
@@ -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)
 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] ARM: SAMSUNG: Constify array of wake irqs passed to samsung_sync_wakemask
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2016-12-10 13:47 ` [RFC 4/7] ARM: s3c64xx: Annotate external clock frequencies __ro_after_init Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 6/7] ARM: s3c24xx: Constify wake_irqs Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 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(-)

diff --git a/arch/arm/plat-samsung/include/plat/wakeup-mask.h b/arch/arm/plat-samsung/include/plat/wakeup-mask.h
index 43e4acd2e1c6..bbfa84b0505a 100644
--- a/arch/arm/plat-samsung/include/plat/wakeup-mask.h
+++ b/arch/arm/plat-samsung/include/plat/wakeup-mask.h
@@ -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 */
diff --git a/arch/arm/plat-samsung/wakeup-mask.c b/arch/arm/plat-samsung/wakeup-mask.c
index 20c3d9117cc2..b9de6b543330 100644
--- a/arch/arm/plat-samsung/wakeup-mask.c
+++ b/arch/arm/plat-samsung/wakeup-mask.c
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] ARM: s3c24xx: Constify wake_irqs
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2016-12-10 13:47 ` [PATCH 5/7] ARM: SAMSUNG: Constify array of wake irqs passed to samsung_sync_wakemask Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-10 13:47 ` [PATCH 7/7] ARM: s3c64xx: " Krzysztof Kozlowski
  2016-12-12 13:39 ` [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 arch/arm/mach-s3c24xx/pm-s3c2412.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c24xx/pm-s3c2412.c b/arch/arm/mach-s3c24xx/pm-s3c2412.c
index d75f95e487ee..0ae4d47a4663 100644
--- a/arch/arm/mach-s3c24xx/pm-s3c2412.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2412.c
@@ -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, },
 };
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/7] ARM: s3c64xx: Constify wake_irqs
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2016-12-10 13:47 ` [PATCH 6/7] ARM: s3c24xx: Constify wake_irqs Krzysztof Kozlowski
@ 2016-12-10 13:47 ` Krzysztof Kozlowski
  2016-12-12 13:39 ` [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2016-12-10 13:47 UTC (permalink / raw)
  To: Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski,
	Javier Martinez Canillas, Simtec Linux Team, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 arch/arm/mach-s3c64xx/pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c
index 59d91b83b03d..b0be382ff6bb 100644
--- a/arch/arm/mach-s3c64xx/pm.c
+++ b/arch/arm/mach-s3c64xx/pm.c
@@ -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, },
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers
  2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2016-12-10 13:47 ` [PATCH 7/7] ARM: s3c64xx: " Krzysztof Kozlowski
@ 2016-12-12 13:39 ` Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2016-12-12 13:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Sylwester Nawrocki, Kukjin Kim, Javier Martinez Canillas,
	Simtec Linux Team, linux-arm-kernel, linux-samsung-soc,
	linux-kernel


Hi,

On Saturday, December 10, 2016 03:47:32 PM Krzysztof Kozlowski wrote:
> 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.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

for patches #1-7

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-12 13:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-10 13:47 [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Krzysztof Kozlowski
2016-12-10 13:47 ` [PATCH 2/7] ARM: EXYNOS: Annotate iomem and pm_data pointers __ro_after_init Krzysztof Kozlowski
2016-12-10 13:47 ` [PATCH 3/7] ARM: s3c24xx: Constify few integer tables Krzysztof Kozlowski
2016-12-10 13:47 ` [RFC 4/7] ARM: s3c64xx: Annotate external clock frequencies __ro_after_init Krzysztof Kozlowski
2016-12-10 13:47 ` [PATCH 5/7] ARM: SAMSUNG: Constify array of wake irqs passed to samsung_sync_wakemask Krzysztof Kozlowski
2016-12-10 13:47 ` [PATCH 6/7] ARM: s3c24xx: Constify wake_irqs Krzysztof Kozlowski
2016-12-10 13:47 ` [PATCH 7/7] ARM: s3c64xx: " Krzysztof Kozlowski
2016-12-12 13:39 ` [PATCH 1/7] ARM: EXYNOS: Constify list of retention registers Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).