Fixes for new ARC toolchain

Compilation issues detected with gcc 4.8.5 + uclibc 1.0.16.

arch/arc/Makefile:
  from upstream Linux 4.7
  - disable -fasynchronous-unwind-tables
  - force -gdwarf-2

arch/arc/boot/Makefile:
  from upstream Linux 4.7
  - add -R .note.gnu.build-id to objcopy flags
  - without this, objcopy creates non-working 2GB Image

arch/arc/include/asm/bitops.h:
  from upstream Linux 4.7
  - fix {set,clear,change}_bit and test_and_{set,clear,change}_bit
  - new assembler is not happy about the old asm code

arch/arc/include/asm/irqflags.h:
  - old assembler had built-in constant 'auxienable'
  - new assembler has built-in constant 'aux_ienable'
  - use the actual value 0x40c here, so this works on both

arch/arc/proc/arc700/entry.S:
  - fix off-by-one error with the number of syscalls
    - NR_syscalls == 354
    - (__syscall_end - __syscall_start) / 4 == 355
  - new assembler is not happy about it

arch/arc/proc/arc700/head.S:
  - fix syntax errors in mov instructions
  - new assembler is not happy about them

drivers/ruby/iputil.c:
  - remove unused but set variable 'donez'

drivers/topaz/hbm.c:
  - fix unused but set variable 'rc'

NOTE:
These changes are valid and working for the old toolchain as well.

Change-Id: I9b9d99178880e14047119be33dcc7a596ed8efc5
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index f6024b9..12c6907 100755
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -61,7 +61,8 @@
 KBUILD_CFLAGS	+= $(shell if [ $(call cc-version, $(CC)) -gt 0400 ] ; then echo $(call cc-option,-mno-sdata); fi ;)
 
 ifdef CONFIG_ARC_STACK_UNWIND
-KBUILD_CFLAGS		+= -fasynchronous-unwind-tables
+# KBUILD_CFLAGS		+= -fasynchronous-unwind-tables
+KBUILD_CFLAGS		+= -gdwarf-2
 endif
 
 LINUXINCLUDE +=  -include ${src}/arch/arc/include/asm/defines.h \
diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index 4c4e272..58dfc7c 100755
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -14,7 +14,7 @@
 
 MKIMAGE =mkimage
 MKIMAGEFLAGS =-A arc -O linux -C none  -T kernel -a 0x80000000 -e 0x80002000 -n "ARC700 Linux kernel" -d Image
-OBJCOPYFLAGS =-O binary -R .note -R .comment -S vmlinux
+OBJCOPYFLAGS =-O binary -R .note -R .note.gnu.build-id -R .comment -S vmlinux
 
 # From Beta's doc:
 # ZTEXTADDR - Address where zImage is located by the bootloader
diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index aa2757f..f6b1c0c 100755
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -178,14 +178,13 @@
     unsigned long temp, flags;
     m += nr >> 5;
 
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
+
     bitops_lock(flags);
 
-    __asm__ __volatile__(
-    "   ld%U3 %0,%3\n\t"
-    "   bset %0,%0,%2\n\t"
-    "   st%U1 %0,%1\n\t"
-    :"=&r" (temp), "=o" (*m)
-    :"ir" (nr), "m" (*m));
+    temp = *m;
+    *m = temp | (1UL << nr);
 
     bitops_unlock(flags);
 }
@@ -195,14 +194,13 @@
     unsigned long temp, flags;
     m += nr >> 5;
 
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
+
     bitops_lock(flags);
 
-    __asm__ __volatile__(
-       "    ld%U3 %0,%3\n\t"
-       "    bclr %0,%0,%2\n\t"
-       "    st%U1 %0,%1\n\t"
-       :"=&r" (temp), "=o" (*m)
-       :"ir" (nr), "m" (*m));
+    temp = *m;
+    *m = temp & ~(1UL << nr);
 
     bitops_unlock(flags);
 }
@@ -212,14 +210,13 @@
     unsigned long temp, flags;
     m += nr >> 5;
 
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
+
     bitops_lock(flags);
 
-    __asm__ __volatile__(
-       "    ld%U3 %0,%3\n\t"
-       "    bxor %0,%0,%2\n\t"
-       "    st%U1 %0,%1\n\t"
-       :"=&r" (temp), "=o" (*m)
-       :"ir" (nr), "m" (*m));
+    temp = *m;
+    *m = temp ^ (1UL << nr);
 
     bitops_unlock(flags);
 }
@@ -228,24 +225,19 @@
 static inline int
 test_and_set_bit(unsigned long nr, volatile unsigned long *m)
 {
-    unsigned long old, temp, flags;
+    unsigned long old, flags;
     m += nr >> 5;
-    // int old = *m; This is wrong, we are reading data before getting lock
+
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
 
     bitops_lock(flags);
 
     old = *m;
-
-    __asm__ __volatile__(
-       "    bset  %0,%3,%2\n\t"
-       "    st%U1 %0,%1\n\t"
-       :"=r" (temp), "=o" (*m)
-       :"ir" (nr), "r"(old));
+    *m = old | (1 << nr);
 
     bitops_unlock(flags);
 
-    if (__builtin_constant_p(nr)) nr &= 0x1f;
-
     return (old & (1 << nr)) != 0;
 }
 
@@ -253,23 +245,19 @@
 static inline int
 test_and_clear_bit(unsigned long nr, volatile unsigned long *m)
 {
-    unsigned long temp, old, flags;
+    unsigned long old, flags;
     m += nr >> 5;
 
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
+
     bitops_lock(flags);
 
     old = *m;
-
-    __asm__ __volatile__(
-       "    bclr  %0,%3,%2\n\t"
-       "    st%U1 %0,%1\n\t"
-       :"=r" (temp), "=o" (*m)
-       :"ir" (nr), "r"(old));
+    *m = old & ~(1 << nr);
 
     bitops_unlock(flags);
 
-    if (__builtin_constant_p(nr)) nr &= 0x1f;
-
     return (old & (1 << nr)) != 0;
 }
 
@@ -277,23 +265,19 @@
 static inline int
 test_and_change_bit(unsigned long nr, volatile unsigned long *m)
 {
-    unsigned long temp, old, flags;
+    unsigned long old, flags;
     m += nr >> 5;
 
+    if (__builtin_constant_p(nr))
+        nr &= 0x1f;
+
     bitops_lock(flags);
 
     old = *m;
-
-    __asm__ __volatile__(
-       "    bxor %0,%3,%2\n\t"
-       "    st%U1 %0,%1\n\t"
-       :"=r" (temp), "=o" (*m)
-       :"ir" (nr), "r"(old));
+    *m = old ^ (1 << nr);
 
     bitops_unlock(flags);
 
-    if (__builtin_constant_p(nr)) nr &= 0x1f;
-
     return (old & (1 << nr)) != 0;
 }
 
diff --git a/arch/arc/include/asm/irqflags.h b/arch/arc/include/asm/irqflags.h
index 507c800..636528c 100644
--- a/arch/arc/include/asm/irqflags.h
+++ b/arch/arc/include/asm/irqflags.h
@@ -117,17 +117,17 @@
  */
 
 #define mask_interrupt(x)  __asm__ __volatile__ (   \
-    "lr r20, [auxienable] \n\t"                     \
+    "lr r20, [0x40c] \n\t"                     \
     "and    r20, r20, %0 \n\t"                      \
-    "sr     r20,[auxienable] \n\t"                  \
+    "sr     r20,[0x40c] \n\t"                  \
     :                                               \
     :"r" (~(x))                                     \
     :"r20", "memory")
 
 #define unmask_interrupt(x)  __asm__ __volatile__ ( \
-    "lr r20, [auxienable] \n\t"                     \
+    "lr r20, [0x40c] \n\t"                     \
     "or     r20, r20, %0 \n\t"                      \
-    "sr     r20, [auxienable] \n\t"                 \
+    "sr     r20, [0x40c] \n\t"                 \
     :                                               \
     :"r" (x)                                        \
     :"r20", "memory")
diff --git a/arch/arc/proc/arc700/entry.S b/arch/arc/proc/arc700/entry.S
index fb8af28..76cfecc 100755
--- a/arch/arc/proc/arc700/entry.S
+++ b/arch/arc/proc/arc700/entry.S
@@ -929,8 +929,8 @@
 ; The syscall table starts here...
 .data
 ARC_ENTRY sys_call_table
-__syscall_start:
   /* 0 */   .long   SYMBOL_NAME(sys_ni_syscall)
+__syscall_start:
         .long   SYMBOL_NAME(sys_exit)
         .long   SYMBOL_NAME(sys_fork_wrapper)
         .long   SYMBOL_NAME(sys_read)
diff --git a/arch/arc/proc/arc700/head.S b/arch/arc/proc/arc700/head.S
index 2315c3c..2e2973d 100755
--- a/arch/arc/proc/arc700/head.S
+++ b/arch/arc/proc/arc700/head.S
@@ -68,7 +68,7 @@
 ; u-boot passes the command line variable at the beginning of BSS
 ; copy the first few bytes out of the BSS into the command_line variable.
 
-    mov r5, [SYMBOL_NAME(command_line)]
+    mov r5, SYMBOL_NAME(command_line)
     mov r6, __bss_start
 
 __copy_commandline:
@@ -105,7 +105,7 @@
 
 #ifdef CONFIG_ARCH_ARC_CURR_IN_REG
     ; setup init_task as "current"
-    mov r25, [SYMBOL_NAME(init_task)]
+    mov r25, SYMBOL_NAME(init_task)
     st r25, [SYMBOL_NAME(_current_task)]
 #endif
 
diff --git a/drivers/ruby/iputil.c b/drivers/ruby/iputil.c
index 1c43200..d7ba4da 100644
--- a/drivers/ruby/iputil.c
+++ b/drivers/ruby/iputil.c
@@ -86,7 +86,6 @@
 	int bestzend = 0;
 	int bestzlen = 0;
 	int inz = 0;
-	int donez = 0;
 	const int addr16len = (int)(sizeof(struct in6_addr) / sizeof(uint16_t));
 
 	/* parse address, looking for longest substring of 0s */
@@ -135,7 +134,6 @@
 		} else if (bestzlen && (i == bestzend)) {
 			p += sprintf(p, "::");
 			inz = 0;
-			donez = 1;
 		} else if (inz) {
 		} else {
 			WARN_ONCE(1, "%s: implementation error", __FUNCTION__);
diff --git a/drivers/topaz/hbm.c b/drivers/topaz/hbm.c
index 25c9260..627bf0f 100644
--- a/drivers/topaz/hbm.c
+++ b/drivers/topaz/hbm.c
@@ -1044,14 +1044,15 @@
 
 	local_bh_enable();
 
-	out:
+	rc = count;
+out:
 	if (cmd) {
 		kfree(cmd);
 	}
 	if (words) {
 		kfree(words);
 	}
-	return count;
+	return rc;
 }
 
 static inline uint32_t hbm_get_rel_cnt(int pool)