summaryrefslogtreecommitdiffstats
path: root/commands/partition.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 /commands/partition.c
parent98df44ee7d6db3919a4dd11e227d1e0caedbfe86 (diff)
downloadbarebox-121c3d6e9c2fb4649f3349edc522c99f3b9585d9.tar.gz
barebox-121c3d6e9c2fb4649f3349edc522c99f3b9585d9.tar.xz
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 'commands/partition.c')
-rw-r--r--commands/partition.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/commands/partition.c b/commands/partition.c
index 6f8d6343c..6d37471f4 100644
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -35,6 +35,7 @@
#include <linux/stat.h>
#include <libgen.h>
#include <getopt.h>
+#include <linux/err.h>
#define SIZE_REMAINING ((ulong)-1)
@@ -48,7 +49,8 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
char *end;
char buf[PATH_MAX] = {};
unsigned long flags = 0;
- int ret;
+ int ret = 0;
+ struct cdev *cdev;
memset(buf, 0, PATH_MAX);
@@ -99,9 +101,12 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
*retsize = size;
- ret = devfs_add_partition(devname, *offset, size, flags, buf);
- if (ret)
+ cdev = devfs_add_partition(devname, *offset, size, flags, buf);
+ if (IS_ERR(cdev)) {
+ ret = PTR_ERR(cdev);
printf("cannot create %s: %s\n", buf, strerror(-ret));
+ }
+
return ret;
}