summaryrefslogtreecommitdiff
path: root/include/part.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-24 13:55:32 -0600
committerTom Rini <trini@konsulko.com>2023-08-25 17:55:18 -0400
commitbcd645428c340254a0f6e3b040fd36c3006fab6c (patch)
treec444be235be60afc52872daca36af79aa7abb5dc /include/part.h
parentc5f1d005f51783a5b34d6164ab66289eb1f4a45b (diff)
part: Add accessors for struct disk_partition type_uuid
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/part.h')
-rw-r--r--include/part.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/part.h b/include/part.h
index 8e5e543c56e..5cf1c5ec96f 100644
--- a/include/part.h
+++ b/include/part.h
@@ -107,6 +107,34 @@ static inline void disk_partition_clr_uuid(struct disk_partition *info)
#endif
}
+/* Accessors for struct disk_partition field ->type_guid */
+extern char *__invalid_use_of_disk_partition_type_uuid;
+
+static inline const
+char *disk_partition_type_uuid(const struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ return info->type_guid;
+#else
+ return __invalid_use_of_disk_partition_type_uuid;
+#endif
+}
+
+static inline void disk_partition_set_type_guid(struct disk_partition *info,
+ const char *val)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ strlcpy(info->type_guid, val, UUID_STR_LEN + 1);
+#endif
+}
+
+static inline void disk_partition_clr_type_guid(struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ *info->type_guid = '\0';
+#endif
+}
+
struct disk_part {
int partnum;
struct disk_partition gpt_part_info;