Merge changes I6c489eb4,I552b40c0

* changes:
  gralloc: do not use private_handle_t::ion_hnd
  gralloc: make fbdev fd a shallow copy
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index a14e233..a9dc47d 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -1,15 +1,15 @@
 # Primary Arch
 TARGET_ARCH := arm64
 TARGET_ARCH_VARIANT := armv8-a
-TARGET_CPU_VARIANT := generic
 TARGET_CPU_ABI := arm64-v8a
+TARGET_CPU_VARIANT := cortex-a53
 
 # Secondary Arch
 TARGET_2ND_ARCH := arm
 TARGET_2ND_ARCH_VARIANT := armv7-a-neon
-TARGET_2ND_CPU_VARIANT := cortex-a15
 TARGET_2ND_CPU_ABI := armeabi-v7a
 TARGET_2ND_CPU_ABI2 := armeabi
+TARGET_2ND_CPU_VARIANT := cortex-a53
 
 TARGET_USES_64_BIT_BINDER := true
 TARGET_SUPPORTS_32_BIT_APPS := true
@@ -26,7 +26,6 @@
 WPA_SUPPLICANT_VERSION := VER_0_8_X
 BOARD_WPA_SUPPLICANT_DRIVER := NL80211
 BOARD_HOSTAPD_DRIVER := NL80211
-CONFIG_DRIVER_NL80211 := y
 
 TARGET_NO_BOOTLOADER := true
 TARGET_NO_KERNEL := false
diff --git a/hikey.mk b/hikey.mk
index 40e1f8b..3174ba4 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -3,7 +3,7 @@
 endif
 TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image-dtb-$(TARGET_KERNEL_USE)
 TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi6220-hikey.dtb-$(TARGET_KERNEL_USE)
-ifeq ($(TARGET_KERNEL_USE), 4.1)
+ifeq ($(TARGET_KERNEL_USE), 3.18)
 TARGET_FSTAB := fstab.hikey-$(TARGET_KERNEL_USE)
 else
 TARGET_FSTAB := fstab.hikey
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index 5fb9b1e..df97048 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -1,14 +1,14 @@
 include device/linaro/hikey/BoardConfigCommon.mk
 
 TARGET_BOARD_PLATFORM := hikey
-ifeq ($(TARGET_KERNEL_USE), 4.1)
+ifeq ($(TARGET_KERNEL_USE), 3.18)
 BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
 else
 BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
 endif
 
 ## printk.devkmsg only has meaning for kernel 4.9 and later
-## it would be ignored by kernel 4.1 and kernel 4.4
+## it would be ignored by kernel 3.18 and kernel 4.4
 BOARD_KERNEL_CMDLINE += printk.devkmsg=on
 
 TARGET_NO_DTIMAGE := true
diff --git a/hikey/fstab.hikey-4.1 b/hikey/fstab.hikey-3.18
similarity index 100%
rename from hikey/fstab.hikey-4.1
rename to hikey/fstab.hikey-3.18
diff --git a/installer/hikey960/fastboot.img b/installer/hikey960/fastboot.img
index 18e53fd..3dcbc2a 100644
--- a/installer/hikey960/fastboot.img
+++ b/installer/hikey960/fastboot.img
Binary files differ
diff --git a/installer/hikey960/lpm3.img b/installer/hikey960/lpm3.img
index 92f590d..c35a193 100644
--- a/installer/hikey960/lpm3.img
+++ b/installer/hikey960/lpm3.img
Binary files differ
diff --git a/installer/hikey960/sec_xloader.img b/installer/hikey960/sec_xloader.img
index b44b6a1..84fa624 100644
--- a/installer/hikey960/sec_xloader.img
+++ b/installer/hikey960/sec_xloader.img
Binary files differ
diff --git a/wpan/uim/uim.c b/wpan/uim/uim.c
index a9dde00..7f78f0c 100644
--- a/wpan/uim/uim.c
+++ b/wpan/uim/uim.c
@@ -42,6 +42,12 @@
 char uim_bd_address[BD_ADDR_LEN];
 bdaddr_t *bd_addr;
 
+/* kim Sysfs path */
+static char *sysfs_install_entry = INSTALL_SYSFS_ENTRY;
+static char *sysfs_dev_name = DEV_NAME_SYSFS;
+static char *sysfs_baud_rate = BAUD_RATE_SYSFS;
+static char *sysfs_flow_ctrl = FLOW_CTRL_SYSFS;
+
 /*****************************************************************************/
 #ifdef UIM_DEBUG
 /*  Function to Read the firmware version
@@ -65,6 +71,14 @@
 }
 #endif
 
+void sysfs_entry_fallback(void)
+{
+	sysfs_install_entry = INSTALL_SYSFS_ENTRY_OLD;
+	sysfs_dev_name = DEV_NAME_SYSFS_OLD;
+	sysfs_baud_rate = BAUD_RATE_SYSFS_OLD;
+	sysfs_flow_ctrl = FLOW_CTRL_SYSFS_OLD;
+}
+
 /*****************************************************************************/
 /* Function to read the HCI event from the given file descriptor
  *
@@ -283,9 +297,9 @@
 
 	if (install == '1') {
 		memset(buf, 0, UART_DEV_NAME_LEN);
-		fd = open(DEV_NAME_SYSFS, O_RDONLY);
+		fd = open(sysfs_dev_name, O_RDONLY);
 		if (fd < 0) {
-			UIM_ERR("Can't open %s", DEV_NAME_SYSFS);
+			UIM_ERR("Can't open %s", sysfs_dev_name);
 			return -1;
 		}
 		len = read(fd, buf, UART_DEV_NAME_LEN);
@@ -298,9 +312,9 @@
 		close(fd);
 
 		memset(buf, 0, UART_DEV_NAME_LEN);
-		fd = open(BAUD_RATE_SYSFS, O_RDONLY);
+		fd = open(sysfs_baud_rate, O_RDONLY);
 		if (fd < 0) {
-			UIM_ERR("Can't open %s", BAUD_RATE_SYSFS);
+			UIM_ERR("Can't open %s", sysfs_baud_rate);
 			return -1;
 		}
 		len = read(fd, buf, UART_DEV_NAME_LEN);
@@ -313,9 +327,9 @@
 		sscanf((const char*)buf, "%d", &cust_baud_rate);
 
 		memset(buf, 0, UART_DEV_NAME_LEN);
-		fd = open(FLOW_CTRL_SYSFS, O_RDONLY);
+		fd = open(sysfs_flow_ctrl, O_RDONLY);
 		if (fd < 0) {
-			UIM_ERR("Can't open %s", FLOW_CTRL_SYSFS);
+			UIM_ERR("Can't open %s", sysfs_flow_ctrl);
 			close(fd);
 			return -1;
 		}
@@ -486,14 +500,17 @@
 
 	/* sysfs entry may get populated after service is started so we retry if it fails*/
 	while (trials > 0) {
-		st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY);
+		st_fd = open(sysfs_install_entry, O_RDONLY);
 		if(st_fd > 0)
 			break;
-		usleep(500000);
+		if (trials == 3)
+			sysfs_entry_fallback();
+		else
+			usleep(500000);
 		--trials;
 		}
 	if (st_fd < 0) {
-		UIM_DBG("unable to open %s(%s)", INSTALL_SYSFS_ENTRY, strerror(errno));
+		UIM_DBG("unable to open %s(%s)", sysfs_install_entry, strerror(errno));
 		return -1;
 	}
 
@@ -525,9 +542,9 @@
 	}
 
 	close(st_fd);
-	st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY);
+	st_fd = open(sysfs_install_entry, O_RDONLY);
 	if (st_fd < 0) {
-		UIM_DBG("unable to open %s (%s)", INSTALL_SYSFS_ENTRY, strerror(errno));
+		UIM_DBG("unable to open %s (%s)", sysfs_install_entry, strerror(errno));
 		return -1;
 	}
 
diff --git a/wpan/uim/uim.h b/wpan/uim/uim.h
index c88d9cc..dc9c5b1 100644
--- a/wpan/uim/uim.h
+++ b/wpan/uim/uim.h
@@ -69,6 +69,10 @@
 #define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate"
 #define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl"
 
+#define INSTALL_SYSFS_ENTRY_OLD "/sys/devices/kim/install"
+#define DEV_NAME_SYSFS_OLD "/sys/devices/kim/dev_name"
+#define BAUD_RATE_SYSFS_OLD "/sys/devices/kim/baud_rate"
+#define FLOW_CTRL_SYSFS_OLD "/sys/devices/kim/flow_cntrl"
 
 #define VERBOSE
 /*Debug logs*/