ubispl: add support for loading volumes by name

The motivation is to use the UBI atomic volume rename functionality to
allow double copy software updates on UBI. To that end the SPL is
configured to always load the same volume name (e.g. "u-boot"),
whereas a software updater always installs into the secondary volume
"u-boot_r". After successful installation, these two volume names are
switched.

This extension is protected by #ifdefs as it will somewhat slow down
loading of volumes by id. This is because the code needs to disable
the optimization of ignoring all volume ids which are not
to-be-loaded, since these can only be resolved after attaching.

This adds two vtbl related functions from Linux, which are taken from
the same kernel version as the current main U-Boot UBI code (Linux 4.2
64291f7db5bd8).

Signed-off-by: Hamish Guthrie <hamish.guthrie@kistler.com>
Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Cc: Kyungmin Park <kmpark@infradead.org>
diff --git a/drivers/mtd/ubispl/ubispl.h b/drivers/mtd/ubispl/ubispl.h
index 9e40b46..bcc376c 100644
--- a/drivers/mtd/ubispl/ubispl.h
+++ b/drivers/mtd/ubispl/ubispl.h
@@ -77,6 +77,8 @@
  * @blockinfo:		The vid headers of the scanned blocks
  * @volinfo:		The volume information of the interesting (toload)
  *			volumes
+ * @vtbl_corrupted:	Flag to indicate status of volume table
+ * @vtbl:		Volume table
  *
  * @fm_buf:		The large fastmap attach buffer
  */
@@ -112,6 +114,11 @@
 	struct ubi_vol_info		volinfo[UBI_SPL_VOL_IDS];
 	struct ubi_vid_hdr		blockinfo[CONFIG_SPL_UBI_MAX_PEBS];
 
+#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
+	/* Volume table */
+	int                             vtbl_valid;
+	struct ubi_vtbl_record          vtbl[UBI_SPL_VOL_IDS];
+#endif
 	/* The large buffer for the fastmap */
 	uint8_t				fm_buf[UBI_FM_BUF_SIZE];
 };