From 53f205df15e25f2de40972c8d8cb409557b4005d Mon Sep 17 00:00:00 2001
From: Simon Shields <simon@lineageos.org>
Date: Sun, 29 Apr 2018 23:30:34 +1000
Subject: [PATCH] build fixes/cleanups for modern GCC

---
 arch/arm/include/asm/io.h                    | 12 +--
 arch/arm/lib/board.c                         | 18 ++--
 board/samsung/smdk4212/clock_init_smdk4212.S |  6 +-
 board/samsung/smdk4212/lowlevel_init.S       | 62 +++++++-------
 board/samsung/smdk4212/mem_init_smdk4212.S   | 86 ++++++++++----------
 common/main.c                                |  2 +-
 common/usb.c                                 |  2 +-
 tools/Makefile                               |  4 +-
 8 files changed, 98 insertions(+), 94 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index a7c46857e..c910d72ed 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -77,42 +77,42 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 #define __arch_putw(v,a)		(*(volatile unsigned short *)(a) = (v))
 #define __arch_putl(v,a)		(*(volatile unsigned int *)(a) = (v))
 
-extern inline void __raw_writesb(unsigned int addr, const void *data, int bytelen)
+static inline void __raw_writesb(unsigned int addr, const void *data, int bytelen)
 {
 	uint8_t *buf = (uint8_t *)data;
 	while(bytelen--)
 		__arch_putb(*buf++, addr);
 }
 
-extern inline void __raw_writesw(unsigned int addr, const void *data, int wordlen)
+static inline void __raw_writesw(unsigned int addr, const void *data, int wordlen)
 {
 	uint16_t *buf = (uint16_t *)data;
 	while(wordlen--)
 		__arch_putw(*buf++, addr);
 }
 
-extern inline void __raw_writesl(unsigned int addr, const void *data, int longlen)
+static inline void __raw_writesl(unsigned int addr, const void *data, int longlen)
 {
 	uint32_t *buf = (uint32_t *)data;
 	while(longlen--)
 		__arch_putl(*buf++, addr);
 }
 
-extern inline void __raw_readsb(unsigned int addr, void *data, int bytelen)
+static inline void __raw_readsb(unsigned int addr, void *data, int bytelen)
 {
 	uint8_t *buf = (uint8_t *)data;
 	while(bytelen--)
 		*buf++ = __arch_getb(addr);
 }
 
-extern inline void __raw_readsw(unsigned int addr, void *data, int wordlen)
+static inline void __raw_readsw(unsigned int addr, void *data, int wordlen)
 {
 	uint16_t *buf = (uint16_t *)data;
 	while(wordlen--)
 		*buf++ = __arch_getw(addr);
 }
 
-extern inline void __raw_readsl(unsigned int addr, void *data, int longlen)
+static inline void __raw_readsl(unsigned int addr, void *data, int longlen)
 {
 	uint32_t *buf = (uint32_t *)data;
 	while(longlen--)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 122ac1be2..a4ddb6c3d 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -92,23 +92,23 @@ extern void rtl8019_get_enetaddr (uchar * addr);
  ************************************************************************
  * May be supplied by boards if desired
  */
-void inline __coloured_LED_init (void) {}
+void __coloured_LED_init (void) {}
 void coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));
-void inline __red_LED_on (void) {}
+void __red_LED_on (void) {}
 void red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));
-void inline __red_LED_off(void) {}
+void __red_LED_off(void) {}
 void red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));
-void inline __green_LED_on(void) {}
+void __green_LED_on(void) {}
 void green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));
-void inline __green_LED_off(void) {}
+void __green_LED_off(void) {}
 void green_LED_off(void) __attribute__((weak, alias("__green_LED_off")));
-void inline __yellow_LED_on(void) {}
+void __yellow_LED_on(void) {}
 void yellow_LED_on(void) __attribute__((weak, alias("__yellow_LED_on")));
-void inline __yellow_LED_off(void) {}
+void __yellow_LED_off(void) {}
 void yellow_LED_off(void) __attribute__((weak, alias("__yellow_LED_off")));
-void inline __blue_LED_on(void) {}
+void __blue_LED_on(void) {}
 void blue_LED_on(void) __attribute__((weak, alias("__blue_LED_on")));
-void inline __blue_LED_off(void) {}
+void __blue_LED_off(void) {}
 void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off")));
 
 /************************************************************************
diff --git a/board/samsung/smdk4212/clock_init_smdk4212.S b/board/samsung/smdk4212/clock_init_smdk4212.S
index f3bd26d02..eee7208fe 100644
--- a/board/samsung/smdk4212/clock_init_smdk4212.S
+++ b/board/samsung/smdk4212/clock_init_smdk4212.S
@@ -9,7 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
- 
+
 #include <config.h>
 #include <asm/arch/cpu.h>
 
@@ -28,7 +28,7 @@
 	.globl system_clock_init
 system_clock_init:
 	push	{lr}
-	
+
 	ldr	r0, =ELFIN_CLOCK_BASE	@0x1003_0000
 
 @ CMU_CPU MUX / DIV
@@ -251,7 +251,7 @@ skip_mpll:
 	ldr	r1, =0x00000084
 	ldr	r2, =DMC_PHYCONTROL1
 	str	r1, [r0, r2]
-	
+
 	/* wait ?us */
 	mov	r1, #0x20000
 11:	subs	r1, r1, #1
diff --git a/board/samsung/smdk4212/lowlevel_init.S b/board/samsung/smdk4212/lowlevel_init.S
index c90bcd83e..4933d7061 100644
--- a/board/samsung/smdk4212/lowlevel_init.S
+++ b/board/samsung/smdk4212/lowlevel_init.S
@@ -9,7 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
- 
+
 #include <config.h>
 #include <version.h>
 #include <asm/arch/cpu.h>
@@ -38,9 +38,9 @@ lowlevel_init:
 	ldr r1, [r0]
 	orr r1, r1, #0xF
 	str r1, [r0]
-	
-	mov r1, #0	
-	/* S5P_CMU_RESET_ISP_SYS */   
+
+	mov r1, #0
+	/* S5P_CMU_RESET_ISP_SYS */
 	ldr r0, =0x10021174
 	str r1, [r0]
 	/* S5P_CMU_SYSCLK_ISP_SYS */
@@ -50,25 +50,25 @@ lowlevel_init:
 	/* check reset status  */
 	ldr     r0, =(INF_REG_BASE + INF_REG1_OFFSET)
 	ldr     r1, [r0]
-	
+
 	/* Sleep wakeup reset */
 	ldr	r2, =S5P_CHECK_SLEEP
 	cmp	r1, r2
-	beq	wakeup_reset	
+	beq	wakeup_reset
+
 
-	
 	/* PS-Hold high */
 	ldr	r0, =0x1002330c
 	ldr	r1, [r0]
 	orr	r1, r1, #0x300
 	str	r1, [r0]
-	
+
 	bl uart_asm_init
-	
+
 #if defined(CONFIG_ONENAND)
 	bl onenandcon_init
 #endif
-	
+
 #if defined(NAND_BOOTING)
 	bl nand_asm_init
 #endif
@@ -86,13 +86,17 @@ lowlevel_init:
 	cmp r1, r2			/* compare r0, r1 */
 	beq after_copy		/* r0 == r1 then skip sdram init and u-boot.bin loading */
 
-#ifndef CONFIG_SMDKC220
+    ldr r3, =0x10020800
+    str r1, [r3]
+
+#ifndef CONFIG_SMDKC220 /*
 	ldr	r0, =CHIP_ID_BASE
 	ldr	r1, [r0]
 	lsr r1, r1, #8
 	and r1, r1, #3
 	cmp r1, #2
 	bne v310_1
+*/
 #endif
 
 	/* Memory initialize */
@@ -158,12 +162,12 @@ after_copy:
 	bl uart_putc
 	mov	r0, #0xD
 	bl uart_putc
-/*	
+/*
 	mov r6, #0
 	ldr r5, =(TZSW_MEM_ADDR+0x5500)
 1:
 	ldrb r4, [r5, r6]
-	
+
 	UBFX    R0, R4, #4, #4
 	CMP     R0, #10
 	ADDCC   R0, R0, #48
@@ -180,12 +184,12 @@ after_copy:
 	add r6, #1
 	cmp r6, #8
 	ble 1b
-	
+
 	mov r6, #0
 	ldr r5, =(TZSW_MEM_ADDR)
 1:
 	ldrb r4, [r5, r6]
-	
+
 	UBFX    R0, R4, #4, #4
 	CMP     R0, #10
 	ADDCC   R0, R0, #48
@@ -216,7 +220,7 @@ after_copy:
 
 #ifdef CONFIG_TRUSTZONE
 board_init_wrapper:
-	msr	cpsr, #0xd3	
+	msr	cpsr, #0xd3
 	mov r0, #0
 	mcr	p15, 0, r0, c8, c7, 0 /* Write TLBIALL - Invalidate entire Unified TLB */
 	mcr	p15, 0, r0, c7, c5, 0 /* Write ICIALLU - Invalidate Instruction Cache */
@@ -242,7 +246,7 @@ _second_boot_info:
 uart_putc:
 	mov r2, r0
 	ldr	r0, =S5PV310_UART_CONSOLE_BASE
-1:	
+1:
 	ldr r1, [R0, #UTRSTAT_OFFSET]
 	and r1, r1, #0x2
 	cmp r1, #0
@@ -298,7 +302,7 @@ wakeup_reset:
 	and r1, r1, #1
 	cmp r1, #0
 	bne skip_dmc
-	
+
 	/* init system clock */
 	bl	mem_ctrl_asm_init
 skip_dmc:
@@ -374,7 +378,7 @@ read_om:
 
 	ldr	r0, =INF_REG_BASE
 	str	r3, [r0, #INF_REG3_OFFSET]
-	
+
 	mov	pc, lr
 
 
@@ -557,7 +561,7 @@ tzasc_init:
 	mov r1, #0xF0000000
 	mov r2, #0xC0000027
 	ldr r3, =0x7FF00000
-	
+
 	ldr r0, =ELFIN_TZASC_LR_BASE
 	str r1, [r0, #TZASC_RA0_OFFSET]
 	str r2, [r0, #TZASC_RA3_OFFSET]
@@ -574,9 +578,9 @@ tzasc_init:
 	str r1, [r0, #TZASC_RA0_OFFSET]
 	str r2, [r0, #TZASC_RA3_OFFSET]
 	str r3, [r0, #TZASC_RSL3_OFFSET]
-	
+
 	mov pc, lr
-	
+
 /*
  * Setting TZPC[TrustZone Protection Controller]
  */
@@ -587,11 +591,11 @@ tzpc_init:
 	mov	r1, #0x2f
 	str	r1, [r0]
 	mov	r1, #0xff
-	str	r1, [r0, #TZPC_DECPROT0SET_OFFSET]	
+	str	r1, [r0, #TZPC_DECPROT0SET_OFFSET]
 	mov	r1, #0x3
 	str	r1, [r0, #TZPC_DECPROT1CLR_OFFSET]
 	mov	r1, #0xfc
-	str	r1, [r0, #TZPC_DECPROT1SET_OFFSET]	
+	str	r1, [r0, #TZPC_DECPROT1SET_OFFSET]
 	mov r1, #0xff
 	str	r1, [r0, #TZPC_DECPROT2SET_OFFSET]
 	str	r1, [r0, #TZPC_DECPROT3SET_OFFSET]
@@ -606,7 +610,7 @@ tzpc_init:
 	str	r1, [r0, #TZPC_DECPROT0SET_OFFSET]
 	str	r1, [r0, #TZPC_DECPROT1SET_OFFSET]
 	str	r1, [r0, #TZPC_DECPROT2SET_OFFSET]
-	str	r1, [r0, #TZPC_DECPROT3SET_OFFSET] 
+	str	r1, [r0, #TZPC_DECPROT3SET_OFFSET]
 
 	ldr	r0, =ELFIN_TZPC3_BASE
 	str	r1, [r0, #TZPC_DECPROT0SET_OFFSET]
@@ -649,7 +653,7 @@ mmc_ch4_devider_change:
 	mov	pc, lr
 
 
-	
+
 /*
  * Nand Interface Init for SMDKC100
  */
@@ -665,7 +669,7 @@ nand_asm_init:
         bic     r1, r1, #(0xf<<8)
         orr     r1, r1, #(0x3<<8)
         str     r1, [r0, #MP01CON_OFFSET]
-	
+
 	ldr	r2, =0x220300
 	str	r2, [r0, #MP01CON_OFFSET]
 
@@ -800,7 +804,7 @@ mmu_table:
 	FL_SECTION_ENTRY __base,3,0,1,1
 	.set __base,__base+1
 	.endr
-	
+
 	// access is not allowed.
 	.rept 0xc00 - 0x600
 	.word 0x00000000
@@ -817,7 +821,7 @@ mmu_table:
 	.rept 0x1000 - 0xE00
 	.word 0x00000000
 	.endr
-	
+
 #endif
 
 
diff --git a/board/samsung/smdk4212/mem_init_smdk4212.S b/board/samsung/smdk4212/mem_init_smdk4212.S
index a7d3e8b9a..2cd6bc245 100644
--- a/board/samsung/smdk4212/mem_init_smdk4212.S
+++ b/board/samsung/smdk4212/mem_init_smdk4212.S
@@ -9,7 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
- 
+
 #include <config.h>
 #include <asm/arch/cpu.h>
 
@@ -31,42 +31,42 @@ mem_ctrl_asm_init:
 /*DREX0***********************************************************/
 /*****************************************************************/
 
-	ldr	r0, =APB_DMC_0_BASE 
+	ldr	r0, =APB_DMC_0_BASE
 
 	ldr	r1, =0xE3855403
 	str	r1, [r0, #DMC_PHYZQCONTROL]
 
-	ldr	r1, =0x71101008				
+	ldr	r1, =0x71101008
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x7110100A				
+	ldr	r1, =0x7110100A
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x71101008				
+	ldr	r1, =0x71101008
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x0000008C				
+	ldr	r1, =0x0000008C
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x0000008C				
+	ldr	r1, =0x0000008C
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
 	ldr	r1, =0x0FFF30CA
 	str	r1, [r0, #DMC_CONCONTROL]
 
-	ldr	r1, =0x00202500				
+	ldr	r1, =0x00202500
 	str	r1, [r0, #DMC_MEMCONTROL]
 
-	ldr	r1, =0x40C01323	
+	ldr	r1, =0x40C01323
 	str	r1, [r0, #DMC_MEMCONFIG0]
 
 	ldr	r1, =(0x80000000 | CONFIG_IV_SIZE)
@@ -75,33 +75,33 @@ mem_ctrl_asm_init:
 #ifdef CONFIG_EVT0_RECOMMEND
 	ldr	r1, =0x6400ffff
 #else
-	ldr	r1, =0x64000000			
+	ldr	r1, =0x64000000
 #endif
 	str	r1, [r0, #DMC_PRECHCONFIG]
 
-	ldr	r1, =0x9C4000FF			
+	ldr	r1, =0x9C4000FF
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x0000005D    				
+	ldr	r1, =0x0000005D
 	str	r1, [r0, #DMC_TIMINGAREF] @TimingAref
 
 #ifdef MCLK_330
-	ldr	r1, =0x2b47654e				
+	ldr	r1, =0x2b47654e
 	str	r1, [r0, #DMC_TIMINGROW]
-	ldr	r1, =0x35330306			
+	ldr	r1, =0x35330306
 	str	r1, [r0, #DMC_TIMINGDATA]
-	ldr	r1, =0x442f0365				
+	ldr	r1, =0x442f0365
 	str	r1, [r0, #DMC_TIMINGPOWER]
 #else
 #ifdef CONFIG_EVT0_RECOMMEND
 	ldr	r1, =0x34A98691
 #else
-	ldr	r1, =0x34498691  
+	ldr	r1, =0x34498691
 #endif
 	str	r1, [r0, #DMC_TIMINGROW] @TimingRow
-	ldr	r1, =0x36330306    				
+	ldr	r1, =0x36330306
 	str	r1, [r0, #DMC_TIMINGDATA] @TimingData
-	ldr	r1, =0x50380365    				
+	ldr	r1, =0x50380365
 	str	r1, [r0, #DMC_TIMINGPOWER] @TimingPower
 #endif
 
@@ -109,66 +109,66 @@ mem_ctrl_asm_init:
 2:	subs	r2, r2, #1
 	bne	2b
 
-	ldr	r1, =0x07000000       				
-	str	r1, [r0, #DMC_DIRECTCMD] 
+	ldr	r1, =0x07000000
+	str	r1, [r0, #DMC_DIRECTCMD]
 
 	mov	r2, #0x100000
 3:	subs	r2, r2, #1
 	bne	3b
 
-	ldr	r1, =0x00071C00       				
+	ldr	r1, =0x00071C00
 	str	r1, [r0, #DMC_DIRECTCMD]
 
 	mov	r2, #0x100000
 4:	subs	r2, r2, #1
 	bne	4b
 
-	ldr	r1, =0x00010BFC       				
-	str	r1, [r0, #DMC_DIRECTCMD] 
+	ldr	r1, =0x00010BFC
+	str	r1, [r0, #DMC_DIRECTCMD]
 
 	mov	r2, #0x100000
 5:	subs	r2, r2, #1
 	bne	5b
 
 	ldr	r1, =0x00000608
-	str	r1, [r0, #DMC_DIRECTCMD] 
-	ldr	r1, =0x00000810       				
-	str	r1, [r0, #DMC_DIRECTCMD] 
-	ldr	r1, =0x00000C08       				
-	str	r1, [r0, #DMC_DIRECTCMD] 
+	str	r1, [r0, #DMC_DIRECTCMD]
+	ldr	r1, =0x00000810
+	str	r1, [r0, #DMC_DIRECTCMD]
+	ldr	r1, =0x00000C08
+	str	r1, [r0, #DMC_DIRECTCMD]
 
 /*****************************************************************/
 /*DREX1***********************************************************/
 /*****************************************************************/
 	ldr	r0, =APB_DMC_1_BASE
 
-	ldr	r1, =0xE3855403			
+	ldr	r1, =0xE3855403
 	str	r1, [r0, #DMC_PHYZQCONTROL]
 
-	ldr	r1, =0x71101008				
+	ldr	r1, =0x71101008
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x7110100A				
+	ldr	r1, =0x7110100A
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x71101008				
+	ldr	r1, =0x71101008
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
-	ldr	r1, =0x0000008C				
+	ldr	r1, =0x0000008C
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x0000008C				
+	ldr	r1, =0x0000008C
 	str	r1, [r0, #DMC_PHYCONTROL1]
 
-	ldr	r1, =0x00000084				
+	ldr	r1, =0x00000084
 	str	r1, [r0, #DMC_PHYCONTROL1]
-	
+
 	ldr	r1, =0x0FFF30CA
 	str	r1, [r0, #DMC_CONCONTROL]
 
@@ -188,7 +188,7 @@ mem_ctrl_asm_init:
 #endif
 	str	r1, [r0, #DMC_PRECHCONFIG]
 
-	ldr	r1, =0x9C4000FF			
+	ldr	r1, =0x9C4000FF
 	str	r1, [r0, #DMC_PHYCONTROL0]
 
 	ldr	r1, =0x0000005D
@@ -205,7 +205,7 @@ mem_ctrl_asm_init:
 #ifdef CONFIG_EVT0_RECOMMEND
 	ldr	r1, =0x34A98691
 #else
-	ldr	r1, =0x34498691  
+	ldr	r1, =0x34498691
 #endif
 	str	r1, [r0, #DMC_TIMINGROW] @TimingRow
 	ldr	r1, =0x36330306
diff --git a/common/main.c b/common/main.c
index d97ccd7dd..851949811 100644
--- a/common/main.c
+++ b/common/main.c
@@ -47,7 +47,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /*
  * Board-specific Platform code can reimplement show_boot_progress () if needed
  */
-void inline __show_boot_progress (int val) {}
+void __show_boot_progress (int val) {}
 void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
 
 #if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
diff --git a/common/usb.c b/common/usb.c
index 10e23de6a..e64e978c1 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -87,7 +87,7 @@ static int hub_port_reset(struct usb_device *dev, int port,
  * wait_ms
  */
 
-inline void wait_ms(unsigned long ms)
+void wait_ms(unsigned long ms)
 {
 	while (ms-- > 0)
 		udelay(1000);
diff --git a/tools/Makefile b/tools/Makefile
index 623f9086f..f1c8624fe 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -60,9 +60,9 @@ BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
 BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
 BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
-BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
+#BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
 BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
-BIN_FILES-y += mkimage$(SFX)
+#BIN_FILES-y += mkimage$(SFX)
 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
 
-- 
2.17.0

