spl: Convert spl_ubi_load_image() to use linker list

Add a linker list declaration for this method and remove the explicit
switch() code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 3217099..9be256e 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -384,11 +384,6 @@
 		return loader->load_image(&bootdev);
 
 	switch (boot_device) {
-#ifdef CONFIG_SPL_UBI
-	case BOOT_DEVICE_NAND:
-	case BOOT_DEVICE_ONENAND:
-		return spl_ubi_load_image(&bootdev);
-#else
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
 		return spl_nand_load_image(&bootdev);
@@ -397,7 +392,6 @@
 	case BOOT_DEVICE_ONENAND:
 		return spl_onenand_load_image(&bootdev);
 #endif
-#endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
 		return spl_nor_load_image(&bootdev);
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index d64e6cf..3ef00aa 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -76,3 +76,6 @@
 #endif
 	return ret;
 }
+/* Use priorty 0 so that Ubi will override NAND and ONENAND methods */
+SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_NAND, spl_ubi_load_image);
+SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_ONENAND, spl_ubi_load_image);