Merge branch 'master_net/phy/prep-cleanup' of https://source.denx.de/u-boot/custodians/u-boot-sh

- PHY framework cleanups
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index de15d09e..a1f44d9 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -419,4 +419,21 @@
 	ret	lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+	push	{r0, r1}
+	mov	r1, lr
+	adds	r1, r1, #2	/* Align to word.  */
+	lsrs	r1, r1, #2
+	lsls	r0, r0, #2
+	lsls	r1, r1, #2
+	ldr	r0, [r1, r0]
+	adds	r0, r0, r1
+	mov	lr, r0
+	pop	{r0, r1}
+	mov	pc, lr		/* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif
diff --git a/cmd/2048.c b/cmd/2048.c
new file mode 100644
index 0000000..fa60aa9
--- /dev/null
+++ b/cmd/2048.c
@@ -0,0 +1,397 @@
+// SPDX-License-Identifier: MIT
+// SPDX-FileCopyrightText: © 2014 Maurits van der Schee
+
+/* Console version of the game "2048" for GNU/Linux */
+
+#include <common.h>
+#include <cli.h>
+#include <command.h>
+#include <rand.h>
+#include <linux/delay.h>
+
+#define SIZE 4
+static uint score;
+
+static void getColor(uint value, char *color, size_t length)
+{
+	u8 original[] = {
+		8, 255, 1, 255, 2, 255, 3, 255,
+		4, 255, 5, 255, 6, 255, 7, 255,
+		9, 0, 10, 0, 11, 0, 12, 0, 13,
+		0, 14, 0, 255, 0, 255, 0};
+	u8 *scheme = original;
+	u8 *background = scheme + 0;
+	u8 *foreground = scheme + 1;
+
+	if (value > 0) {
+		while (value >>= 1) {
+			if (background + 2 < scheme + sizeof(original)) {
+				background += 2;
+				foreground += 2;
+			}
+		}
+	}
+	snprintf(color, length, "\033[38;5;%d;48;5;%dm", *foreground,
+		 *background);
+}
+
+static void drawBoard(u16 board[SIZE][SIZE])
+{
+	int x, y;
+	char color[40], reset[] = "\033[0m";
+
+	printf("\033[H");
+	printf("2048.c %17d pts\n\n", score);
+
+	for (y = 0; y < SIZE; y++) {
+		for (x = 0; x < SIZE; x++) {
+			getColor(board[x][y], color, 40);
+			printf("%s", color);
+			printf("       ");
+			printf("%s", reset);
+		}
+		printf("\n");
+		for (x = 0; x < SIZE; x++) {
+			getColor(board[x][y], color, 40);
+			printf("%s", color);
+			if (board[x][y] != 0) {
+				char s[8];
+				s8 t;
+
+				snprintf(s, 8, "%u", board[x][y]);
+				t = 7 - strlen(s);
+				printf("%*s%s%*s", t - t / 2, "", s, t / 2, "");
+			} else {
+				printf("   ·   ");
+			}
+			printf("%s", reset);
+		}
+		printf("\n");
+		for (x = 0; x < SIZE; x++) {
+			getColor(board[x][y], color, 40);
+			printf("%s", color);
+			printf("       ");
+			printf("%s", reset);
+		}
+		printf("\n");
+	}
+	printf("\n");
+	printf("        ←, ↑, →, ↓ or q        \n");
+	printf("\033[A");
+}
+
+static int8_t findTarget(u16 array[SIZE], int x, int stop)
+{
+	int t;
+
+	/* if the position is already on the first, don't evaluate */
+	if (x == 0)
+		return x;
+	for (t = x - 1; t >= 0; t--) {
+		if (array[t]) {
+			if (array[t] != array[x]) {
+				/* merge is not possible, take next position */
+				return t + 1;
+			}
+			return t;
+		}
+
+		/* we should not slide further, return this one */
+		if (t == stop)
+			return t;
+	}
+	/* we did not find a */
+	return x;
+}
+
+static bool slideArray(u16 array[SIZE])
+{
+	bool success = false;
+	int x, t, stop = 0;
+
+	for (x = 0; x < SIZE; x++) {
+		if (array[x] != 0) {
+			t = findTarget(array, x, stop);
+			/*
+			 * if target is not original position, then move or
+			 * merge
+			 */
+			if (t != x) {
+				/*
+				 * if target is not zero, set stop to avoid
+				 * double merge
+				 */
+				if (array[t]) {
+					score += array[t] + array[x];
+					stop = t + 1;
+				}
+				array[t] += array[x];
+				array[x] = 0;
+				success = true;
+			}
+		}
+	}
+	return success;
+}
+
+static void rotateBoard(u16 board[SIZE][SIZE])
+{
+	s8 i, j, n = SIZE;
+	int tmp;
+
+	for (i = 0; i < n / 2; i++) {
+		for (j = i; j < n - i - 1; j++) {
+			tmp = board[i][j];
+			board[i][j] = board[j][n - i - 1];
+			board[j][n - i - 1] = board[n - i - 1][n - j - 1];
+			board[n - i - 1][n - j - 1] = board[n - j - 1][i];
+			board[n - j - 1][i] = tmp;
+		}
+	}
+}
+
+static bool moveUp(u16 board[SIZE][SIZE])
+{
+	bool success = false;
+	int x;
+
+	for (x = 0; x < SIZE; x++)
+		success |= slideArray(board[x]);
+
+	return success;
+}
+
+static bool moveLeft(u16 board[SIZE][SIZE])
+{
+	bool success;
+
+	rotateBoard(board);
+	success = moveUp(board);
+	rotateBoard(board);
+	rotateBoard(board);
+	rotateBoard(board);
+	return success;
+}
+
+static bool moveDown(u16 board[SIZE][SIZE])
+{
+	bool success;
+
+	rotateBoard(board);
+	rotateBoard(board);
+	success = moveUp(board);
+	rotateBoard(board);
+	rotateBoard(board);
+	return success;
+}
+
+static bool moveRight(u16 board[SIZE][SIZE])
+{
+	bool success;
+
+	rotateBoard(board);
+	rotateBoard(board);
+	rotateBoard(board);
+	success = moveUp(board);
+	rotateBoard(board);
+	return success;
+}
+
+static bool findPairDown(u16 board[SIZE][SIZE])
+{
+	bool success = false;
+	int x, y;
+
+	for (x = 0; x < SIZE; x++) {
+		for (y = 0; y < SIZE - 1; y++) {
+			if (board[x][y] == board[x][y + 1])
+				return true;
+		}
+	}
+
+	return success;
+}
+
+static int16_t countEmpty(u16 board[SIZE][SIZE])
+{
+	int x, y;
+	int count = 0;
+
+	for (x = 0; x < SIZE; x++) {
+		for (y = 0; y < SIZE; y++) {
+			if (board[x][y] == 0)
+				count++;
+		}
+	}
+	return count;
+}
+
+static bool gameEnded(u16 board[SIZE][SIZE])
+{
+	bool ended = true;
+
+	if (countEmpty(board) > 0)
+		return false;
+	if (findPairDown(board))
+		return false;
+	rotateBoard(board);
+	if (findPairDown(board))
+		ended = false;
+	rotateBoard(board);
+	rotateBoard(board);
+	rotateBoard(board);
+
+	return ended;
+}
+
+static void addRandom(u16 board[SIZE][SIZE])
+{
+	int x, y;
+	int r, len = 0;
+	u16 n, list[SIZE * SIZE][2];
+
+	for (x = 0; x < SIZE; x++) {
+		for (y = 0; y < SIZE; y++) {
+			if (board[x][y] == 0) {
+				list[len][0] = x;
+				list[len][1] = y;
+				len++;
+			}
+		}
+	}
+
+	if (len > 0) {
+		r = rand() % len;
+		x = list[r][0];
+		y = list[r][1];
+		n = ((rand() % 10) / 9 + 1) * 2;
+		board[x][y] = n;
+	}
+}
+
+static int test(void)
+{
+	u16 array[SIZE];
+	u16 data[] = {
+		0, 0, 0, 2,	2, 0, 0, 0,
+		0, 0, 2, 2,	4, 0, 0, 0,
+		0, 2, 0, 2,	4, 0, 0, 0,
+		2, 0, 0, 2,	4, 0, 0, 0,
+		2, 0, 2, 0,	4, 0, 0, 0,
+		2, 2, 2, 0,	4, 2, 0, 0,
+		2, 0, 2, 2,	4, 2, 0, 0,
+		2, 2, 0, 2,	4, 2, 0, 0,
+		2, 2, 2, 2,	4, 4, 0, 0,
+		4, 4, 2, 2,	8, 4, 0, 0,
+		2, 2, 4, 4,	4, 8, 0, 0,
+		8, 0, 2, 2,	8, 4, 0, 0,
+		4, 0, 2, 2,	4, 4, 0, 0
+	};
+	u16 *in, *out;
+	u16 t, tests;
+	int i;
+	bool success = true;
+
+	tests = (sizeof(data) / sizeof(data[0])) / (2 * SIZE);
+	for (t = 0; t < tests; t++) {
+		in = data + t * 2 * SIZE;
+		out = in + SIZE;
+		for (i = 0; i < SIZE; i++)
+			array[i] = in[i];
+		slideArray(array);
+		for (i = 0; i < SIZE; i++) {
+			if (array[i] != out[i])
+				success = false;
+		}
+		if (!success) {
+			for (i = 0; i < SIZE; i++)
+				printf("%d ", in[i]);
+			printf(" = > ");
+			for (i = 0; i < SIZE; i++)
+				printf("%d ", array[i]);
+			printf("expected ");
+			for (i = 0; i < SIZE; i++)
+				printf("%d ", in[i]);
+			printf(" = > ");
+			for (i = 0; i < SIZE; i++)
+				printf("%d ", out[i]);
+			printf("\n");
+			break;
+		}
+	}
+	if (success)
+		printf("All %u tests executed successfully\n", tests);
+
+	return !success;
+}
+
+static int do_2048(struct cmd_tbl *cmdtp, int flag, int argc,
+		   char *const argv[])
+{
+	struct cli_ch_state cch_s, *cch = &cch_s;
+	u16 board[SIZE][SIZE];
+	bool success;
+
+	if (argc == 2 && strcmp(argv[1], "test") == 0)
+		return test();
+
+	score = 0;
+
+	printf("\033[?25l\033[2J\033[H");
+
+	memset(board, 0, sizeof(board));
+	addRandom(board);
+	addRandom(board);
+	drawBoard(board);
+	cli_ch_init(cch);
+	while (true) {
+		int c;
+
+		c = cli_ch_process(cch, 0);
+		if (!c) {
+			c = getchar();
+			c = cli_ch_process(cch, c);
+		}
+		switch (c) {
+		case CTL_CH('b'): /* left arrow */
+			success = moveLeft(board);
+			break;
+		case CTL_CH('f'): /* right arrow */
+			success = moveRight(board);
+			break;
+		case CTL_CH('p'):/* up arrow */
+			success = moveUp(board);
+			break;
+		case CTL_CH('n'): /* down arrow */
+			success = moveDown(board);
+			break;
+		default:
+			success = false;
+		}
+		if (success) {
+			drawBoard(board);
+			mdelay(150);
+			addRandom(board);
+			drawBoard(board);
+			if (gameEnded(board)) {
+				printf("         GAME OVER          \n");
+				break;
+			}
+		}
+		if (c == 'q') {
+			printf("            QUIT            \n");
+			break;
+		}
+	}
+
+	printf("\033[?25h");
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	2048,	2,	1,	do_2048,
+	"The 2048 game",
+	"Use your arrow keys to move the tiles. When two tiles with "
+	"the same number touch, they merge into one!"
+);
diff --git a/cmd/Kconfig b/cmd/Kconfig
index bab35fc..e45b884 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1446,7 +1446,8 @@
 
 config CMD_SCSI
 	bool "scsi - Access to SCSI devices"
-	default y if SCSI
+	depends on SCSI
+	default y
 	help
 	  This provides a 'scsi' command which provides access to SCSI (Small
 	  Computer System Interface) devices. The command provides a way to
@@ -1940,6 +1941,17 @@
 
 menu "Misc commands"
 
+config CMD_2048
+	bool "Play 2048"
+	help
+	  This is a simple sliding block puzzle game designed by Italian web
+	  developer Gabriele Cirulli. The game's objective is to slide numbered
+	  tiles on a grid to combine them to create a tile with the number
+	  2048.
+
+	  This needs ANSI support on your terminal to work. It is not fully
+	  functional on a video device.
+
 config CMD_BMP
 	bool "Enable 'bmp' command"
 	depends on VIDEO
diff --git a/cmd/Makefile b/cmd/Makefile
index 054ef42..6c37521 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,7 @@
 obj-y += version.o
 
 # command
+obj-$(CONFIG_CMD_2048) += 2048.o
 obj-$(CONFIG_CMD_ACPI) += acpi.o
 obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
 obj-$(CONFIG_CMD_AES) += aes.o
diff --git a/cmd/date.c b/cmd/date.c
index 58505e6..fe9c8c6 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -98,7 +98,7 @@
 				puts("## Get date failed\n");
 			}
 		}
-		/* FALL TROUGH */
+		fallthrough;
 	case 1:			/* get date & time */
 #ifdef CONFIG_DM_RTC
 		rcode = dm_rtc_get(dev, &tm);
diff --git a/cmd/pci.c b/cmd/pci.c
index 58a7475..78b661d 100644
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -517,6 +517,7 @@
 			addr = hextoul(argv[3], NULL);
 		if (argc > 4)
 			value = hextoul(argv[4], NULL);
+		fallthrough;
 	case 'h':		/* header */
 	case 'b':		/* bars */
 		if (argc < 3)
diff --git a/cmd/regulator.c b/cmd/regulator.c
index ed4996d..8988c90 100644
--- a/cmd/regulator.c
+++ b/cmd/regulator.c
@@ -37,6 +37,7 @@
 			printf("Can't get the regulator: %s!\n", name);
 			return failure(ret);
 		}
+		fallthrough;
 	case 1:
 		if (!currdev) {
 			printf("Regulator device is not set!\n\n");
diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig
index 9c906ed..9940258 100644
--- a/configs/controlcenterdc_defconfig
+++ b/configs/controlcenterdc_defconfig
@@ -72,6 +72,7 @@
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_USE_ROOTPATH=y
 CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_SYS_SATA_MAX_PORTS=2
 CONFIG_SCSI_AHCI=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
diff --git a/configs/highbank_defconfig b/configs/highbank_defconfig
index f045757..4eac7b2 100644
--- a/configs/highbank_defconfig
+++ b/configs/highbank_defconfig
@@ -30,6 +30,7 @@
 CONFIG_MISC_INIT_R=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_ENV_IS_IN_NVRAM=y
+CONFIG_SYS_SATA_MAX_PORTS=5
 CONFIG_SCSI_AHCI=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 3a1f14c..ca95b2c 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -340,3 +340,4 @@
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
+CONFIG_CMD_2048=y
diff --git a/doc/arch/m68k.rst b/doc/arch/m68k.rst
index a9180fd..8474ece 100644
--- a/doc/arch/m68k.rst
+++ b/doc/arch/m68k.rst
@@ -5,7 +5,7 @@
 
 History
 -------
-* November 02, 2017	Angelo Dureghello <angelo@sysam.it>
+* November 02, 2017	Angelo Dureghello <angelo@kernel-space.org>
 * August   08, 2005	Jens Scharsig <esw@bus-elektronik.de>
   MCF5282 implementation without preloader
 * January  12, 2004	<josef.baumgartner@telex.de>
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 3fe53d6..049f7ef 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -20,6 +20,14 @@
 
 	  See also CMD_SATA which provides command-line support.
 
+config SYS_SATA_MAX_PORTS
+	int "Maximum supported SATA ports"
+	depends on SCSI_AHCI && !DM_SCSI
+	default 1
+	help
+	  Sets the maximum number of ports to scan when looking for devices.
+	  Ports from 0 to (this value - 1) are scanned.
+
 config LIBATA
 	bool
 	help
@@ -37,6 +45,7 @@
 	bool "Support for PCI-based AHCI controller"
 	depends on PCI
 	depends on DM_SCSI
+	depends on SCSI_AHCI
 	help
 	  Enables support for the PCI-based AHCI controller.
 
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 272c48b..6998b82 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -211,8 +211,8 @@
 	      uc_priv->cap, uc_priv->port_map, uc_priv->n_ports);
 
 #if !defined(CONFIG_DM_SCSI)
-	if (uc_priv->n_ports > CONFIG_SYS_SCSI_MAX_SCSI_ID)
-		uc_priv->n_ports = CONFIG_SYS_SCSI_MAX_SCSI_ID;
+	if (uc_priv->n_ports > CONFIG_SYS_SATA_MAX_PORTS)
+		uc_priv->n_ports = CONFIG_SYS_SATA_MAX_PORTS;
 #endif
 
 	for (i = 0; i < uc_priv->n_ports; i++) {
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 77d3f37..067fae2 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -31,7 +31,7 @@
 static int serial_check_stdout(const void *blob, struct udevice **devp)
 {
 	int node = -1;
-	const char *str, *p, *name;
+	const char *str, *p;
 	int namelen;
 
 	/* Check for a chosen console */
@@ -39,20 +39,16 @@
 	if (str) {
 		p = strchr(str, ':');
 		namelen = p ? p - str : strlen(str);
+		/*
+		 * This also deals with things like
+		 *
+		 *	stdout-path = "serial0:115200n8";
+		 *
+		 * since fdt_path_offset_namelen() treats a str not
+		 * beginning with '/' as an alias and thus applies
+		 * fdt_get_alias_namelen() to it.
+		 */
 		node = fdt_path_offset_namelen(blob, str, namelen);
-
-		if (node < 0) {
-			/*
-			 * Deal with things like
-			 *	stdout-path = "serial0:115200n8";
-			 *
-			 * We need to look up the alias and then follow it to
-			 * the correct node.
-			 */
-			name = fdt_get_alias_namelen(blob, str, namelen);
-			if (name)
-				node = fdt_path_offset(blob, name);
-		}
 	}
 
 	if (node < 0)
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index cdd2304..b44565b 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -573,6 +573,7 @@
 
 config FSL_ESPI
 	bool "Freescale eSPI driver"
+	depends on MPC85xx
 	imply SPI_FLASH_BAR
 	help
 	  Enable the Freescale eSPI driver. This driver can be used to
diff --git a/include/lmb.h b/include/lmb.h
index 7298c2c..07bf221 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -35,6 +35,24 @@
 	enum lmb_flags flags;
 };
 
+/*
+ * For regions size management, see LMB configuration in KConfig
+ * all the #if test are done with CONFIG_LMB_USE_MAX_REGIONS (boolean)
+ *
+ * case 1. CONFIG_LMB_USE_MAX_REGIONS is defined (legacy mode)
+ *         => CONFIG_LMB_MAX_REGIONS is used to configure the region size,
+ *         directly in the array lmb_region.region[], with the same
+ *         configuration for memory and reserved regions.
+ *
+ * case 2. CONFIG_LMB_USE_MAX_REGIONS is not defined, the size of each
+ *         region is configurated *independently* with
+ *         => CONFIG_LMB_MEMORY_REGIONS: struct lmb.memory_regions
+ *         => CONFIG_LMB_RESERVED_REGIONS: struct lmb.reserved_regions
+ *         lmb_region.region is only a pointer to the correct buffer,
+ *         initialized in lmb_init(). This configuration is useful to manage
+ *         more reserved memory regions with CONFIG_LMB_RESERVED_REGIONS.
+ */
+
 /**
  * struct lmb_region - Description of a set of region.
  *
@@ -68,7 +86,7 @@
 struct lmb {
 	struct lmb_region memory;
 	struct lmb_region reserved;
-#ifdef CONFIG_LMB_MEMORY_REGIONS
+#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
 	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
 #endif
diff --git a/lib/Kconfig b/lib/Kconfig
index 202a34a..d8dac09 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1057,7 +1057,6 @@
 
 config LMB_USE_MAX_REGIONS
 	bool "Use a common number of memory and reserved regions in lmb lib"
-	depends on LMB
 	default y
 	help
 	  Define the number of supported memory regions in the library logical
@@ -1067,7 +1066,7 @@
 
 config LMB_MAX_REGIONS
 	int "Number of memory and reserved regions in lmb lib"
-	depends on LMB && LMB_USE_MAX_REGIONS
+	depends on LMB_USE_MAX_REGIONS
 	default 16
 	help
 	  Define the number of supported regions, memory and reserved, in the
@@ -1075,7 +1074,7 @@
 
 config LMB_MEMORY_REGIONS
 	int "Number of memory regions in lmb lib"
-	depends on LMB && !LMB_USE_MAX_REGIONS
+	depends on !LMB_USE_MAX_REGIONS
 	default 8
 	help
 	  Define the number of supported memory regions in the library logical
@@ -1084,7 +1083,7 @@
 
 config LMB_RESERVED_REGIONS
 	int "Number of reserved regions in lmb lib"
-	depends on LMB && !LMB_USE_MAX_REGIONS
+	depends on !LMB_USE_MAX_REGIONS
 	default 8
 	help
 	  Define the number of supported reserved regions in the library logical
diff --git a/lib/lmb.c b/lib/lmb.c
index 2444b2a..b2c233e 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -27,7 +27,7 @@
 	enum lmb_flags flags;
 	int i;
 
-	printf(" %s.cnt  = 0x%lx\n", name, rgn->cnt);
+	printf(" %s.cnt = 0x%lx / max = 0x%lx\n", name, rgn->cnt, rgn->max);
 
 	for (i = 0; i < rgn->cnt; i++) {
 		base = rgn->region[i].base;
@@ -110,7 +110,7 @@
 #if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
 	lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
-#elif defined(CONFIG_LMB_MEMORY_REGIONS)
+#else
 	lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
 	lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
 	lmb->memory.region = lmb->memory_regions;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 2d13e68..e87503e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -674,6 +674,7 @@
 
 		case 'x':
 			flags |= SMALL;
+		/* fallthrough */
 		case 'X':
 			base = 16;
 			break;
@@ -681,8 +682,10 @@
 		case 'd':
 			if (fmt[1] == 'E')
 				flags |= ERRSTR;
+		/* fallthrough */
 		case 'i':
 			flags |= SIGN;
+		/* fallthrough */
 		case 'u':
 			break;
 
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 1d193bd..0b201b9 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -73,7 +73,7 @@
 		" -c, --config         configuration file, default:" CONFIG_FILE "\n"
 #endif
 		" -n, --noheader       do not repeat variable name in output\n"
-		" -l, --lock           lock node, default:/var/lock\n"
+		" -l, --lock           lock node, default:/run\n"
 		"\n");
 }
 
@@ -88,7 +88,7 @@
 #ifdef CONFIG_FILE
 		" -c, --config         configuration file, default:" CONFIG_FILE "\n"
 #endif
-		" -l, --lock           lock node, default:/var/lock\n"
+		" -l, --lock           lock node, default:/run\n"
 		" -s, --script         batch mode to minimize writes\n"
 		"\n"
 		"Examples:\n"
@@ -206,7 +206,7 @@
 
 int main(int argc, char *argv[])
 {
-	char *lockname = "/var/lock/" CMD_PRINTENV ".lock";
+	char *lockname = "/run/" CMD_PRINTENV ".lock";
 	int lockfd = -1;
 	int retval = EXIT_SUCCESS;
 	char *_cmdname;
diff --git a/tools/fdt_add_pubkey.c b/tools/fdt_add_pubkey.c
index 999f5a7..5582d7a 100644
--- a/tools/fdt_add_pubkey.c
+++ b/tools/fdt_add_pubkey.c
@@ -10,7 +10,7 @@
 static const char *require_keys; /* -r <conf|image> */
 static const char *keydest; /* argv[n] */
 
-static void print_usage(const char *msg)
+static void __attribute__((__noreturn__)) print_usage(const char *msg)
 {
 	fprintf(stderr, "Error: %s\n", msg);
 	fprintf(stderr, "Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>]"
@@ -19,7 +19,7 @@
 	exit(EXIT_FAILURE);
 }
 
-static void print_help(void)
+static void __attribute__((__noreturn__)) print_help(void)
 {
 	fprintf(stderr, "Options:\n"
 		"\t-a <algo>       Cryptographic algorithm. Optional parameter, default value: sha1,rsa2048\n"