Patch from broadcom

When updating the default reservation code to handle reserved-memory[1]
DT entries in addition to memreserve, I made an off-by-one error when
checking for the unhandled 'split region' case and could also set the
incorrect size for memreserve at the end of a region.  Fix that,
simplify the logic a bit, and add some (hopefully) clarifying comments.

Change-Id: Icc68a5023387c5336f52559514377e818421d2cf
diff --git a/drivers/soc/brcmstb/memory.c b/drivers/soc/brcmstb/memory.c
index 2c249fc..22524e6 100644
--- a/drivers/soc/brcmstb/memory.c
+++ b/drivers/soc/brcmstb/memory.c
@@ -321,12 +321,11 @@
 
 		if (start >= region->base &&
 				start < region->base + region->size) {
+			/* adjust for reserved region at beginning */
 			newstart = region->base + region->size;
 			newsize = size - (newstart - start);
 		} else if (start < region->base) {
-			if (start + size < region->base + region->size) {
-				newsize = region->base - start;
-			} else if (start + size >=
+			if (start + size >
 					region->base + region->size) {
 				/* unhandled condition */
 				pr_err("%s: Split region %pa@%pa, reserve will fail\n",
@@ -335,6 +334,8 @@
 				memblock_dump_all();
 				return -EINVAL;
 			}
+			/* adjust for reserved region at end */
+			newsize = min(region->base - start, size);
 		}
 		/* see if we had any modifications */
 		if (newsize != size || newstart != start) {