summaryrefslogtreecommitdiffstats
path: root/common/partitions.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-05-24 12:54:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-15 11:15:47 +0200
commit121c3d6e9c2fb4649f3349edc522c99f3b9585d9 (patch)
tree61deccc69452fe6338c231118df5c1f8a4440aa5 /common/partitions.c
parent98df44ee7d6db3919a4dd11e227d1e0caedbfe86 (diff)
downloadbarebox-121c3d6e9c2fb4649f3349edc522c99f3b9585d9.tar.gz
devfs: let devfs_add_partition return the new partition
Useful for unregistering later or for adding addional flags. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/partitions.c')
-rw-r--r--common/partitions.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/common/partitions.c b/common/partitions.c
index 35a604c..38032a3 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -29,6 +29,7 @@
#include <disks.h>
#include <filetype.h>
#include <dma.h>
+#include <linux/err.h>
#include "partitions/parser.h"
@@ -48,16 +49,19 @@ static int register_one_partition(struct block_device *blk,
int ret;
uint64_t start = part->first_sec * SECTOR_SIZE;
uint64_t size = part->size * SECTOR_SIZE;
+ struct cdev *cdev;
partition_name = asprintf("%s.%d", blk->cdev.name, no);
if (!partition_name)
return -ENOMEM;
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
partition_name, blk->cdev.name);
- ret = devfs_add_partition(blk->cdev.name,
+ cdev = devfs_add_partition(blk->cdev.name,
start, size, 0, partition_name);
- if (ret)
+ if (IS_ERR(cdev)) {
+ ret = PTR_ERR(cdev);
goto out;
+ }
free(partition_name);
@@ -70,10 +74,10 @@ static int register_one_partition(struct block_device *blk,
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
partition_name, blk->cdev.name);
- ret = devfs_add_partition(blk->cdev.name,
+ cdev = devfs_add_partition(blk->cdev.name,
start, size, 0, partition_name);
- if (ret)
+ if (IS_ERR(cdev))
dev_warn(blk->dev, "Registering partition %s on drive %s failed\n",
partition_name, blk->cdev.name);