From: Petr Hodina <[email protected]>

Snapdragon keeps the slot state in the boot_a/boot_b GPT attribute
flags, handled by ab_select_slot(), so no "misc" partition is needed.
Override phonemenu_ab_slot() in a new Qualcomm specific file so the
generic code does not require one.

Signed-off-by: Petr Hodina <[email protected]>
---
 MAINTAINERS          |  1 +
 cmd/Makefile         |  2 +-
 cmd/phonemenu_qcom.c | 28 ++++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8734a683221..e4c108a0412 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -689,6 +689,7 @@ S:  Maintained
 T:     git https://source.denx.de/u-boot/custodians/u-boot-snapdragon.git
 F:     cmd/phone_util.c
 F:     cmd/phonemenu.c
+F:     cmd/phonemenu_qcom.c
 F:     include/phonemenu.h
 F:     configs/qcm6490_defconfig
 F:     configs/qcs9100_defconfig
diff --git a/cmd/Makefile b/cmd/Makefile
index 913d94abdb2..2fb613228f6 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_CMD_BMP) += bmp.o
 obj-$(CONFIG_CMD_BOOTCOUNT) += bootcount.o
 obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
 obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
-obj-$(CONFIG_CMD_PHONEMENU) += phone_util.o phonemenu.o
+obj-$(CONFIG_CMD_PHONEMENU) += phone_util.o phonemenu.o phonemenu_qcom.o
 obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
 obj-$(CONFIG_CMD_BOOTZ) += bootz.o
 obj-$(CONFIG_CMD_BOOTI) += booti.o
diff --git a/cmd/phonemenu_qcom.c b/cmd/phonemenu_qcom.c
new file mode 100644
index 00000000000..d8a295c10dc
--- /dev/null
+++ b/cmd/phonemenu_qcom.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm specific header information for phonemenu.
+ */
+
+#include <android_ab.h>
+#include <blk.h>
+#include <part.h>
+#include <phonemenu.h>
+#include <linux/errno.h>
+
+#if IS_ENABLED(CONFIG_ARCH_SNAPDRAGON)
+
+/*
+ * Slot state comes from the boot_a/boot_b GPT attribute flags
+ */
+int phonemenu_ab_slot(void)
+{
+       struct blk_desc *desc = phonemenu_storage_desc();
+       struct disk_partition unused = { 0 };
+
+       if (!desc)
+               return -ENODEV;
+
+       return ab_select_slot(desc, &unused, false);
+}
+
+#endif /* CONFIG_ARCH_SNAPDRAGON */

-- 
2.55.0


Reply via email to