* [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random
@ 2019-08-27 14:32 Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 1/6] sandbox: include header to provide missing prototype Ahmad Fatoum
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
What's in the topic is what the last patch does. The others are cleanup
or fixes or add a symbol needed by the last patch.
In summary, with this patchset, you can probe barebox,hostfile nodes in
your device tree, create partitions and have e.g. barebox state refer to
it. Some problems with symbol collisions are fixed, which e.g. cause X11
to use barebox strdup on my system, but the glibc free(3), which
resulted in a crash whenever it attempted to open the SDL window.
Ahmad Fatoum (6):
sandbox: include header to provide missing prototype
sandbox: remove unused ARCH_LINUX Kconfig symbol
sandbox: redefine optarg and optind to avoid collisions
sandbox: compile with symbol -fvisibility=hidden
sandbox: hostfile: allow probing from device tree
hwrng: add sandbox driver interface to host /dev/random
arch/sandbox/Kconfig | 3 -
arch/sandbox/Makefile | 6 +-
arch/sandbox/board/Makefile | 1 +
arch/sandbox/board/board.c | 7 +++
arch/sandbox/board/dev-random.c | 24 +++++++
arch/sandbox/board/devices.c | 1 +
arch/sandbox/board/hostfile.c | 16 +++--
arch/sandbox/dts/sandbox-state.dtsi | 50 +++++++++++++++
.../sandbox/mach-sandbox/include/mach/linux.h | 8 +++
arch/sandbox/os/common.c | 5 ++
drivers/hw_random/Kconfig | 8 +++
drivers/hw_random/Makefile | 1 +
drivers/hw_random/dev-random.c | 63 +++++++++++++++++++
13 files changed, 184 insertions(+), 9 deletions(-)
create mode 100644 arch/sandbox/board/dev-random.c
create mode 100644 arch/sandbox/dts/sandbox-state.dtsi
create mode 100644 drivers/hw_random/dev-random.c
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/6] sandbox: include header to provide missing prototype
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 2/6] sandbox: remove unused ARCH_LINUX Kconfig symbol Ahmad Fatoum
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
sandbox_add_device lacks a prototype. Include the appropriate header to
fix this.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/board/devices.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c
index 242a0d718e91..72e62552a3b8 100644
--- a/arch/sandbox/board/devices.c
+++ b/arch/sandbox/board/devices.c
@@ -8,6 +8,7 @@
#include <driver.h>
#include <mach/linux.h>
#include <init.h>
+#include <mach/linux.h>
static LIST_HEAD(sandbox_device_list);
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/6] sandbox: remove unused ARCH_LINUX Kconfig symbol
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 1/6] sandbox: include header to provide missing prototype Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 3/6] sandbox: redefine optarg and optind to avoid collisions Ahmad Fatoum
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
It's not referenced anywhere anymore, so drop it.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/Kconfig | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 5227cb624f2b..d153846efa0f 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -12,6 +12,3 @@ config LINUX
bool
default y
select GENERIC_FIND_NEXT_BIT
-
-config ARCH_LINUX
- bool
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/6] sandbox: redefine optarg and optind to avoid collisions
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 1/6] sandbox: include header to provide missing prototype Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 2/6] sandbox: remove unused ARCH_LINUX Kconfig symbol Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 4/6] sandbox: compile with symbol -fvisibility=hidden Ahmad Fatoum
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
If we don't do this, the barebox main may fail to parse arguments.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 85c70b5e8059..2a75b81cf632 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -23,7 +23,8 @@ CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dglob=barebox_glob -Dglobfree=barebox_globfree \
-Dioctl=barebox_ioctl -Dfstat=barebox_fstat \
-Dopendir=barebox_opendir -Dreaddir=barebox_readdir \
- -Dclosedir=barebox_closedir
+ -Dclosedir=barebox_closedir \
+ -Doptarg=barebox_optarg -Doptind=barebox_optind
machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/6] sandbox: compile with symbol -fvisibility=hidden
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
` (2 preceding siblings ...)
2019-08-27 14:32 ` [PATCH 3/6] sandbox: redefine optarg and optind to avoid collisions Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 5/6] sandbox: hostfile: allow probing from device tree Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 6/6] hwrng: add sandbox driver interface to host /dev/random Ahmad Fatoum
5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
barebox defines many symbols that are reserved for the C implementation.
This collides with the libc, when building barebox for ARCH=sandbox.
Specify -fvsibility-hidden, so libraries barebox is linked against don't
inadvertently use barebox' functions.
This fixes a heap corruption occurring when issuing fb0.enable=1 on my
system, because X11 used strdup out of barebox, but free out of glibc[1]:
binding file /lib/x86_64-linux-gnu/libX11.so.6 [0] to
./barebox [0]: normal symbol l `strdup' [GLIBC_2.2.5]
[...]
binding file /lib/x86_64-linux-gnu/libc.so.6 [0] to
/lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `free' [GLIBC_2.2.5]
[1]: cf. CFLAGS +=-Dfree=barebox_free in arch/sandbox/Makefile
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 2a75b81cf632..780783a1e08c 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -1,6 +1,7 @@
KBUILD_DEFCONFIG := sandbox_defconfig
-CPPFLAGS += -D__SANDBOX__ -fno-strict-aliasing
+CPPFLAGS += -D__SANDBOX__ -fno-strict-aliasing -fvisibility=hidden
+
machine-y := sandbox
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/6] sandbox: hostfile: allow probing from device tree
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
` (3 preceding siblings ...)
2019-08-27 14:32 ` [PATCH 4/6] sandbox: compile with symbol -fvisibility=hidden Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
2019-08-28 11:49 ` Sascha Hauer
2019-08-27 14:32 ` [PATCH 6/6] hwrng: add sandbox driver interface to host /dev/random Ahmad Fatoum
5 siblings, 1 reply; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
When testing things like barebox state in sandbox, it's nice to be able
to refer to a partition on a hostfile by phandle. Support this by
checking for reading the barebox,filename property.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/board/hostfile.c | 16 ++++--
arch/sandbox/dts/sandbox-state.dtsi | 50 +++++++++++++++++++
.../sandbox/mach-sandbox/include/mach/linux.h | 1 +
arch/sandbox/os/common.c | 5 ++
4 files changed, 68 insertions(+), 4 deletions(-)
create mode 100644 arch/sandbox/dts/sandbox-state.dtsi
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 745f078d1a79..e5a7580d0792 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -84,15 +84,16 @@ static int hf_probe(struct device_d *dev)
if (!dev->device_node)
return -ENODEV;
- err = of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd);
- if (err)
- return err;
+ of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd);
err = of_property_read_string(dev->device_node, "barebox,filename",
&priv->filename);
if (err)
return err;
+ if (!priv->fd)
+ priv->fd = linux_open(priv->filename, true);
+
priv->cdev.name = dev->device_node->name;
priv->cdev.dev = dev;
priv->cdev.ops = &hf_fops;
@@ -101,7 +102,14 @@ static int hf_probe(struct device_d *dev)
dev->info = hf_info;
dev->priv = priv;
- return devfs_create(&priv->cdev);
+ err = devfs_create(&priv->cdev);
+ if (err)
+ return err;
+
+ of_parse_partitions(&priv->cdev, dev->device_node);
+ of_partitions_register_fixup(&priv->cdev);
+
+ return 0;
}
static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
diff --git a/arch/sandbox/dts/sandbox-state.dtsi b/arch/sandbox/dts/sandbox-state.dtsi
new file mode 100644
index 000000000000..fc17bd078899
--- /dev/null
+++ b/arch/sandbox/dts/sandbox-state.dtsi
@@ -0,0 +1,50 @@
+/ {
+ aliases {
+ state = &state;
+ };
+
+ disk {
+ compatible = "barebox,hostfile";
+ barebox,filename = "disk";
+ reg = <0x0 0x0 0x100000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ hostfile_state: state@0 {
+ reg = <0x0 0x1000>;
+ label = "state";
+ };
+ };
+ };
+
+ state: state {
+ magic = <0xaa3b86a6>;
+ compatible = "barebox,state";
+ backend-type = "raw";
+ backend = <&hostfile_state>;
+ backend-storage-type = "direct";
+ backend-stridesize = <64>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ vars {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ x {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <1>;
+ };
+
+ y {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+ };
+ };
+};
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index 7d0ed55735e7..c344285473e6 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -10,6 +10,7 @@ struct fb_bitfield;
int linux_register_device(const char *name, void *start, void *end);
int tap_alloc(const char *dev);
uint64_t linux_get_time(void);
+int linux_open(const char *filename, int readwrite);
int linux_read(int fd, void *buf, size_t count);
int linux_read_nonblock(int fd, void *buf, size_t count);
ssize_t linux_write(int fd, const void *buf, size_t count);
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index a7ea8f2d3b18..86118822a177 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -121,6 +121,11 @@ void __attribute__((noreturn)) linux_exit(void)
exit(0);
}
+int linux_open(const char *filename, int readwrite)
+{
+ return open(filename, readwrite ? O_RDWR : O_RDONLY);
+}
+
int linux_read(int fd, void *buf, size_t count)
{
ssize_t ret;
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/6] hwrng: add sandbox driver interface to host /dev/random
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
` (4 preceding siblings ...)
2019-08-27 14:32 ` [PATCH 5/6] sandbox: hostfile: allow probing from device tree Ahmad Fatoum
@ 2019-08-27 14:32 ` Ahmad Fatoum
5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-27 14:32 UTC (permalink / raw)
To: barebox
Linux as well as other operating systems can provide /dev/random and
/dev/urandom device to service userspace need for randomness.
Add a driver to use /dev/random for blocking and /dev/urandom for
non-blocking barebox random numbers.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
arch/sandbox/board/Makefile | 1 +
arch/sandbox/board/board.c | 7 +++
arch/sandbox/board/dev-random.c | 24 +++++++
.../sandbox/mach-sandbox/include/mach/linux.h | 7 +++
drivers/hw_random/Kconfig | 8 +++
drivers/hw_random/Makefile | 1 +
drivers/hw_random/dev-random.c | 63 +++++++++++++++++++
7 files changed, 111 insertions(+)
create mode 100644 arch/sandbox/board/dev-random.c
create mode 100644 drivers/hw_random/dev-random.c
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
index b6c271c858c6..26f6cb192269 100644
--- a/arch/sandbox/board/Makefile
+++ b/arch/sandbox/board/Makefile
@@ -5,5 +5,6 @@ obj-y += console.o
obj-y += devices.o
obj-y += dtb.o
obj-y += poweroff.o
+obj-y += dev-random.o
extra-y += barebox.lds
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c
index 1f6392d15ed3..ad2bc910c342 100644
--- a/arch/sandbox/board/board.c
+++ b/arch/sandbox/board/board.c
@@ -42,6 +42,11 @@ static struct device_d sdl_device = {
.platform_data = &mode,
};
+static struct device_d devrandom_device = {
+ .id = DEVICE_ID_DYNAMIC,
+ .name = "devrandom",
+};
+
static int devices_init(void)
{
platform_device_register(&tap_device);
@@ -54,6 +59,8 @@ static int devices_init(void)
platform_device_register(&sdl_device);
+ platform_device_register(&devrandom_device);
+
return 0;
}
diff --git a/arch/sandbox/board/dev-random.c b/arch/sandbox/board/dev-random.c
new file mode 100644
index 000000000000..f65e5ef6e5ed
--- /dev/null
+++ b/arch/sandbox/board/dev-random.c
@@ -0,0 +1,24 @@
+#include <common.h>
+#include <mach/linux.h>
+
+devrandom_t *devrandom_init(void) {
+ devrandom_t *fds = xzalloc(sizeof(*fds));
+
+ fds->randomfd = linux_open("/dev/random", false);
+ if (fds->randomfd < 0)
+ return ERR_PTR(-EPERM);
+
+ fds->urandomfd = linux_open("/dev/urandom", false);
+ if (fds->urandomfd < 0)
+ return ERR_PTR(-EPERM);
+
+ return fds;
+}
+
+int devrandom_read(devrandom_t *devrandom, void *buf, size_t len, int wait)
+{
+ if (wait)
+ return linux_read(devrandom->randomfd, buf, len);
+
+ return linux_read(devrandom->urandomfd, buf, len);
+}
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index c344285473e6..1e64d41c6a5e 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -51,4 +51,11 @@ void barebox_libftdi1_gpio_set_value(struct ft2232_bitbang *ftbb,
int barebox_libftdi1_update(struct ft2232_bitbang *ftbb);
void barebox_libftdi1_close(void);
+typedef struct {
+ int randomfd;
+ int urandomfd;
+} devrandom_t;
+devrandom_t *devrandom_init(void);
+int devrandom_read(devrandom_t *devrandom, void *buf, size_t len, int wait);
+
#endif /* __ASM_ARCH_LINUX_H */
diff --git a/drivers/hw_random/Kconfig b/drivers/hw_random/Kconfig
index d1297a48d0bb..c57928204d30 100644
--- a/drivers/hw_random/Kconfig
+++ b/drivers/hw_random/Kconfig
@@ -14,4 +14,12 @@ config HWRNG_MXC_RNGC
This driver provides kernel-side support for the Random Number
Generator hardware found on some Freescale i.MX processors.
+config HWRNG_DEV_RANDOM
+ tristate "Linux /dev/random and /dev/urandom RNG"
+ depends on SANDBOX
+ default y
+ help
+ This driver allows use of the host provided /dev/random
+ and /dev/urandom as barebox HWRNGs.
+
endif
diff --git a/drivers/hw_random/Makefile b/drivers/hw_random/Makefile
index 79c238c48d60..8be62f38b740 100644
--- a/drivers/hw_random/Makefile
+++ b/drivers/hw_random/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_HWRNG) += core.o
obj-$(CONFIG_HWRNG_MXC_RNGC) += mxc-rngc.o
+obj-$(CONFIG_HWRNG_DEV_RANDOM) += dev-random.o
diff --git a/drivers/hw_random/dev-random.c b/drivers/hw_random/dev-random.c
new file mode 100644
index 000000000000..2170db7437ce
--- /dev/null
+++ b/drivers/hw_random/dev-random.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Ahmad Fatoum, Pengutronix
+ */
+
+#include <common.h>
+#include <init.h>
+#include <linux/hw_random.h>
+#include <mach/linux.h>
+
+struct devrandom_rnd {
+ struct hwrng hwrng;
+ devrandom_t *priv;
+};
+
+static inline struct devrandom_rnd *to_rnd(struct hwrng *hwrng)
+{
+ return container_of(hwrng, struct devrandom_rnd, hwrng);
+}
+
+static int devrandom_rnd_read(struct hwrng *hwrng, void *buf, size_t max, bool wait)
+{
+ return devrandom_read(to_rnd(hwrng)->priv, buf, max, wait);
+}
+
+static int devrandom_rnd_init(struct hwrng *hwrng)
+{
+ devrandom_t *devrandom = devrandom_init();
+ if (IS_ERR(devrandom))
+ return PTR_ERR(devrandom);
+
+ to_rnd(hwrng)->priv = devrandom;
+ return 0;
+}
+
+static int devrandom_rnd_probe(struct device_d *dev)
+{
+ struct devrandom_rnd *rnd;
+ int ret;
+
+ rnd = xzalloc(sizeof(*rnd));
+
+ rnd->hwrng.name = dev->name;
+ rnd->hwrng.read = devrandom_rnd_read;
+ rnd->hwrng.init = devrandom_rnd_init;
+
+ ret = hwrng_register(dev, &rnd->hwrng);
+ if (ret) {
+ dev_err(dev, "failed to register: %s\n", strerror(-ret));
+
+ return ret;
+ }
+
+ dev_info(dev, "Registered.\n");
+
+ return 0;
+}
+
+static struct driver_d devrandom_rnd_driver = {
+ .name = "devrandom",
+ .probe = devrandom_rnd_probe,
+};
+device_platform_driver(devrandom_rnd_driver);
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 5/6] sandbox: hostfile: allow probing from device tree
2019-08-27 14:32 ` [PATCH 5/6] sandbox: hostfile: allow probing from device tree Ahmad Fatoum
@ 2019-08-28 11:49 ` Sascha Hauer
2019-08-28 12:06 ` Ahmad Fatoum
0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2019-08-28 11:49 UTC (permalink / raw)
To: Ahmad Fatoum, g; +Cc: barebox
On Tue, Aug 27, 2019 at 04:32:38PM +0200, Ahmad Fatoum wrote:
> When testing things like barebox state in sandbox, it's nice to be able
> to refer to a partition on a hostfile by phandle. Support this by
> checking for reading the barebox,filename property.
>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> arch/sandbox/board/hostfile.c | 16 ++++--
> arch/sandbox/dts/sandbox-state.dtsi | 50 +++++++++++++++++++
> .../sandbox/mach-sandbox/include/mach/linux.h | 1 +
> arch/sandbox/os/common.c | 5 ++
> 4 files changed, 68 insertions(+), 4 deletions(-)
> create mode 100644 arch/sandbox/dts/sandbox-state.dtsi
>
> diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
> index 745f078d1a79..e5a7580d0792 100644
> --- a/arch/sandbox/board/hostfile.c
> +++ b/arch/sandbox/board/hostfile.c
> @@ -84,15 +84,16 @@ static int hf_probe(struct device_d *dev)
> if (!dev->device_node)
> return -ENODEV;
>
> - err = of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd);
> - if (err)
> - return err;
> + of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd);
>
> err = of_property_read_string(dev->device_node, "barebox,filename",
> &priv->filename);
> if (err)
> return err;
>
> + if (!priv->fd)
> + priv->fd = linux_open(priv->filename, true);
> +
> priv->cdev.name = dev->device_node->name;
> priv->cdev.dev = dev;
> priv->cdev.ops = &hf_fops;
> @@ -101,7 +102,14 @@ static int hf_probe(struct device_d *dev)
> dev->info = hf_info;
> dev->priv = priv;
>
> - return devfs_create(&priv->cdev);
> + err = devfs_create(&priv->cdev);
> + if (err)
> + return err;
> +
> + of_parse_partitions(&priv->cdev, dev->device_node);
> + of_partitions_register_fixup(&priv->cdev);
> +
> + return 0;
> }
>
> static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
> diff --git a/arch/sandbox/dts/sandbox-state.dtsi b/arch/sandbox/dts/sandbox-state.dtsi
> new file mode 100644
> index 000000000000..fc17bd078899
> --- /dev/null
> +++ b/arch/sandbox/dts/sandbox-state.dtsi
> @@ -0,0 +1,50 @@
This file doesn't belong into this patch.
Applied 1-4 for now.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 5/6] sandbox: hostfile: allow probing from device tree
2019-08-28 11:49 ` Sascha Hauer
@ 2019-08-28 12:06 ` Ahmad Fatoum
0 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2019-08-28 12:06 UTC (permalink / raw)
To: barebox
Hello Sascha,
On 8/28/19 1:49 PM, Sascha Hauer wrote:
> This file doesn't belong into this patch.
The file contains an example of how a barebox,hostfile node looks like.
Would you prefer I split if off into a separate patch?
Cheers
Ahmad
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-08-28 12:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 14:32 [PATCH 0/6] sandbox: add HWRNG driver for host /dev/random Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 1/6] sandbox: include header to provide missing prototype Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 2/6] sandbox: remove unused ARCH_LINUX Kconfig symbol Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 3/6] sandbox: redefine optarg and optind to avoid collisions Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 4/6] sandbox: compile with symbol -fvisibility=hidden Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 5/6] sandbox: hostfile: allow probing from device tree Ahmad Fatoum
2019-08-28 11:49 ` Sascha Hauer
2019-08-28 12:06 ` Ahmad Fatoum
2019-08-27 14:32 ` [PATCH 6/6] hwrng: add sandbox driver interface to host /dev/random Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox