From 6019a3d07d7258908c764289b43786d255c6c329 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 25 Jul 2017 14:46:56 -0500 Subject: of: enable unittests on UML The unittests can run on UML, but OF_IRQ and OF_ADDRESS need to be enabled. Rework the kconfig dependencies to enable the unittests. The unittests cannot build on Sparc, so we need to add an explicit dependency for !SPARC. There's one failure in overlay tests because the base DT is not unflattened early. Cc: Thomas Meyer Signed-off-by: Rob Herring --- drivers/of/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index ad9a9578f9c4..5020d7ef7494 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -13,7 +13,8 @@ if OF config OF_UNITTEST bool "Device Tree runtime unit tests" - depends on OF_IRQ + depends on !SPARC + select IRQ_DOMAIN select OF_EARLY_FLATTREE select OF_RESOLVE help @@ -61,7 +62,7 @@ config OF_DYNAMIC config OF_ADDRESS def_bool y - depends on !SPARC && HAS_IOMEM + depends on !SPARC && (HAS_IOMEM || UML) select OF_ADDRESS_PCI if PCI config OF_ADDRESS_PCI -- cgit v1.2.3 From fae3b9cd70bd0f6f80df1843cb243f7ac4d8b4c3 Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Wed, 6 Dec 2017 23:43:34 +0100 Subject: of: irq: Fix function description comment Make small cleanup in function description for of_irq_parse_raw Signed-off-by: Vasyl Gomonovych Signed-off-by: Rob Herring --- drivers/of/irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/irq.c b/drivers/of/irq.c index ec00ae7384c2..7dcea86e052c 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -83,9 +83,8 @@ EXPORT_SYMBOL_GPL(of_irq_find_parent); /** * of_irq_parse_raw - Low level interrupt tree parsing - * @parent: the device interrupt parent * @addr: address specifier (start of "reg" property of the device) in be32 format - * @out_irq: structure of_irq updated by this function + * @out_irq: structure of_phandle_args updated by this function * * Returns 0 on success and a negative number on error * -- cgit v1.2.3 From af6074fc9aa4b29517375634189ada1869eea598 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 27 Dec 2017 12:55:14 -0600 Subject: of: Use SPDX license tag for DT files Convert remaining DT files to use SPDX-License-Identifier tags. Cc: Benjamin Herrenschmidt Cc: Guennadi Liakhovetski Cc: Paul Mackerras Cc: Pantelis Antoniou Reviewed-by: Frank Rowand Reviewed-by: Philippe Ombredanne Signed-off-by: Rob Herring --- drivers/of/Kconfig | 1 + drivers/of/address.c | 2 +- drivers/of/base.c | 6 +----- drivers/of/device.c | 1 + drivers/of/dynamic.c | 1 + drivers/of/fdt.c | 5 +---- drivers/of/fdt_address.c | 6 +----- drivers/of/irq.c | 6 +----- drivers/of/kobj.c | 2 +- drivers/of/of_numa.c | 13 +------------ drivers/of/of_private.h | 6 +----- drivers/of/of_reserved_mem.c | 6 +----- drivers/of/overlay.c | 5 +---- drivers/of/pdt.c | 6 +----- drivers/of/platform.c | 7 +------ drivers/of/property.c | 6 +----- drivers/of/resolver.c | 5 +---- drivers/of/unittest-data/overlay_bad_symbol.dts | 1 + 18 files changed, 18 insertions(+), 67 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 5020d7ef7494..06898039d11e 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 config DTC bool diff --git a/drivers/of/address.c b/drivers/of/address.c index fa6cabfc3cb9..6391604a6f8f 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #define pr_fmt(fmt) "OF: " fmt #include diff --git a/drivers/of/base.c b/drivers/of/base.c index 26618ba8f92a..dd0b4201f1cc 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Procedures for creating, accessing and interpreting the device tree. * @@ -11,11 +12,6 @@ * * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and * Grant Likely. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. */ #define pr_fmt(fmt) "OF: " fmt diff --git a/drivers/of/device.c b/drivers/of/device.c index 25bddf9c9fe1..064c818105bd 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index ab988d88704d..7bb33d22b4e2 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Support for dynamic device trees. * diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 4675e5ac4d11..7db5353a24c0 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Functions for working with the Flattened Device Tree data format * * Copyright 2009 Benjamin Herrenschmidt, IBM Corp * benh@kernel.crashing.org - * - * 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. */ #define pr_fmt(fmt) "OF: fdt: " fmt diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c index 843a542dac7d..1dc15ab78b10 100644 --- a/drivers/of/fdt_address.c +++ b/drivers/of/fdt_address.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * FDT Address translation based on u-boot fdt_support.c which in turn was * based on the kernel unflattened DT address translation code. @@ -6,11 +7,6 @@ * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com * * Copyright 2010-2011 Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. */ #define pr_fmt(fmt) "OF: fdt: " fmt diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 7dcea86e052c..02ad93a304a4 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Derived from arch/i386/kernel/irq.c * Copyright (C) 1992 Linus Torvalds @@ -8,11 +9,6 @@ * Adapted for Power Macintosh by Paul Mackerras * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au) * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * * This file contains the code used to make IRQ descriptions in the * device tree to actual irq numbers on an interrupt controller * driver. diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 250fc7bb550f..7a0a18980b98 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include @@ -161,4 +162,3 @@ void __of_detach_node_sysfs(struct device_node *np) /* finally remove the kobj_init ref */ of_node_put(np); } - diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 2db1f7a04baf..f9d5480a4ae5 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -1,19 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * OF NUMA Parsing support. * * Copyright (C) 2015 - 2016 Cavium Inc. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ #define pr_fmt(fmt) "OF: NUMA: " fmt diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 92a9a3687446..0c609e7d0334 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ #ifndef _LINUX_OF_PRIVATE_H #define _LINUX_OF_PRIVATE_H /* @@ -5,11 +6,6 @@ * * Paul Mackerras August 1996. * Copyright (C) 1996-2005 Paul Mackerras. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. */ /** diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 22b75c82e377..9a4f4246231d 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Device tree based initialization code for reserved memory. * @@ -6,11 +7,6 @@ * http://www.samsung.com * Author: Marek Szyprowski * Author: Josh Cartwright - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License or (at your optional) any later version of the license. */ #define pr_fmt(fmt) "OF: reserved mem: " fmt diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 3981b7da4fa9..3397d7642958 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Functions for working with device tree overlays * * Copyright (C) 2012 Pantelis Antoniou * Copyright (C) 2012 Texas Instruments Inc. - * - * 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. */ #define pr_fmt(fmt) "OF: overlay: " fmt diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index d2acae825af9..013e65de074a 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* pdt.c: OF PROM device tree support code. * * Paul Mackerras August 1996. @@ -8,11 +9,6 @@ * * Adapted for sparc by David S. Miller davem@davemloft.net * Adapted for multiple architectures by Andres Salomon - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. */ #include diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b7cf84b29737..d67dbdab40d1 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -1,15 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. * * and Arnd Bergmann, IBM Corp. * Merged from powerpc/kernel/of_platform.c and * sparc{,64}/kernel/of_device.c by Stephen Rothwell - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * */ #define pr_fmt(fmt) "OF: " fmt diff --git a/drivers/of/property.c b/drivers/of/property.c index 8ad33a44a7b8..2b22560b60c1 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * drivers/of/property.c - Procedures for accessing and interpreting * Devicetree properties and graphs. @@ -16,11 +17,6 @@ * * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and * Grant Likely. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. */ #define pr_fmt(fmt) "OF: " fmt diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index cfaeef5f6cb1..740d19bde601 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Functions for dealing with DT resolution * * Copyright (C) 2012 Pantelis Antoniou * Copyright (C) 2012 Texas Instruments Inc. - * - * 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. */ #define pr_fmt(fmt) "OF: resolver: " fmt diff --git a/drivers/of/unittest-data/overlay_bad_symbol.dts b/drivers/of/unittest-data/overlay_bad_symbol.dts index 09261cb9a67e..135052ee1517 100644 --- a/drivers/of/unittest-data/overlay_bad_symbol.dts +++ b/drivers/of/unittest-data/overlay_bad_symbol.dts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /dts-v1/; /plugin/; -- cgit v1.2.3 From 0fa1c579349fdd90173381712ad78aa99c09d38b Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 5 Jan 2018 15:32:33 -0600 Subject: of/fdt: use memblock_virt_alloc for early alloc memblock_virt_alloc() works for both memblock and bootmem, so use it and make early_init_dt_alloc_memory_arch a static function. The arches using bootmem define early_init_dt_alloc_memory_arch as either: __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)) or: alloc_bootmem_align(size, align) Both of these evaluate to the same thing as does memblock_virt_alloc for bootmem. So we can disable the arch specific functions by making early_init_dt_alloc_memory_arch static and they can be removed in subsequent commits. Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/fdt.c | 16 ++++------------ drivers/of/unittest.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 7db5353a24c0..84aa9d676375 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1180,14 +1181,6 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, return memblock_reserve(base, size); } -/* - * called from unflatten_device_tree() to bootstrap devicetree itself - * Architectures can override this definition if memblock isn't used - */ -void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) -{ - return __va(memblock_alloc(size, align)); -} #else void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) { @@ -1206,13 +1199,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, &base, &size, nomap ? " (nomap)" : ""); return -ENOSYS; } +#endif -void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) +static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) { - WARN_ON(1); - return NULL; + return memblock_virt_alloc(size, align); } -#endif bool __init early_init_dt_verify(void *params) { diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0f8052f1355c..7a9abaae874d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -5,6 +5,7 @@ #define pr_fmt(fmt) "### dt-test ### " fmt +#include #include #include #include @@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = { static struct device_node *overlay_base_root; +static void * __init dt_alloc_memory(u64 size, u64 align) +{ + return memblock_virt_alloc(size, align); +} + /* * Create base device tree for the overlay unittest. * @@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void) return; } - info->data = early_init_dt_alloc_memory_arch(size, - roundup_pow_of_two(FDT_V17_SIZE)); + info->data = dt_alloc_memory(size, roundup_pow_of_two(FDT_V17_SIZE)); if (!info->data) { pr_err("alloc for dtb 'overlay_base' failed"); return; @@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void) memcpy(info->data, info->dtb_begin, size); __unflatten_device_tree(info->data, NULL, &info->np_overlay, - early_init_dt_alloc_memory_arch, true); + dt_alloc_memory, true); overlay_base_root = info->np_overlay; } -- cgit v1.2.3 From bd6dc70b62bb99d257a3ef39840fd89bf98bc0dd Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 5 Jan 2018 20:55:30 +0900 Subject: of: unittest: refactor Makefile Some cleanups: - use obj-$(CONFIG_OF_OVERLAY) instead of ifdef ... endif - compute targets from obj-y Signed-off-by: Masahiro Yamada Signed-off-by: Rob Herring --- drivers/of/unittest-data/Makefile | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile index 32389acfa616..df697976740a 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -2,19 +2,12 @@ DTC_FLAGS_testcases := -Wno-interrupts_property obj-y += testcases.dtb.o -targets += testcases.dtb testcases.dtb.S +obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \ + overlay_bad_phandle.dtb.o \ + overlay_bad_symbol.dtb.o \ + overlay_base.dtb.o -ifdef CONFIG_OF_OVERLAY - -obj-y += overlay.dtb.o -obj-y += overlay_bad_phandle.dtb.o -obj-y += overlay_bad_symbol.dtb.o -obj-y += overlay_base.dtb.o - -targets += overlay.dtb overlay.dtb.S -targets += overlay_bad_phandle.dtb overlay_bad_phandle.dtb.S -targets += overlay_bad_symbol.dtb overlay_bad_symbol.dtb.S -targets += overlay_base.dtb overlay_base.dtb.S +targets += $(foreach suffix, dtb dtb.S, $(patsubst %.dtb.o,%.$(suffix),$(obj-y))) # enable creation of __symbols__ node DTC_FLAGS_overlay := -@ @@ -22,8 +15,6 @@ DTC_FLAGS_overlay_bad_phandle := -@ DTC_FLAGS_overlay_bad_symbol := -@ DTC_FLAGS_overlay_base := -@ -endif - .PRECIOUS: \ $(obj)/%.dtb.S \ $(obj)/%.dtb -- cgit v1.2.3