diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2014-02-27 21:39:05 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-02-28 11:19:07 +0100 |
commit | 2a644bed634bdf8afdd79e672fd67306a0e5dc3c (patch) | |
tree | 4e470c1fdc30b405d32ddab0586a8394be4226d9 /include/driver.h | |
parent | 14d0355d7c1b55bc4713b8c7768ae012840bbc85 (diff) | |
download | barebox-2a644bed634bdf8afdd79e672fd67306a0e5dc3c.tar.gz barebox-2a644bed634bdf8afdd79e672fd67306a0e5dc3c.tar.xz |
devfs: partitioning: add new helper devfs_create_partitions
Compared to devfs_add_partition which adds a single partition
devfs_create_partitions creates several partitions at once. One nice
benefit is that this simplifies appending partitions because the start
of the latter partition doesn't need to be specified explicitly.
Also dev_add_bb_dev() is called by the new helper if the bbname is
specified for a partition.
Note that adding partitions is also more flexible now (also via
devfs_add_partition) because negative values for offset and size now
have a proper meaning instead of creating broken partitions.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/driver.h')
-rw-r--r-- | include/driver.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/driver.h b/include/driver.h index 33b82c3e96..31bdecf6d8 100644 --- a/include/driver.h +++ b/include/driver.h @@ -491,6 +491,39 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset, loff_t size, unsigned int flags, const char *name); int devfs_del_partition(const char *name); +#define DEVFS_PARTITION_APPEND 0 + +/** + * struct devfs_partition - defines parameters for a single partition + * @offset: start of partition + * a negative offset requests to start the partition relative to the + * device's end. DEVFS_PARTITION_APPEND (i.e. 0) means start directly at + * the end of the previous partition. + * @size: size of partition + * a non-positive value requests to use a size that keeps -size free space + * after the current partition. A special case of this is passing 0, which + * means "until end of device". + * @flags: flags passed to devfs_add_partition + * @name: name passed to devfs_add_partition + * @bbname: if non-NULL also dev_add_bb_dev() is called for the partition during + * devfs_create_partitions(). + */ +struct devfs_partition { + loff_t offset; + loff_t size; + unsigned int flags; + const char *name; + const char *bbname; +}; +/** + * devfs_create_partitions - create a set of partitions for a device + * @devname: name of the device to partition + * @partinfo: array of partition parameters + * The array is processed until an entry with .name = NULL is found. + */ +int devfs_create_partitions(const char *devname, + const struct devfs_partition partinfo[]); + #define DRV_OF_COMPAT(compat) \ IS_ENABLED(CONFIG_OFDEVICE) ? (compat) : NULL |