summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2023-08-24 13:55:31 -0600
committerTom Rini <[email protected]>2023-08-25 17:55:18 -0400
commitc5f1d005f51783a5b34d6164ab66289eb1f4a45b (patch)
treece2387e3ccb134d02bfd2c458546c420ca886c53 /include
parentade2316da3cd76abe7649d34abb84f1370fb942d (diff)
part: Add accessors for struct disk_partition 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 <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/part.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/part.h b/include/part.h
index 3a6be75421d..8e5e543c56e 100644
--- a/include/part.h
+++ b/include/part.h
@@ -80,6 +80,33 @@ struct disk_partition {
#endif
};
+/* Accessors for struct disk_partition field ->uuid */
+extern char *__invalid_use_of_disk_partition_uuid;
+
+static inline const char *disk_partition_uuid(const struct disk_partition *info)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ return info->uuid;
+#else
+ return __invalid_use_of_disk_partition_uuid;
+#endif
+}
+
+static inline void disk_partition_set_uuid(struct disk_partition *info,
+ const char *val)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ strlcpy(info->uuid, val, UUID_STR_LEN + 1);
+#endif
+}
+
+static inline void disk_partition_clr_uuid(struct disk_partition *info)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ *info->uuid = '\0';
+#endif
+}
+
struct disk_part {
int partnum;
struct disk_partition gpt_part_info;