summaryrefslogtreecommitdiffstats
path: root/common/partition.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-08-14 09:28:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2008-08-14 09:28:10 +0200
commit65778b63d2f0b6d5b3405010eedc72271bce20e0 (patch)
treec4c3e859387a3dce7da811edff04a3b79cb9f5fd /common/partition.c
parent59f72431f42753e1f61bd19176eb67029e2ef77c (diff)
downloadbarebox-65778b63d2f0b6d5b3405010eedc72271bce20e0.tar.gz
barebox-65778b63d2f0b6d5b3405010eedc72271bce20e0.tar.xz
Partition: Add an own device id for partitions
Add an own device id for partitions. This is necessary to allow the partition layer to check if the given device is really a partition. Also, check for readonly flag in erase. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/partition.c')
-rw-r--r--common/partition.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/partition.c b/common/partition.c
index 8804fdb7c3..bb946383d3 100644
--- a/common/partition.c
+++ b/common/partition.c
@@ -59,6 +59,7 @@ struct device_d *dev_add_partition(struct device_d *dev, unsigned long offset,
part->device.map_base = dev->map_base + offset;
part->device.size = size;
part->device.type_data = part;
+ part->device.type = DEVICE_TYPE_PARTITION;
get_free_deviceid(part->device.id, name);
part->offset = offset;
@@ -71,6 +72,7 @@ struct device_d *dev_add_partition(struct device_d *dev, unsigned long offset,
if (part->device.driver)
return &part->device;
+ unregister_device(&part->device);
free(part);
return 0;
}
@@ -87,6 +89,9 @@ static int part_erase(struct device_d *dev, size_t count, unsigned long offset)
{
struct partition *part = dev->type_data;
+ if (part->flags & PARTITION_READONLY)
+ return -EROFS;
+
return dev_erase(part->physdev, count, offset + part->offset);
}
@@ -246,6 +251,7 @@ struct driver_d part_driver = {
.erase = part_erase,
.protect= part_protect,
.memmap = part_memmap,
+ .type = DEVICE_TYPE_PARTITION,
};
static int partition_init(void)