diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-15 14:21:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-15 14:21:20 +0100 |
commit | 0fdbd47ac4ff832f1c950db0b6ccb2eda3824158 (patch) | |
tree | b6f121ca8017c89be96af2ff96d07f1f20e8f52c /common | |
parent | 42cdd1452a51ca970a6cda76e3bdbe4f04d6e13f (diff) | |
parent | a1511452b8eb44cdce2e7e879b82d147e213654e (diff) | |
download | barebox-0fdbd47ac4ff832f1c950db0b6ccb2eda3824158.tar.gz barebox-0fdbd47ac4ff832f1c950db0b6ccb2eda3824158.tar.xz |
Merge branch 'for-next/rockchip'
Diffstat (limited to 'common')
-rw-r--r-- | common/partitions.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/partitions.c b/common/partitions.c index d80878e065..b579559672 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -156,3 +156,30 @@ int partition_parser_register(struct partition_parser *p) return 0; } + +/** + * cdev_unallocated_space - return unallocated space + * cdev: The cdev + * + * This function returns the space that is not allocated by any partition + * at the start of a device. + * + * Return: The unallocated space at the start of the device in bytes + */ +loff_t cdev_unallocated_space(struct cdev *cdev) +{ + struct cdev *partcdev; + loff_t start; + + if (!cdev) + return 0; + + start = cdev->size; + + list_for_each_entry(partcdev, &cdev->partitions, partition_entry) { + if (partcdev->offset < start) + start = partcdev->offset; + } + + return start; +} |