dm: part: Convert partition API use to linker lists
We can use linker lists instead of explicitly declaring each function.
This makes the code shorter by avoiding switch() statements and lots of
header file declarations.
While this does clean up the code it introduces a few code issues with SPL.
SPL never needs to print partition information since this all happens from
commands. SPL mostly doesn't need to obtain information about a partition
either, except in a few cases. Add these cases so that the code will be
dropped from each partition driver when not needed. This avoids code bloat.
I think this is still a win, since it is not a bad thing to be explicit
about which features are used in SPL. But others may like to weigh in.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
diff --git a/disk/part_mac.c b/disk/part_mac.c
index ae83495..3fb3b16 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -40,7 +40,7 @@
/*
* Test for a valid MAC partition
*/
-int test_part_mac(struct blk_desc *dev_desc)
+static int test_part_mac(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
@@ -64,8 +64,7 @@
return (0);
}
-
-void print_part_mac(struct blk_desc *dev_desc)
+static void print_part_mac(struct blk_desc *dev_desc)
{
ulong i, n;
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
@@ -214,8 +213,8 @@
/* NOTREACHED */
}
-int get_partition_info_mac(struct blk_desc *dev_desc, int part,
- disk_partition_t *info)
+static int get_partition_info_mac(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
@@ -238,4 +237,11 @@
return (0);
}
+U_BOOT_PART_TYPE(mac) = {
+ .name = "MAC",
+ .part_type = PART_TYPE_MAC,
+ .get_info = get_partition_info_mac,
+ .print = print_part_mac,
+ .test = test_part_mac,
+};
#endif