diff options
-rw-r--r-- | arch/sandbox/Kconfig | 1 | ||||
-rw-r--r-- | arch/sandbox/Makefile | 2 | ||||
-rw-r--r-- | arch/sandbox/board/Makefile | 1 | ||||
-rw-r--r-- | arch/sandbox/board/dtb.c | 67 | ||||
-rw-r--r-- | arch/sandbox/board/hostfile.c | 113 | ||||
-rw-r--r-- | arch/sandbox/configs/sandbox_defconfig | 35 | ||||
-rw-r--r-- | arch/sandbox/dts/.gitignore | 1 | ||||
-rw-r--r-- | arch/sandbox/dts/Makefile | 11 | ||||
-rw-r--r-- | arch/sandbox/dts/sandbox.dts | 7 | ||||
-rw-r--r-- | arch/sandbox/dts/skeleton.dtsi | 13 | ||||
-rw-r--r-- | arch/sandbox/mach-sandbox/include/mach/hostfile.h | 11 | ||||
-rw-r--r-- | arch/sandbox/mach-sandbox/include/mach/linux.h | 2 | ||||
-rw-r--r-- | arch/sandbox/os/common.c | 107 | ||||
-rw-r--r-- | drivers/base/driver.c | 6 | ||||
-rw-r--r-- | drivers/of/base.c | 4 | ||||
-rw-r--r-- | drivers/of/of_path.c | 4 | ||||
-rw-r--r-- | fs/fs.c | 4 | ||||
-rw-r--r-- | include/driver.h | 2 | ||||
-rw-r--r-- | include/fs.h | 4 | ||||
-rw-r--r-- | include/of.h | 28 |
20 files changed, 321 insertions, 102 deletions
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 707fca3dc3..9c72673bde 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -1,5 +1,6 @@ config SANDBOX bool + select OFTREE default y config ARCH_TEXT_BASE diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index e3fb039554..a539a901fc 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -50,4 +50,6 @@ cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \ common-y += $(BOARD) arch/sandbox/os/ +common-$(CONFIG_OFTREE) += arch/sandbox/dts/ + CLEAN_FILES += $(BOARD)/barebox.lds diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile index 5104f5cb26..460116332d 100644 --- a/arch/sandbox/board/Makefile +++ b/arch/sandbox/board/Makefile @@ -3,5 +3,6 @@ obj-y += clock.o obj-y += hostfile.o obj-y += console.o obj-y += devices.o +obj-y += dtb.o extra-y += barebox.lds diff --git a/arch/sandbox/board/dtb.c b/arch/sandbox/board/dtb.c new file mode 100644 index 0000000000..af4a64a9c7 --- /dev/null +++ b/arch/sandbox/board/dtb.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * Copyright (c) 2015 Marc Kleine-Budde <mkl@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <common.h> +#include <init.h> +#include <of.h> + +#include <mach/linux.h> +#include <linux/err.h> + +static const void *dtb; + +int barebox_register_dtb(const void *new_dtb) +{ + if (dtb) + return -EBUSY; + + dtb = new_dtb; + + return 0; +} + +static int of_sandbox_init(void) +{ + struct device_node *root; + int ret; + + if (dtb) { + root = of_unflatten_dtb(dtb); + } else { + root = of_new_node(NULL, NULL); + + ret = of_property_write_u32(root, "#address-cells", 2); + if (ret) + return ret; + + ret = of_property_write_u32(root, "#size-cells", 1); + if (ret) + return ret; + } + + if (IS_ERR(root)) + return PTR_ERR(root); + + of_set_root_node(root); + of_fix_tree(root); + if (IS_ENABLED(CONFIG_OFDEVICE)) + of_probe(); + + return 0; +} +core_initcall(of_sandbox_init); diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index ac29cfa47a..c1a2643bc7 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -23,18 +23,22 @@ #include <mach/linux.h> #include <init.h> #include <errno.h> +#include <linux/err.h> #include <mach/hostfile.h> #include <xfuncs.h> +#include <linux/err.h> + struct hf_priv { struct cdev cdev; - struct hf_platform_data *pdata; + const char *filename; + int fd; }; static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) { - struct hf_platform_data *hf = cdev->priv; - int fd = hf->fd; + struct hf_priv *priv= cdev->priv; + int fd = priv->fd; if (linux_lseek(fd, offset) != offset) return -EINVAL; @@ -44,8 +48,8 @@ static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) { - struct hf_platform_data *hf = cdev->priv; - int fd = hf->fd; + struct hf_priv *priv = cdev->priv; + int fd = priv->fd; if (linux_lseek(fd, offset) != offset) return -EINVAL; @@ -55,9 +59,9 @@ static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t static void hf_info(struct device_d *dev) { - struct hf_platform_data *hf = dev->platform_data; + struct hf_priv *priv = dev->priv; - printf("file: %s\n", hf->filename); + printf("file: %s\n", priv->filename); } static struct file_operations hf_fops = { @@ -68,48 +72,87 @@ static struct file_operations hf_fops = { static int hf_probe(struct device_d *dev) { - struct hf_platform_data *hf = dev->platform_data; struct hf_priv *priv = xzalloc(sizeof(*priv)); + struct resource *res; + int err; + + res = dev_get_resource(dev, IORESOURCE_MEM, 0); + if (IS_ERR(res)) + return PTR_ERR(res); + + priv->cdev.size = resource_size(res); - priv->pdata = hf; + if (!dev->device_node) + return -ENODEV; - priv->cdev.name = hf->name; - priv->cdev.size = hf->size; + err = of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd); + if (err) + return err; + + err = of_property_read_string(dev->device_node, "barebox,filename", + &priv->filename); + if (err) + return err; + + priv->cdev.name = dev->device_node->name; + priv->cdev.dev = dev; priv->cdev.ops = &hf_fops; - priv->cdev.priv = hf; + priv->cdev.priv = priv; dev->info = hf_info; + dev->priv = priv; -#ifdef CONFIG_FS_DEVFS - devfs_create(&priv->cdev); -#endif - - return 0; + return devfs_create(&priv->cdev); } +static __maybe_unused struct of_device_id hostfile_dt_ids[] = { + { + .compatible = "barebox,hostfile", + }, { + /* sentinel */ + } +}; + static struct driver_d hf_drv = { .name = "hostfile", + .of_compatible = DRV_OF_COMPAT(hostfile_dt_ids), .probe = hf_probe, }; -device_platform_driver(hf_drv); +coredevice_platform_driver(hf_drv); -int barebox_register_filedev(struct hf_platform_data *hf) +static int of_hostfile_fixup(struct device_node *root, void *ctx) { - 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; + struct hf_info *hf = ctx; + struct device_node *node; + uint32_t reg[] = { + hf->base >> 32, + hf->base, + hf->size + }; + int ret; + + node = of_new_node(root, hf->devname); + + ret = of_set_property(node, "compatible", hostfile_dt_ids->compatible, + strlen(hostfile_dt_ids->compatible) + 1, 1); + if (ret) + return ret; + + ret = of_property_write_u32_array(node, "reg", reg, ARRAY_SIZE(reg)); + if (ret) + return ret; + + ret = of_property_write_u32(node, "barebox,fd", hf->fd); + if (ret) + return ret; + + ret = of_set_property(node, "barebox,filename", hf->filename, + strlen(hf->filename) + 1, 1); + + return ret; +} - return sandbox_add_device(dev); +int barebox_register_filedev(struct hf_info *hf) +{ + return of_register_fixup(of_hostfile_fixup, hf); } diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig index 7ce2569501..ec045f7c0b 100644 --- a/arch/sandbox/configs/sandbox_defconfig +++ b/arch/sandbox/configs/sandbox_defconfig @@ -5,25 +5,36 @@ CONFIG_PARTITION=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/sandbox/board/env" CONFIG_DEBUG_INFO=y -CONFIG_CMD_EDIT=y -CONFIG_CMD_SLEEP=y -CONFIG_CMD_SAVEENV=y -CONFIG_CMD_EXPORT=y -CONFIG_CMD_PRINTENV=y -CONFIG_CMD_READLINE=y -CONFIG_CMD_TFTP=y +CONFIG_LONGHELP=y CONFIG_CMD_MEMINFO=y -CONFIG_CMD_CRC=y -CONFIG_CMD_FLASH=y # CONFIG_CMD_BOOTM is not set -CONFIG_CMD_RESET=y CONFIG_CMD_GO=y -CONFIG_CMD_TIMEOUT=y +CONFIG_CMD_RESET=y CONFIG_CMD_PARTITION=y -CONFIG_NET=y +CONFIG_CMD_EXPORT=y +CONFIG_CMD_PRINTENV=y +CONFIG_CMD_MAGICVAR=y +CONFIG_CMD_MAGICVAR_HELP=y +CONFIG_CMD_SAVEENV=y +CONFIG_CMD_SLEEP=y CONFIG_CMD_DHCP=y CONFIG_CMD_PING=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_EDIT=y +CONFIG_CMD_READLINE=y +CONFIG_CMD_TIMEOUT=y +CONFIG_CMD_CRC=y +CONFIG_CMD_FLASH=y +CONFIG_CMD_2048=y +CONFIG_CMD_OF_NODE=y +CONFIG_CMD_OF_PROPERTY=y +CONFIG_CMD_OF_DISPLAY_TIMINGS=y +CONFIG_CMD_OFTREE=y +CONFIG_NET=y +CONFIG_OFDEVICE=y +CONFIG_OF_BAREBOX_DRIVERS=y CONFIG_DRIVER_NET_TAP=y # CONFIG_SPI is not set +# CONFIG_PINCTRL is not set CONFIG_FS_CRAMFS=y CONFIG_FS_TFTP=y diff --git a/arch/sandbox/dts/.gitignore b/arch/sandbox/dts/.gitignore new file mode 100644 index 0000000000..077903c50a --- /dev/null +++ b/arch/sandbox/dts/.gitignore @@ -0,0 +1 @@ +*dtb* diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile new file mode 100644 index 0000000000..6f68388578 --- /dev/null +++ b/arch/sandbox/dts/Makefile @@ -0,0 +1,11 @@ +ifeq ($(CONFIG_OFTREE),y) +dtb-y += \ + sandbox.dtb +endif + +# just to build a built-in.o. Otherwise compilation fails when no devicetree is +# created. +obj- += dummy.o + +always := $(dtb-y) +clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts new file mode 100644 index 0000000000..2595aa13fa --- /dev/null +++ b/arch/sandbox/dts/sandbox.dts @@ -0,0 +1,7 @@ +/dts-v1/; + +#include "skeleton.dtsi" + +/ { + +}; diff --git a/arch/sandbox/dts/skeleton.dtsi b/arch/sandbox/dts/skeleton.dtsi new file mode 100644 index 0000000000..38ead821bb --- /dev/null +++ b/arch/sandbox/dts/skeleton.dtsi @@ -0,0 +1,13 @@ +/* + * Skeleton device tree; the bare minimum needed to boot; just include and + * add a compatible value. The bootloader will typically populate the memory + * node. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + chosen { }; + aliases { }; + memory { device_type = "memory"; reg = <0 0 0>; }; +}; diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h index 7c4e67cf68..627fe28e76 100644 --- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h +++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h @@ -1,15 +1,14 @@ #ifndef __ASM_ARCH_HOSTFILE_H #define __ASM_ARCH_HOSTFILE_H -struct hf_platform_data { +struct hf_info { int fd; - size_t size; unsigned long base; - char *filename; - char *name; + size_t size; + const char *devname; + const char *filename; }; -int barebox_register_filedev(struct hf_platform_data *hf); +int barebox_register_filedev(struct hf_info *hf); #endif /* __ASM_ARCH_HOSTFILE_H */ - diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 98f9067046..990173e10b 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -20,6 +20,8 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[]); int barebox_register_console(char *name_template, int stdinfd, int stdoutfd); +int barebox_register_dtb(const void *dtb); + struct linux_console_data { int stdinfd; int stdoutfd; diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 0854fb5d80..d627391890 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -206,31 +206,41 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[]) extern void start_barebox(void); extern void mem_malloc_init(void *start, void *end); -static int add_image(char *str, char *name) +static int add_image(char *str, char *devname_template, int *devname_number) { - char *file; - int readonly = 0, map = 1; + struct hf_info *hf = malloc(sizeof(struct hf_info)); + char *filename, *devname; + char tmp[16]; + int readonly = 0; struct stat s; char *opt; int fd, ret; - struct hf_platform_data *hf = malloc(sizeof(struct hf_platform_data)); if (!hf) return -1; - file = strtok(str, ","); + filename = strtok(str, ","); while ((opt = strtok(NULL, ","))) { if (!strcmp(opt, "ro")) readonly = 1; - if (!strcmp(opt, "map")) - map = 1; } - printf("add file %s(%s)\n", file, readonly ? "ro" : ""); + /* parses: "devname=filename" */ + devname = strtok(filename, "="); + filename = strtok(NULL, "="); + if (!filename) { + filename = devname; + snprintf(tmp, sizeof(tmp), + devname_template, (*devname_number)++); + devname = strdup(tmp); + } + + printf("add %s backed by file %s%s\n", devname, + filename, readonly ? "(ro)" : ""); - fd = open(file, readonly ? O_RDONLY : O_RDWR); + fd = open(filename, readonly ? O_RDONLY : O_RDWR); hf->fd = fd; - hf->filename = file; + hf->filename = filename; if (fd < 0) { perror("open"); @@ -243,15 +253,13 @@ static int add_image(char *str, char *name) } hf->size = s.st_size; - hf->name = strdup(name); - - if (map) { - hf->base = (unsigned long)mmap(NULL, hf->size, - PROT_READ | (readonly ? 0 : PROT_WRITE), - MAP_SHARED, fd, 0); - if ((void *)hf->base == MAP_FAILED) - printf("warning: mmapping %s failed\n", file); - } + hf->devname = strdup(devname); + + hf->base = (unsigned long)mmap(NULL, hf->size, + PROT_READ | (readonly ? 0 : PROT_WRITE), + MAP_SHARED, fd, 0); + if ((void *)hf->base == MAP_FAILED) + printf("warning: mmapping %s failed\n", filename); ret = barebox_register_filedev(hf); if (ret) @@ -265,6 +273,42 @@ err_out: return -1; } +static int add_dtb(const char *file) +{ + struct stat s; + void *dtb = NULL; + int fd; + + fd = open(file, O_RDONLY); + if (fd < 0) { + perror("open"); + goto err_out; + } + + if (fstat(fd, &s)) { + perror("fstat"); + goto err_out; + } + + dtb = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (dtb == MAP_FAILED) { + perror("mmap"); + goto err_out; + } + + if (barebox_register_dtb(dtb)) + goto err_out; + + return 0; + + err_out: + if (dtb) + munmap(dtb, s.st_size); + if (fd > 0) + close(fd); + return -1; +} + static void print_usage(const char*); static struct option long_options[] = { @@ -272,6 +316,7 @@ static struct option long_options[] = { {"malloc", 1, 0, 'm'}, {"image", 1, 0, 'i'}, {"env", 1, 0, 'e'}, + {"dtb", 1, 0, 'd'}, {"stdout", 1, 0, 'O'}, {"stdin", 1, 0, 'I'}, {"xres", 1, 0, 'x'}, @@ -279,14 +324,13 @@ static struct option long_options[] = { {0, 0, 0, 0}, }; -static const char optstring[] = "hm:i:e:O:I:x:y:"; +static const char optstring[] = "hm:i:e:d:O:I:x:y:"; int main(int argc, char *argv[]) { void *ram; int opt, ret, fd; int malloc_size = CONFIG_MALLOC_SIZE; - char str[6]; int fdno = 0, envno = 0, option_index = 0; while (1) { @@ -308,6 +352,13 @@ int main(int argc, char *argv[]) break; case 'e': break; + case 'd': + ret = add_dtb(optarg); + if (ret) { + printf("Failed to load dtb: '%s'\n", optarg); + exit(1); + } + break; case 'O': fd = open(optarg, O_WRONLY); if (fd < 0) { @@ -361,18 +412,14 @@ int main(int argc, char *argv[]) switch (opt) { case 'i': - sprintf(str, "fd%d", fdno); - ret = add_image(optarg, str); + ret = add_image(optarg, "fd%d", &fdno); if (ret) exit(1); - fdno++; break; case 'e': - sprintf(str, "env%d", envno); - ret = add_image(optarg, str); + ret = add_image(optarg, "env%d", &envno); if (ret) exit(1); - envno++; break; default: break; @@ -399,15 +446,19 @@ static void print_usage(const char *prgname) "Usage: %s [OPTIONS]\n" "Start barebox.\n\n" "Options:\n\n" -" -m, --malloc=<size> Start sandbox with a specified malloc-space size in bytes.\n" +" -m, --malloc=<size> Start sandbox with a specified malloc-space size in bytes.\n" " -i, --image=<file> Map an image file to barebox. This option can be given\n" " multiple times. The files will show up as\n" " /dev/fd0 ... /dev/fdx under barebox.\n" +" -i, --image=<dev>=<file>\n" +" Same as above, the files will show up as\n" +" /dev/<dev>\n" " -e, --env=<file> Map a file with an environment to barebox. With this \n" " option, files are mapped as /dev/env0 ... /dev/envx\n" " and thus are used as the default environment.\n" " An empty file generated with dd will do to get started\n" " with an empty environment.\n" +" -d, --dtb=<file> Map a device tree binary blob (dtb) into barebox.\n" " -O, --stdout=<file> Register a file as a console capable of doing stdout.\n" " <file> can be a regular file or a FIFO.\n" " -I, --stdin=<file> Register a file as a console capable of doing stdin.\n" diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 81b35031a1..3363b56675 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -350,12 +350,6 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num) } EXPORT_SYMBOL(dev_request_mem_region); -int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot) -{ - printf("%s: currently broken\n", __func__); - return -EINVAL; -} - int generic_memmap_ro(struct cdev *cdev, void **map, int flags) { if (!cdev->dev) diff --git a/drivers/of/base.c b/drivers/of/base.c index af10fd1da3..d45d3941b8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -184,7 +184,7 @@ void of_alias_scan(void) end--; len = end - start; - id = simple_strtol(end, 0, 10); + id = simple_strtol(end, NULL, 10); if (id < 0) continue; @@ -280,7 +280,7 @@ struct device_node *of_find_node_by_phandle_from(phandle phandle, root = root_node; if (!root) - return 0; + return NULL; of_tree_for_each_node_from(node, root) if (node->phandle == phandle) diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index f0fd917ada..df63c5782a 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -132,9 +132,9 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath) struct of_path op = {}; struct device_node *rnode; const char *path, *str; - int i, len, ret; + int i, ret; - path = of_get_property(node, propname, &len); + path = of_get_property(node, propname, NULL); if (!path) return -EINVAL; @@ -923,7 +923,7 @@ out: } EXPORT_SYMBOL(lseek); -int erase(int fd, size_t count, unsigned long offset) +int erase(int fd, size_t count, loff_t offset) { struct fs_driver_d *fsdrv; FILE *f; @@ -950,7 +950,7 @@ int erase(int fd, size_t count, unsigned long offset) } EXPORT_SYMBOL(erase); -int protect(int fd, size_t count, unsigned long offset, int prot) +int protect(int fd, size_t count, loff_t offset, int prot) { struct fs_driver_d *fsdrv; FILE *f; diff --git a/include/driver.h b/include/driver.h index 76fd4b1720..0ee3b4554f 100644 --- a/include/driver.h +++ b/include/driver.h @@ -331,8 +331,6 @@ struct driver_d *get_driver_by_name(const char *name); struct cdev; -int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot); - /* These are used by drivers which work with direct memory accesses */ ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags); ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags); diff --git a/include/fs.h b/include/fs.h index 63e35ca815..b8a95a20a7 100644 --- a/include/fs.h +++ b/include/fs.h @@ -147,8 +147,8 @@ int mount (const char *device, const char *fsname, const char *path, int umount(const char *pathname); /* not-so-standard functions */ -int erase(int fd, size_t count, unsigned long offset); -int protect(int fd, size_t count, unsigned long offset, int prot); +int erase(int fd, size_t count, loff_t offset); +int protect(int fd, size_t count, loff_t offset, int prot); int protect_file(const char *file, int prot); void *memmap(int fd, int flags); diff --git a/include/of.h b/include/of.h index 2ad941864f..764a2e5939 100644 --- a/include/of.h +++ b/include/of.h @@ -61,7 +61,6 @@ struct device_d; struct driver_d; int of_fix_tree(struct device_node *); -int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context); int of_match(struct device_d *dev, struct driver_d *drv); @@ -240,6 +239,11 @@ void of_add_memory_bank(struct device_node *node, bool dump, int r, u64 base, u64 size); struct device_d *of_find_device_by_node_path(const char *path); int of_find_path(struct device_node *node, const char *propname, char **outpath); +int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context); +struct device_node *of_find_node_by_alias(struct device_node *root, + const char *alias); +struct device_node *of_find_node_by_path_or_alias(struct device_node *root, + const char *str); #else static inline int of_parse_partitions(struct cdev *cdev, struct device_node *node) @@ -596,6 +600,24 @@ static inline struct device_d *of_device_enable_and_register_by_name( { return NULL; } + +static inline int of_register_fixup(int (*fixup)(struct device_node *, void *), + void *context) +{ + return -ENOSYS; +} + +static inline struct device_node *of_find_node_by_alias( + struct device_node *root, const char *alias) +{ + return NULL; +} + +static inline struct device_node *of_find_node_by_path_or_alias( + struct device_node *root, const char *str) +{ + return NULL; +} #endif #define for_each_node_by_name(dn, name) \ @@ -731,10 +753,6 @@ int of_device_disable_path(const char *path); phandle of_get_tree_max_phandle(struct device_node *root); phandle of_node_create_phandle(struct device_node *node); int of_set_property_to_child_phandle(struct device_node *node, char *prop_name); -struct device_node *of_find_node_by_alias(struct device_node *root, - const char *alias); -struct device_node *of_find_node_by_path_or_alias(struct device_node *root, - const char *str); static inline struct device_node *of_find_root_node(struct device_node *node) { |