summaryrefslogtreecommitdiffstats
path: root/arch/sandbox/board/hostfile.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-09-20 07:36:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-20 08:50:59 +0200
commitfc5caa43a8c2f0166bee57bda7de127fe37b31f8 (patch)
tree37b87d976660aa8acb7cc1c3b01a065c32064699 /arch/sandbox/board/hostfile.c
parent48842b9b2510baa744561c36d3fcb0034a9f389e (diff)
downloadbarebox-fc5caa43a8c2f0166bee57bda7de127fe37b31f8.tar.gz
barebox-fc5caa43a8c2f0166bee57bda7de127fe37b31f8.tar.xz
sandbox: do not register device before barebox is started
This will crash when use registered bus with device registered to it. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/board/hostfile.c')
-rw-r--r--arch/sandbox/board/hostfile.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 96fa100011..00e46e22d4 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -102,7 +102,22 @@ device_initcall(hf_init);
int barebox_register_filedev(struct hf_platform_data *hf)
{
- return !add_generic_device("hostfile", DEVICE_ID_DYNAMIC, NULL, hf->base, hf->size,
- IORESOURCE_MEM, hf);
+ struct device_d *dev;
+ struct resource *res;
+
+ dev = xzalloc(sizeof(*dev));
+ strcpy(dev->name, "hostfile");
+ dev->id = DEVICE_ID_DYNAMIC;
+ dev->platform_data = hf;
+
+ res = xzalloc(sizeof(struct resource));
+ res[0].start = hf->base;
+ res[0].end = hf->base + hf->size - 1;
+ res[0].flags = IORESOURCE_MEM;
+
+ dev->resource = res;
+ dev->num_resources = 1;
+
+ return sandbox_add_device(dev);
}