Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux

Pull devicetree changes from Grant Likely:
"Here are the devicetree changes queued up for v4.1. Nothing really
exciting here. Rob has another few commits for big-endian attached
UARTs, but those will be sent in a separate merge request since they
haven't been as thoroughly tested as this batch.

Here are the highlights:

- lots of unittest cleanup from Frank Rowand

- bugfixes and updates to the of_graph code

- tighten up of_get_mac_address() code

- documentation updates"

* tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux:
of/unittest: Fix of_platform_depopulate test case
of/unittest: early return from test skips tests
of/unittest: breadcrumbs to reduce pain of future maintainers
of/unittest: reduce checkpatch noise - line after declarations
of/unittest: typo in error string
of/unittest: add const where needed
of_net: factor out repetitive code from of_get_mac_address()
drivers/of: Add empty ranges quirk for PA-Semi
of: Allow selection of OF_DYNAMIC and OF_OVERLAY if OF_UNITTEST
of: Empty node & property flag accessors when !OF
of: Explicitly include linux/types.h in of_graph.h
dt-bindings: brcm: rationalize Broadcom documentation naming
of/unittest: replace 'selftest' with 'unittest'
Documentation: rename of_selftest.txt to of_unittest.txt
Documentation: update the of_selftest.txt
dt: OF_UNITTEST make dependency broken
MAINTAINERS: Pantelis Antoniou device tree overlay maintainer
of: Add of_graph_get_port_by_id function
of: Add for_each_endpoint_of_node helper macro
of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint

+611 -517
Documentation/devicetree/bindings/arm/bcm/bcm11351.txt Documentation/devicetree/bindings/arm/bcm/brcm,bcm11351.txt
Documentation/devicetree/bindings/arm/bcm/bcm21664.txt Documentation/devicetree/bindings/arm/bcm/brcm,bcm21664.txt
Documentation/devicetree/bindings/arm/bcm/bcm63138.txt Documentation/devicetree/bindings/arm/bcm/brcm,bcm63138.txt
Documentation/devicetree/bindings/arm/bcm/brcm,bcm11351-cpu-method Documentation/devicetree/bindings/arm/bcm/brcm,bcm11351-cpu-method.txt
Documentation/devicetree/bindings/arm/bcm/cygnus.txt Documentation/devicetree/bindings/arm/bcm/brcm,cygnus.txt
Documentation/devicetree/bindings/arm/bcm/kona-resetmgr.txt Documentation/devicetree/bindings/reset/brcm,bcm21664-resetmgr.txt
Documentation/devicetree/bindings/arm/bcm/kona-timer.txt Documentation/devicetree/bindings/timer/brcm,kona-timer.txt
Documentation/devicetree/bindings/arm/bcm/kona-wdt.txt Documentation/devicetree/bindings/watchdog/brcm,kona-wdt.txt
Documentation/devicetree/bindings/arm/bcm2835.txt Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
Documentation/devicetree/bindings/arm/bcm4708.txt Documentation/devicetree/bindings/arm/bcm/brcm,bcm4708.txt
Documentation/devicetree/bindings/arm/brcm-brcmstb.txt Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt
Documentation/devicetree/bindings/bus/bcma.txt Documentation/devicetree/bindings/bus/brcm,bus-axi.txt
Documentation/devicetree/bindings/clock/bcm-kona-clock.txt Documentation/devicetree/bindings/clock/brcm,kona-ccu.txt
Documentation/devicetree/bindings/dma/bcm2835-dma.txt Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.txt
Documentation/devicetree/bindings/gpio/gpio-bcm-kona.txt Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
Documentation/devicetree/bindings/i2c/i2c-bcm-kona.txt Documentation/devicetree/bindings/i2c/brcm,kona-i2c.txt
Documentation/devicetree/bindings/mfd/bcm590xx.txt Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt
Documentation/devicetree/bindings/mips/brcm/bmips.txt Documentation/devicetree/bindings/mips/brcm/brcm,bmips.txt
Documentation/devicetree/bindings/mips/brcm/usb.txt Documentation/devicetree/bindings/usb/brcm,bcm3384-usb.txt
Documentation/devicetree/bindings/misc/smc.txt Documentation/devicetree/bindings/misc/brcm,kona-smc.txt
Documentation/devicetree/bindings/mmc/kona-sdhci.txt Documentation/devicetree/bindings/mmc/brcm,kona-sdhci.txt
Documentation/devicetree/bindings/net/broadcom-bcmgenet.txt Documentation/devicetree/bindings/net/brcm,bcmgenet.txt
Documentation/devicetree/bindings/net/broadcom-mdio-unimac.txt Documentation/devicetree/bindings/net/brcm,unimac-mdio.txt
Documentation/devicetree/bindings/net/broadcom-sf2.txt Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt
Documentation/devicetree/bindings/net/broadcom-systemport.txt Documentation/devicetree/bindings/net/brcm,systemport.txt
Documentation/devicetree/bindings/phy/bcm-phy.txt Documentation/devicetree/bindings/phy/brcm,kona-usb2-phy.txt
Documentation/devicetree/bindings/pwm/bcm-kona-pwm.txt Documentation/devicetree/bindings/pwm/brcm,kona-pwm.txt
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt
Documentation/devicetree/bindings/sound/bcm2835-i2s.txt Documentation/devicetree/bindings/sound/brcm,bcm2835-i2s.txt
+22 -22
Documentation/devicetree/bindings/unittest.txt
··· 1 - 1) OF selftest platform device 1 + 1) OF unittest platform device 2 2 3 - ** selftest 3 + ** unittest 4 4 5 5 Required properties: 6 - - compatible: must be "selftest" 6 + - compatible: must be "unittest" 7 7 8 8 All other properties are optional. 9 9 10 10 Example: 11 - selftest { 12 - compatible = "selftest"; 11 + unittest { 12 + compatible = "unittest"; 13 13 status = "okay"; 14 14 }; 15 15 16 - 2) OF selftest i2c adapter platform device 16 + 2) OF unittest i2c adapter platform device 17 17 18 18 ** platform device unittest adapter 19 19 20 20 Required properties: 21 - - compatible: must be selftest-i2c-bus 21 + - compatible: must be unittest-i2c-bus 22 22 23 - Children nodes contain selftest i2c devices. 23 + Children nodes contain unittest i2c devices. 24 24 25 25 Example: 26 - selftest-i2c-bus { 27 - compatible = "selftest-i2c-bus"; 26 + unittest-i2c-bus { 27 + compatible = "unittest-i2c-bus"; 28 28 status = "okay"; 29 29 }; 30 30 31 - 3) OF selftest i2c device 31 + 3) OF unittest i2c device 32 32 33 - ** I2C selftest device 33 + ** I2C unittest device 34 34 35 35 Required properties: 36 - - compatible: must be selftest-i2c-dev 36 + - compatible: must be unittest-i2c-dev 37 37 38 38 All other properties are optional 39 39 40 40 Example: 41 - selftest-i2c-dev { 42 - compatible = "selftest-i2c-dev"; 41 + unittest-i2c-dev { 42 + compatible = "unittest-i2c-dev"; 43 43 status = "okay"; 44 44 }; 45 45 46 - 4) OF selftest i2c mux device 46 + 4) OF unittest i2c mux device 47 47 48 - ** I2C selftest mux 48 + ** I2C unittest mux 49 49 50 50 Required properties: 51 - - compatible: must be selftest-i2c-mux 51 + - compatible: must be unittest-i2c-mux 52 52 53 - Children nodes contain selftest i2c bus nodes per channel. 53 + Children nodes contain unittest i2c bus nodes per channel. 54 54 55 55 Example: 56 - selftest-i2c-mux { 57 - compatible = "selftest-i2c-mux"; 56 + unittest-i2c-mux { 57 + compatible = "unittest-i2c-mux"; 58 58 status = "okay"; 59 59 #address-cells = <1>; 60 60 #size-cells = <0>; ··· 64 64 #size-cells = <0>; 65 65 i2c-dev { 66 66 reg = <8>; 67 - compatible = "selftest-i2c-dev"; 67 + compatible = "unittest-i2c-dev"; 68 68 status = "okay"; 69 69 }; 70 70 };
+14 -14
Documentation/devicetree/of_selftest.txt Documentation/devicetree/of_unittest.txt
··· 1 - Open Firmware Device Tree Selftest 1 + Open Firmware Device Tree Unittest 2 2 ---------------------------------- 3 3 4 4 Author: Gaurav Minocha <gaurav.minocha.os@gmail.com> 5 5 6 6 1. Introduction 7 7 8 - This document explains how the test data required for executing OF selftest 8 + This document explains how the test data required for executing OF unittest 9 9 is attached to the live tree dynamically, independent of the machine's 10 10 architecture. 11 11 ··· 22 22 23 23 2. Test-data 24 24 25 - The Device Tree Source file (drivers/of/testcase-data/testcases.dts) contains 25 + The Device Tree Source file (drivers/of/unittest-data/testcases.dts) contains 26 26 the test data required for executing the unit tests automated in 27 - drivers/of/selftests.c. Currently, following Device Tree Source Include files 28 - (.dtsi) are included in testcase.dts: 27 + drivers/of/unittest.c. Currently, following Device Tree Source Include files 28 + (.dtsi) are included in testcases.dts: 29 29 30 - drivers/of/testcase-data/tests-interrupts.dtsi 31 - drivers/of/testcase-data/tests-platform.dtsi 32 - drivers/of/testcase-data/tests-phandle.dtsi 33 - drivers/of/testcase-data/tests-match.dtsi 30 + drivers/of/unittest-data/tests-interrupts.dtsi 31 + drivers/of/unittest-data/tests-platform.dtsi 32 + drivers/of/unittest-data/tests-phandle.dtsi 33 + drivers/of/unittest-data/tests-match.dtsi 34 34 35 35 When the kernel is build with OF_SELFTEST enabled, then the following make rule 36 36 37 37 $(obj)/%.dtb: $(src)/%.dts FORCE 38 38 $(call if_changed_dep, dtc) 39 39 40 - is used to compile the DT source file (testcase.dts) into a binary blob 41 - (testcase.dtb), also referred as flattened DT. 40 + is used to compile the DT source file (testcases.dts) into a binary blob 41 + (testcases.dtb), also referred as flattened DT. 42 42 43 43 After that, using the following rule the binary blob above is wrapped as an 44 - assembly file (testcase.dtb.S). 44 + assembly file (testcases.dtb.S). 45 45 46 46 $(obj)/%.dtb.S: $(obj)/%.dtb 47 47 $(call cmd, dt_S_dtb) 48 48 49 - The assembly file is compiled into an object file (testcase.dtb.o), and is 49 + The assembly file is compiled into an object file (testcases.dtb.o), and is 50 50 linked into the kernel image. 51 51 52 52 ··· 98 98 Figure 1: Generic structure of un-flattened device tree 99 99 100 100 101 - Before executing OF selftest, it is required to attach the test data to 101 + Before executing OF unittest, it is required to attach the test data to 102 102 machine's device tree (if present). So, when selftest_data_add() is called, 103 103 at first it reads the flattened device tree data linked into the kernel image 104 104 via the following kernel symbols:
+9
MAINTAINERS
··· 7243 7243 F: arch/*/boot/dts/ 7244 7244 F: include/dt-bindings/ 7245 7245 7246 + OPEN FIRMWARE AND DEVICE TREE OVERLAYS 7247 + M: Pantelis Antoniou <pantelis.antoniou@konsulko.com> 7248 + L: devicetree@vger.kernel.org 7249 + S: Maintained 7250 + F: Documentation/devicetree/dynamic-resolution-notes.txt 7251 + F: Documentation/devicetree/overlay-notes.txt 7252 + F: drivers/of/overlay.c 7253 + F: drivers/of/resolver.c 7254 + 7246 7255 OPENRISC ARCHITECTURE 7247 7256 M: Jonas Bonn <jonas@southpole.se> 7248 7257 W: http://openrisc.net
+2 -11
drivers/coresight/of_coresight.c
··· 52 52 endpoint, of_dev_node_match); 53 53 } 54 54 55 - static struct device_node *of_get_coresight_endpoint( 56 - const struct device_node *parent, struct device_node *prev) 57 - { 58 - struct device_node *node = of_graph_get_next_endpoint(parent, prev); 59 - 60 - of_node_put(prev); 61 - return node; 62 - } 63 - 64 55 static void of_coresight_get_ports(struct device_node *node, 65 56 int *nr_inport, int *nr_outport) 66 57 { ··· 59 68 int in = 0, out = 0; 60 69 61 70 do { 62 - ep = of_get_coresight_endpoint(node, ep); 71 + ep = of_graph_get_next_endpoint(node, ep); 63 72 if (!ep) 64 73 break; 65 74 ··· 131 140 /* Iterate through each port to discover topology */ 132 141 do { 133 142 /* Get a handle on a port */ 134 - ep = of_get_coresight_endpoint(node, ep); 143 + ep = of_graph_get_next_endpoint(node, ep); 135 144 if (!ep) 136 145 break; 137 146
+1 -10
drivers/gpu/drm/imx/imx-drm-core.c
··· 431 431 } 432 432 EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of); 433 433 434 - static struct device_node *imx_drm_of_get_next_endpoint( 435 - const struct device_node *parent, struct device_node *prev) 436 - { 437 - struct device_node *node = of_graph_get_next_endpoint(parent, prev); 438 - 439 - of_node_put(prev); 440 - return node; 441 - } 442 - 443 434 /* 444 435 * @node: device tree node containing encoder input ports 445 436 * @encoder: drm_encoder ··· 448 457 return -EINVAL; 449 458 450 459 do { 451 - ep = imx_drm_of_get_next_endpoint(node, ep); 460 + ep = of_graph_get_next_endpoint(node, ep); 452 461 if (!ep) 453 462 break; 454 463
+4 -11
drivers/gpu/drm/rcar-du/rcar_du_kms.c
··· 206 206 enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE; 207 207 struct device_node *connector = NULL; 208 208 struct device_node *encoder = NULL; 209 - struct device_node *prev = NULL; 209 + struct device_node *ep_node = NULL; 210 210 struct device_node *entity_ep_node; 211 211 struct device_node *entity; 212 212 int ret; ··· 225 225 entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0); 226 226 227 227 while (1) { 228 - struct device_node *ep_node; 229 - 230 - ep_node = of_graph_get_next_endpoint(entity, prev); 231 - of_node_put(prev); 232 - prev = ep_node; 228 + ep_node = of_graph_get_next_endpoint(entity, ep_node); 233 229 234 230 if (!ep_node) 235 231 break; ··· 296 300 static int rcar_du_encoders_init(struct rcar_du_device *rcdu) 297 301 { 298 302 struct device_node *np = rcdu->dev->of_node; 299 - struct device_node *prev = NULL; 303 + struct device_node *ep_node = NULL; 300 304 unsigned int num_encoders = 0; 301 305 302 306 /* ··· 304 308 * pipeline. 305 309 */ 306 310 while (1) { 307 - struct device_node *ep_node; 308 311 enum rcar_du_output output; 309 312 struct of_endpoint ep; 310 313 unsigned int i; 311 314 int ret; 312 315 313 - ep_node = of_graph_get_next_endpoint(np, prev); 314 - of_node_put(prev); 315 - prev = ep_node; 316 + ep_node = of_graph_get_next_endpoint(np, ep_node); 316 317 317 318 if (ep_node == NULL) 318 319 break;
-1
drivers/media/platform/am437x/am437x-vpfe.c
··· 2504 2504 GFP_KERNEL); 2505 2505 pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_OF; 2506 2506 pdata->asd[i]->match.of.node = rem; 2507 - of_node_put(endpoint); 2508 2507 of_node_put(rem); 2509 2508 } 2510 2509
+2 -1
drivers/media/platform/soc_camera/soc_camera.c
··· 1694 1694 if (!i) 1695 1695 soc_of_bind(ici, epn, ren->parent); 1696 1696 1697 - of_node_put(epn); 1698 1697 of_node_put(ren); 1699 1698 1700 1699 if (i) { ··· 1701 1702 break; 1702 1703 } 1703 1704 } 1705 + 1706 + of_node_put(epn); 1704 1707 } 1705 1708 1706 1709 #else
+10 -1
drivers/of/Kconfig
··· 34 34 # Hardly any platforms need this. It is safe to select, but only do so if you 35 35 # need it. 36 36 config OF_DYNAMIC 37 - bool 37 + bool "Support for dynamic device trees" if OF_UNITTEST 38 + help 39 + On some platforms, the device tree can be manipulated at runtime. 40 + While this option is selected automatically on such platforms, you 41 + can enable it manually to improve device tree unit test coverage. 38 42 39 43 config OF_ADDRESS 40 44 def_bool y ··· 91 87 bool "Device Tree overlays" 92 88 select OF_DYNAMIC 93 89 select OF_RESOLVE 90 + help 91 + Overlays are a method to dynamically modify part of the kernel's 92 + device tree with dynamically loaded data. 93 + While this option is selected automatically when needed, you can 94 + enable it manually to improve device tree unit test coverage. 94 95 95 96 endmenu # OF
+3 -2
drivers/of/Makefile
··· 6 6 obj-$(CONFIG_OF_ADDRESS) += address.o 7 7 obj-$(CONFIG_OF_IRQ) += irq.o 8 8 obj-$(CONFIG_OF_NET) += of_net.o 9 - obj-$(CONFIG_OF_UNITTEST) += of_unittest.o 10 - of_unittest-objs := unittest.o unittest-data/testcases.dtb.o 9 + obj-$(CONFIG_OF_UNITTEST) += unittest.o 11 10 obj-$(CONFIG_OF_MDIO) += of_mdio.o 12 11 obj-$(CONFIG_OF_PCI) += of_pci.o 13 12 obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o ··· 14 15 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o 15 16 obj-$(CONFIG_OF_RESOLVE) += resolver.o 16 17 obj-$(CONFIG_OF_OVERLAY) += overlay.o 18 + 19 + obj-$(CONFIG_OF_UNITTEST) += unittest-data/ 17 20 18 21 CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt 19 22 CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
+33 -8
drivers/of/base.c
··· 2109 2109 EXPORT_SYMBOL(of_graph_parse_endpoint); 2110 2110 2111 2111 /** 2112 + * of_graph_get_port_by_id() - get the port matching a given id 2113 + * @parent: pointer to the parent device node 2114 + * @id: id of the port 2115 + * 2116 + * Return: A 'port' node pointer with refcount incremented. The caller 2117 + * has to use of_node_put() on it when done. 2118 + */ 2119 + struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) 2120 + { 2121 + struct device_node *node, *port; 2122 + 2123 + node = of_get_child_by_name(parent, "ports"); 2124 + if (node) 2125 + parent = node; 2126 + 2127 + for_each_child_of_node(parent, port) { 2128 + u32 port_id = 0; 2129 + 2130 + if (of_node_cmp(port->name, "port") != 0) 2131 + continue; 2132 + of_property_read_u32(port, "reg", &port_id); 2133 + if (id == port_id) 2134 + break; 2135 + } 2136 + 2137 + of_node_put(node); 2138 + 2139 + return port; 2140 + } 2141 + EXPORT_SYMBOL(of_graph_get_port_by_id); 2142 + 2143 + /** 2112 2144 * of_graph_get_next_endpoint() - get next endpoint node 2113 2145 * @parent: pointer to the parent device node 2114 2146 * @prev: previous endpoint node, or NULL to get first 2115 2147 * 2116 2148 * Return: An 'endpoint' node pointer with refcount incremented. Refcount 2117 - * of the passed @prev node is not decremented, the caller have to use 2118 - * of_node_put() on it when done. 2149 + * of the passed @prev node is decremented. 2119 2150 */ 2120 2151 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, 2121 2152 struct device_node *prev) ··· 2182 2151 if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", 2183 2152 __func__, prev->full_name)) 2184 2153 return NULL; 2185 - 2186 - /* 2187 - * Avoid dropping prev node refcount to 0 when getting the next 2188 - * child below. 2189 - */ 2190 - of_node_get(prev); 2191 2154 } 2192 2155 2193 2156 while (1) {
+17 -12
drivers/of/of_net.c
··· 38 38 } 39 39 EXPORT_SYMBOL_GPL(of_get_phy_mode); 40 40 41 + static const void *of_get_mac_addr(struct device_node *np, const char *name) 42 + { 43 + struct property *pp = of_find_property(np, name, NULL); 44 + 45 + if (pp && pp->length == ETH_ALEN && is_valid_ether_addr(pp->value)) 46 + return pp->value; 47 + return NULL; 48 + } 49 + 41 50 /** 42 51 * Search the device tree for the best MAC address to use. 'mac-address' is 43 52 * checked first, because that is supposed to contain to "most recent" MAC ··· 67 58 */ 68 59 const void *of_get_mac_address(struct device_node *np) 69 60 { 70 - struct property *pp; 61 + const void *addr; 71 62 72 - pp = of_find_property(np, "mac-address", NULL); 73 - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) 74 - return pp->value; 63 + addr = of_get_mac_addr(np, "mac-address"); 64 + if (addr) 65 + return addr; 75 66 76 - pp = of_find_property(np, "local-mac-address", NULL); 77 - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) 78 - return pp->value; 67 + addr = of_get_mac_addr(np, "local-mac-address"); 68 + if (addr) 69 + return addr; 79 70 80 - pp = of_find_property(np, "address", NULL); 81 - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) 82 - return pp->value; 83 - 84 - return NULL; 71 + return of_get_mac_addr(np, "address"); 85 72 } 86 73 EXPORT_SYMBOL(of_get_mac_address);
+2
drivers/of/unittest-data/.gitignore
··· 1 + testcases.dtb 2 + testcases.dtb.S
+7
drivers/of/unittest-data/Makefile
··· 1 + obj-y += testcases.dtb.o 2 + 3 + targets += testcases.dtb testcases.dtb.S 4 + 5 + .SECONDARY: \ 6 + $(obj)/testcases.dtb.S \ 7 + $(obj)/testcases.dtb
+54 -54
drivers/of/unittest-data/tests-overlay.dtsi
··· 4 4 overlay-node { 5 5 6 6 /* test bus */ 7 - selftestbus: test-bus { 7 + unittestbus: test-bus { 8 8 compatible = "simple-bus"; 9 9 #address-cells = <1>; 10 10 #size-cells = <0>; 11 11 12 - selftest100: test-selftest100 { 13 - compatible = "selftest"; 12 + unittest100: test-unittest100 { 13 + compatible = "unittest"; 14 14 status = "okay"; 15 15 reg = <100>; 16 16 }; 17 17 18 - selftest101: test-selftest101 { 19 - compatible = "selftest"; 18 + unittest101: test-unittest101 { 19 + compatible = "unittest"; 20 20 status = "disabled"; 21 21 reg = <101>; 22 22 }; 23 23 24 - selftest0: test-selftest0 { 25 - compatible = "selftest"; 24 + unittest0: test-unittest0 { 25 + compatible = "unittest"; 26 26 status = "disabled"; 27 27 reg = <0>; 28 28 }; 29 29 30 - selftest1: test-selftest1 { 31 - compatible = "selftest"; 30 + unittest1: test-unittest1 { 31 + compatible = "unittest"; 32 32 status = "okay"; 33 33 reg = <1>; 34 34 }; 35 35 36 - selftest2: test-selftest2 { 37 - compatible = "selftest"; 36 + unittest2: test-unittest2 { 37 + compatible = "unittest"; 38 38 status = "disabled"; 39 39 reg = <2>; 40 40 }; 41 41 42 - selftest3: test-selftest3 { 43 - compatible = "selftest"; 42 + unittest3: test-unittest3 { 43 + compatible = "unittest"; 44 44 status = "okay"; 45 45 reg = <3>; 46 46 }; 47 47 48 - selftest5: test-selftest5 { 49 - compatible = "selftest"; 48 + unittest5: test-unittest5 { 49 + compatible = "unittest"; 50 50 status = "disabled"; 51 51 reg = <5>; 52 52 }; 53 53 54 - selftest6: test-selftest6 { 55 - compatible = "selftest"; 54 + unittest6: test-unittest6 { 55 + compatible = "unittest"; 56 56 status = "disabled"; 57 57 reg = <6>; 58 58 }; 59 59 60 - selftest7: test-selftest7 { 61 - compatible = "selftest"; 60 + unittest7: test-unittest7 { 61 + compatible = "unittest"; 62 62 status = "disabled"; 63 63 reg = <7>; 64 64 }; 65 65 66 - selftest8: test-selftest8 { 67 - compatible = "selftest"; 66 + unittest8: test-unittest8 { 67 + compatible = "unittest"; 68 68 status = "disabled"; 69 69 reg = <8>; 70 70 }; 71 71 72 72 i2c-test-bus { 73 - compatible = "selftest-i2c-bus"; 73 + compatible = "unittest-i2c-bus"; 74 74 status = "okay"; 75 75 reg = <50>; 76 76 77 77 #address-cells = <1>; 78 78 #size-cells = <0>; 79 79 80 - test-selftest12 { 80 + test-unittest12 { 81 81 reg = <8>; 82 - compatible = "selftest-i2c-dev"; 82 + compatible = "unittest-i2c-dev"; 83 83 status = "disabled"; 84 84 }; 85 85 86 - test-selftest13 { 86 + test-unittest13 { 87 87 reg = <9>; 88 - compatible = "selftest-i2c-dev"; 88 + compatible = "unittest-i2c-dev"; 89 89 status = "okay"; 90 90 }; 91 91 92 - test-selftest14 { 92 + test-unittest14 { 93 93 reg = <10>; 94 - compatible = "selftest-i2c-mux"; 94 + compatible = "unittest-i2c-mux"; 95 95 status = "okay"; 96 96 97 97 #address-cells = <1>; ··· 104 104 105 105 test-mux-dev { 106 106 reg = <32>; 107 - compatible = "selftest-i2c-dev"; 107 + compatible = "unittest-i2c-dev"; 108 108 status = "okay"; 109 109 }; 110 110 }; ··· 116 116 /* test enable using absolute target path */ 117 117 overlay0 { 118 118 fragment@0 { 119 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest0"; 119 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest0"; 120 120 __overlay__ { 121 121 status = "okay"; 122 122 }; ··· 126 126 /* test disable using absolute target path */ 127 127 overlay1 { 128 128 fragment@0 { 129 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest1"; 129 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest1"; 130 130 __overlay__ { 131 131 status = "disabled"; 132 132 }; ··· 136 136 /* test enable using label */ 137 137 overlay2 { 138 138 fragment@0 { 139 - target = <&selftest2>; 139 + target = <&unittest2>; 140 140 __overlay__ { 141 141 status = "okay"; 142 142 }; ··· 146 146 /* test disable using label */ 147 147 overlay3 { 148 148 fragment@0 { 149 - target = <&selftest3>; 149 + target = <&unittest3>; 150 150 __overlay__ { 151 151 status = "disabled"; 152 152 }; ··· 156 156 /* test insertion of a full node */ 157 157 overlay4 { 158 158 fragment@0 { 159 - target = <&selftestbus>; 159 + target = <&unittestbus>; 160 160 __overlay__ { 161 161 162 162 /* suppress DTC warning */ 163 163 #address-cells = <1>; 164 164 #size-cells = <0>; 165 165 166 - test-selftest4 { 167 - compatible = "selftest"; 166 + test-unittest4 { 167 + compatible = "unittest"; 168 168 status = "okay"; 169 169 reg = <4>; 170 170 }; ··· 175 175 /* test overlay apply revert */ 176 176 overlay5 { 177 177 fragment@0 { 178 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest5"; 178 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest5"; 179 179 __overlay__ { 180 180 status = "okay"; 181 181 }; ··· 185 185 /* test overlays application and removal in sequence */ 186 186 overlay6 { 187 187 fragment@0 { 188 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest6"; 188 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest6"; 189 189 __overlay__ { 190 190 status = "okay"; 191 191 }; ··· 193 193 }; 194 194 overlay7 { 195 195 fragment@0 { 196 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest7"; 196 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest7"; 197 197 __overlay__ { 198 198 status = "okay"; 199 199 }; ··· 203 203 /* test overlays application and removal in bad sequence */ 204 204 overlay8 { 205 205 fragment@0 { 206 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest8"; 206 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; 207 207 __overlay__ { 208 208 status = "okay"; 209 209 }; ··· 211 211 }; 212 212 overlay9 { 213 213 fragment@0 { 214 - target-path = "/testcase-data/overlay-node/test-bus/test-selftest8"; 214 + target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; 215 215 __overlay__ { 216 216 property-foo = "bar"; 217 217 }; ··· 227 227 #address-cells = <1>; 228 228 #size-cells = <0>; 229 229 230 - test-selftest10 { 231 - compatible = "selftest"; 230 + test-unittest10 { 231 + compatible = "unittest"; 232 232 status = "okay"; 233 233 reg = <10>; 234 234 235 235 #address-cells = <1>; 236 236 #size-cells = <0>; 237 237 238 - test-selftest101 { 239 - compatible = "selftest"; 238 + test-unittest101 { 239 + compatible = "unittest"; 240 240 status = "okay"; 241 241 reg = <1>; 242 242 }; ··· 255 255 #address-cells = <1>; 256 256 #size-cells = <0>; 257 257 258 - test-selftest11 { 259 - compatible = "selftest"; 258 + test-unittest11 { 259 + compatible = "unittest"; 260 260 status = "okay"; 261 261 reg = <11>; 262 262 263 263 #address-cells = <1>; 264 264 #size-cells = <0>; 265 265 266 - test-selftest111 { 267 - compatible = "selftest"; 266 + test-unittest111 { 267 + compatible = "unittest"; 268 268 status = "okay"; 269 269 reg = <1>; 270 270 }; ··· 277 277 /* test enable using absolute target path (i2c) */ 278 278 overlay12 { 279 279 fragment@0 { 280 - target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest12"; 280 + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12"; 281 281 __overlay__ { 282 282 status = "okay"; 283 283 }; ··· 287 287 /* test disable using absolute target path (i2c) */ 288 288 overlay13 { 289 289 fragment@0 { 290 - target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest13"; 290 + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13"; 291 291 __overlay__ { 292 292 status = "disabled"; 293 293 }; ··· 301 301 __overlay__ { 302 302 #address-cells = <1>; 303 303 #size-cells = <0>; 304 - test-selftest15 { 304 + test-unittest15 { 305 305 reg = <11>; 306 - compatible = "selftest-i2c-mux"; 306 + compatible = "unittest-i2c-mux"; 307 307 status = "okay"; 308 308 309 309 #address-cells = <1>; ··· 316 316 317 317 test-mux-dev { 318 318 reg = <32>; 319 - compatible = "selftest-i2c-dev"; 319 + compatible = "unittest-i2c-dev"; 320 320 status = "okay"; 321 321 }; 322 322 };
+378 -364
drivers/of/unittest.c
··· 25 25 26 26 #include "of_private.h" 27 27 28 - static struct selftest_results { 28 + static struct unittest_results { 29 29 int passed; 30 30 int failed; 31 - } selftest_results; 31 + } unittest_results; 32 32 33 - #define selftest(result, fmt, ...) ({ \ 33 + #define unittest(result, fmt, ...) ({ \ 34 34 bool failed = !(result); \ 35 35 if (failed) { \ 36 - selftest_results.failed++; \ 36 + unittest_results.failed++; \ 37 37 pr_err("FAIL %s():%i " fmt, __func__, __LINE__, ##__VA_ARGS__); \ 38 38 } else { \ 39 - selftest_results.passed++; \ 39 + unittest_results.passed++; \ 40 40 pr_debug("pass %s():%i\n", __func__, __LINE__); \ 41 41 } \ 42 42 failed; \ 43 43 }) 44 44 45 - static void __init of_selftest_find_node_by_name(void) 45 + static void __init of_unittest_find_node_by_name(void) 46 46 { 47 47 struct device_node *np; 48 48 const char *options; 49 49 50 50 np = of_find_node_by_path("/testcase-data"); 51 - selftest(np && !strcmp("/testcase-data", np->full_name), 51 + unittest(np && !strcmp("/testcase-data", np->full_name), 52 52 "find /testcase-data failed\n"); 53 53 of_node_put(np); 54 54 55 55 /* Test if trailing '/' works */ 56 56 np = of_find_node_by_path("/testcase-data/"); 57 - selftest(!np, "trailing '/' on /testcase-data/ should fail\n"); 57 + unittest(!np, "trailing '/' on /testcase-data/ should fail\n"); 58 58 59 59 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); 60 - selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 60 + unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 61 61 "find /testcase-data/phandle-tests/consumer-a failed\n"); 62 62 of_node_put(np); 63 63 64 64 np = of_find_node_by_path("testcase-alias"); 65 - selftest(np && !strcmp("/testcase-data", np->full_name), 65 + unittest(np && !strcmp("/testcase-data", np->full_name), 66 66 "find testcase-alias failed\n"); 67 67 of_node_put(np); 68 68 69 69 /* Test if trailing '/' works on aliases */ 70 70 np = of_find_node_by_path("testcase-alias/"); 71 - selftest(!np, "trailing '/' on testcase-alias/ should fail\n"); 71 + unittest(!np, "trailing '/' on testcase-alias/ should fail\n"); 72 72 73 73 np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); 74 - selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 74 + unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 75 75 "find testcase-alias/phandle-tests/consumer-a failed\n"); 76 76 of_node_put(np); 77 77 78 78 np = of_find_node_by_path("/testcase-data/missing-path"); 79 - selftest(!np, "non-existent path returned node %s\n", np->full_name); 79 + unittest(!np, "non-existent path returned node %s\n", np->full_name); 80 80 of_node_put(np); 81 81 82 82 np = of_find_node_by_path("missing-alias"); 83 - selftest(!np, "non-existent alias returned node %s\n", np->full_name); 83 + unittest(!np, "non-existent alias returned node %s\n", np->full_name); 84 84 of_node_put(np); 85 85 86 86 np = of_find_node_by_path("testcase-alias/missing-path"); 87 - selftest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); 87 + unittest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); 88 88 of_node_put(np); 89 89 90 90 np = of_find_node_opts_by_path("/testcase-data:testoption", &options); 91 - selftest(np && !strcmp("testoption", options), 91 + unittest(np && !strcmp("testoption", options), 92 92 "option path test failed\n"); 93 93 of_node_put(np); 94 94 95 95 np = of_find_node_opts_by_path("/testcase-data:test/option", &options); 96 - selftest(np && !strcmp("test/option", options), 96 + unittest(np && !strcmp("test/option", options), 97 97 "option path test, subcase #1 failed\n"); 98 98 of_node_put(np); 99 99 100 100 np = of_find_node_opts_by_path("/testcase-data/testcase-device1:test/option", &options); 101 - selftest(np && !strcmp("test/option", options), 101 + unittest(np && !strcmp("test/option", options), 102 102 "option path test, subcase #2 failed\n"); 103 103 of_node_put(np); 104 104 105 105 np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); 106 - selftest(np, "NULL option path test failed\n"); 106 + unittest(np, "NULL option path test failed\n"); 107 107 of_node_put(np); 108 108 109 109 np = of_find_node_opts_by_path("testcase-alias:testaliasoption", 110 110 &options); 111 - selftest(np && !strcmp("testaliasoption", options), 111 + unittest(np && !strcmp("testaliasoption", options), 112 112 "option alias path test failed\n"); 113 113 of_node_put(np); 114 114 115 115 np = of_find_node_opts_by_path("testcase-alias:test/alias/option", 116 116 &options); 117 - selftest(np && !strcmp("test/alias/option", options), 117 + unittest(np && !strcmp("test/alias/option", options), 118 118 "option alias path test, subcase #1 failed\n"); 119 119 of_node_put(np); 120 120 121 121 np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL); 122 - selftest(np, "NULL option alias path test failed\n"); 122 + unittest(np, "NULL option alias path test failed\n"); 123 123 of_node_put(np); 124 124 125 125 options = "testoption"; 126 126 np = of_find_node_opts_by_path("testcase-alias", &options); 127 - selftest(np && !options, "option clearing test failed\n"); 127 + unittest(np && !options, "option clearing test failed\n"); 128 128 of_node_put(np); 129 129 130 130 options = "testoption"; 131 131 np = of_find_node_opts_by_path("/", &options); 132 - selftest(np && !options, "option clearing root node test failed\n"); 132 + unittest(np && !options, "option clearing root node test failed\n"); 133 133 of_node_put(np); 134 134 } 135 135 136 - static void __init of_selftest_dynamic(void) 136 + static void __init of_unittest_dynamic(void) 137 137 { 138 138 struct device_node *np; 139 139 struct property *prop; ··· 147 147 /* Array of 4 properties for the purpose of testing */ 148 148 prop = kzalloc(sizeof(*prop) * 4, GFP_KERNEL); 149 149 if (!prop) { 150 - selftest(0, "kzalloc() failed\n"); 150 + unittest(0, "kzalloc() failed\n"); 151 151 return; 152 152 } 153 153 ··· 155 155 prop->name = "new-property"; 156 156 prop->value = "new-property-data"; 157 157 prop->length = strlen(prop->value); 158 - selftest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); 158 + unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); 159 159 160 160 /* Try to add an existing property - should fail */ 161 161 prop++; 162 162 prop->name = "new-property"; 163 163 prop->value = "new-property-data-should-fail"; 164 164 prop->length = strlen(prop->value); 165 - selftest(of_add_property(np, prop) != 0, 165 + unittest(of_add_property(np, prop) != 0, 166 166 "Adding an existing property should have failed\n"); 167 167 168 168 /* Try to modify an existing property - should pass */ 169 169 prop->value = "modify-property-data-should-pass"; 170 170 prop->length = strlen(prop->value); 171 - selftest(of_update_property(np, prop) == 0, 171 + unittest(of_update_property(np, prop) == 0, 172 172 "Updating an existing property should have passed\n"); 173 173 174 174 /* Try to modify non-existent property - should pass*/ ··· 176 176 prop->name = "modify-property"; 177 177 prop->value = "modify-missing-property-data-should-pass"; 178 178 prop->length = strlen(prop->value); 179 - selftest(of_update_property(np, prop) == 0, 179 + unittest(of_update_property(np, prop) == 0, 180 180 "Updating a missing property should have passed\n"); 181 181 182 182 /* Remove property - should pass */ 183 - selftest(of_remove_property(np, prop) == 0, 183 + unittest(of_remove_property(np, prop) == 0, 184 184 "Removing a property should have passed\n"); 185 185 186 186 /* Adding very large property - should pass */ ··· 188 188 prop->name = "large-property-PAGE_SIZEx8"; 189 189 prop->length = PAGE_SIZE * 8; 190 190 prop->value = kzalloc(prop->length, GFP_KERNEL); 191 - selftest(prop->value != NULL, "Unable to allocate large buffer\n"); 191 + unittest(prop->value != NULL, "Unable to allocate large buffer\n"); 192 192 if (prop->value) 193 - selftest(of_add_property(np, prop) == 0, 193 + unittest(of_add_property(np, prop) == 0, 194 194 "Adding a large property should have passed\n"); 195 195 } 196 196 197 - static int __init of_selftest_check_node_linkage(struct device_node *np) 197 + static int __init of_unittest_check_node_linkage(struct device_node *np) 198 198 { 199 199 struct device_node *child; 200 200 int count = 0, rc; ··· 206 206 return -EINVAL; 207 207 } 208 208 209 - rc = of_selftest_check_node_linkage(child); 209 + rc = of_unittest_check_node_linkage(child); 210 210 if (rc < 0) 211 211 return rc; 212 212 count += rc; ··· 215 215 return count + 1; 216 216 } 217 217 218 - static void __init of_selftest_check_tree_linkage(void) 218 + static void __init of_unittest_check_tree_linkage(void) 219 219 { 220 220 struct device_node *np; 221 221 int allnode_count = 0, child_count; ··· 225 225 226 226 for_each_of_allnodes(np) 227 227 allnode_count++; 228 - child_count = of_selftest_check_node_linkage(of_root); 228 + child_count = of_unittest_check_node_linkage(of_root); 229 229 230 - selftest(child_count > 0, "Device node data structure is corrupted\n"); 231 - selftest(child_count == allnode_count, "allnodes list size (%i) doesn't match" 232 - "sibling lists size (%i)\n", allnode_count, child_count); 230 + unittest(child_count > 0, "Device node data structure is corrupted\n"); 231 + unittest(child_count == allnode_count, 232 + "allnodes list size (%i) doesn't match sibling lists size (%i)\n", 233 + allnode_count, child_count); 233 234 pr_debug("allnodes list size (%i); sibling lists size (%i)\n", allnode_count, child_count); 234 235 } 235 236 ··· 240 239 }; 241 240 242 241 static DEFINE_HASHTABLE(phandle_ht, 8); 243 - static void __init of_selftest_check_phandles(void) 242 + static void __init of_unittest_check_phandles(void) 244 243 { 245 244 struct device_node *np; 246 245 struct node_hash *nh; ··· 268 267 hash_add(phandle_ht, &nh->node, np->phandle); 269 268 phandle_count++; 270 269 } 271 - selftest(dup_count == 0, "Found %i duplicates in %i phandles\n", 270 + unittest(dup_count == 0, "Found %i duplicates in %i phandles\n", 272 271 dup_count, phandle_count); 273 272 274 273 /* Clean up */ ··· 278 277 } 279 278 } 280 279 281 - static void __init of_selftest_parse_phandle_with_args(void) 280 + static void __init of_unittest_parse_phandle_with_args(void) 282 281 { 283 282 struct device_node *np; 284 283 struct of_phandle_args args; ··· 291 290 } 292 291 293 292 rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); 294 - selftest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); 293 + unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); 295 294 296 295 for (i = 0; i < 8; i++) { 297 296 bool passed = true; 297 + 298 298 rc = of_parse_phandle_with_args(np, "phandle-list", 299 299 "#phandle-cells", i, &args); 300 300 ··· 344 342 passed = false; 345 343 } 346 344 347 - selftest(passed, "index %i - data error on node %s rc=%i\n", 345 + unittest(passed, "index %i - data error on node %s rc=%i\n", 348 346 i, args.np->full_name, rc); 349 347 } 350 348 351 349 /* Check for missing list property */ 352 350 rc = of_parse_phandle_with_args(np, "phandle-list-missing", 353 351 "#phandle-cells", 0, &args); 354 - selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); 352 + unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); 355 353 rc = of_count_phandle_with_args(np, "phandle-list-missing", 356 354 "#phandle-cells"); 357 - selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); 355 + unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); 358 356 359 357 /* Check for missing cells property */ 360 358 rc = of_parse_phandle_with_args(np, "phandle-list", 361 359 "#phandle-cells-missing", 0, &args); 362 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 360 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 363 361 rc = of_count_phandle_with_args(np, "phandle-list", 364 362 "#phandle-cells-missing"); 365 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 363 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 366 364 367 365 /* Check for bad phandle in list */ 368 366 rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", 369 367 "#phandle-cells", 0, &args); 370 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 368 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 371 369 rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle", 372 370 "#phandle-cells"); 373 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 371 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 374 372 375 373 /* Check for incorrectly formed argument list */ 376 374 rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", 377 375 "#phandle-cells", 1, &args); 378 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 376 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 379 377 rc = of_count_phandle_with_args(np, "phandle-list-bad-args", 380 378 "#phandle-cells"); 381 - selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 379 + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 382 380 } 383 381 384 - static void __init of_selftest_property_string(void) 382 + static void __init of_unittest_property_string(void) 385 383 { 386 384 const char *strings[4]; 387 385 struct device_node *np; ··· 394 392 } 395 393 396 394 rc = of_property_match_string(np, "phandle-list-names", "first"); 397 - selftest(rc == 0, "first expected:0 got:%i\n", rc); 395 + unittest(rc == 0, "first expected:0 got:%i\n", rc); 398 396 rc = of_property_match_string(np, "phandle-list-names", "second"); 399 - selftest(rc == 1, "second expected:1 got:%i\n", rc); 397 + unittest(rc == 1, "second expected:1 got:%i\n", rc); 400 398 rc = of_property_match_string(np, "phandle-list-names", "third"); 401 - selftest(rc == 2, "third expected:2 got:%i\n", rc); 399 + unittest(rc == 2, "third expected:2 got:%i\n", rc); 402 400 rc = of_property_match_string(np, "phandle-list-names", "fourth"); 403 - selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); 401 + unittest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); 404 402 rc = of_property_match_string(np, "missing-property", "blah"); 405 - selftest(rc == -EINVAL, "missing property; rc=%i\n", rc); 403 + unittest(rc == -EINVAL, "missing property; rc=%i\n", rc); 406 404 rc = of_property_match_string(np, "empty-property", "blah"); 407 - selftest(rc == -ENODATA, "empty property; rc=%i\n", rc); 405 + unittest(rc == -ENODATA, "empty property; rc=%i\n", rc); 408 406 rc = of_property_match_string(np, "unterminated-string", "blah"); 409 - selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 407 + unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 410 408 411 409 /* of_property_count_strings() tests */ 412 410 rc = of_property_count_strings(np, "string-property"); 413 - selftest(rc == 1, "Incorrect string count; rc=%i\n", rc); 411 + unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); 414 412 rc = of_property_count_strings(np, "phandle-list-names"); 415 - selftest(rc == 3, "Incorrect string count; rc=%i\n", rc); 413 + unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); 416 414 rc = of_property_count_strings(np, "unterminated-string"); 417 - selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 415 + unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 418 416 rc = of_property_count_strings(np, "unterminated-string-list"); 419 - selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); 417 + unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); 420 418 421 419 /* of_property_read_string_index() tests */ 422 420 rc = of_property_read_string_index(np, "string-property", 0, strings); 423 - selftest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc); 421 + unittest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc); 424 422 strings[0] = NULL; 425 423 rc = of_property_read_string_index(np, "string-property", 1, strings); 426 - selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 424 + unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 427 425 rc = of_property_read_string_index(np, "phandle-list-names", 0, strings); 428 - selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc); 426 + unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc); 429 427 rc = of_property_read_string_index(np, "phandle-list-names", 1, strings); 430 - selftest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc); 428 + unittest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc); 431 429 rc = of_property_read_string_index(np, "phandle-list-names", 2, strings); 432 - selftest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc); 430 + unittest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc); 433 431 strings[0] = NULL; 434 432 rc = of_property_read_string_index(np, "phandle-list-names", 3, strings); 435 - selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 433 + unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 436 434 strings[0] = NULL; 437 435 rc = of_property_read_string_index(np, "unterminated-string", 0, strings); 438 - selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 436 + unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 439 437 rc = of_property_read_string_index(np, "unterminated-string-list", 0, strings); 440 - selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc); 438 + unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc); 441 439 strings[0] = NULL; 442 440 rc = of_property_read_string_index(np, "unterminated-string-list", 2, strings); /* should fail */ 443 - selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 441 + unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); 444 442 strings[1] = NULL; 445 443 446 444 /* of_property_read_string_array() tests */ 447 445 rc = of_property_read_string_array(np, "string-property", strings, 4); 448 - selftest(rc == 1, "Incorrect string count; rc=%i\n", rc); 446 + unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); 449 447 rc = of_property_read_string_array(np, "phandle-list-names", strings, 4); 450 - selftest(rc == 3, "Incorrect string count; rc=%i\n", rc); 448 + unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); 451 449 rc = of_property_read_string_array(np, "unterminated-string", strings, 4); 452 - selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 450 + unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); 453 451 /* -- An incorrectly formed string should cause a failure */ 454 452 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4); 455 - selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); 453 + unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); 456 454 /* -- parsing the correctly formed strings should still work: */ 457 455 strings[2] = NULL; 458 456 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 2); 459 - selftest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc); 457 + unittest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc); 460 458 strings[1] = NULL; 461 459 rc = of_property_read_string_array(np, "phandle-list-names", strings, 1); 462 - selftest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]); 460 + unittest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]); 463 461 } 464 462 465 463 #define propcmp(p1, p2) (((p1)->length == (p2)->length) && \ 466 464 (p1)->value && (p2)->value && \ 467 465 !memcmp((p1)->value, (p2)->value, (p1)->length) && \ 468 466 !strcmp((p1)->name, (p2)->name)) 469 - static void __init of_selftest_property_copy(void) 467 + static void __init of_unittest_property_copy(void) 470 468 { 471 469 #ifdef CONFIG_OF_DYNAMIC 472 470 struct property p1 = { .name = "p1", .length = 0, .value = "" }; ··· 474 472 struct property *new; 475 473 476 474 new = __of_prop_dup(&p1, GFP_KERNEL); 477 - selftest(new && propcmp(&p1, new), "empty property didn't copy correctly\n"); 475 + unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\n"); 478 476 kfree(new->value); 479 477 kfree(new->name); 480 478 kfree(new); 481 479 482 480 new = __of_prop_dup(&p2, GFP_KERNEL); 483 - selftest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); 481 + unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); 484 482 kfree(new->value); 485 483 kfree(new->name); 486 484 kfree(new); 487 485 #endif 488 486 } 489 487 490 - static void __init of_selftest_changeset(void) 488 + static void __init of_unittest_changeset(void) 491 489 { 492 490 #ifdef CONFIG_OF_DYNAMIC 493 491 struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" }; ··· 497 495 struct of_changeset chgset; 498 496 499 497 n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); 500 - selftest(n1, "testcase setup failure\n"); 498 + unittest(n1, "testcase setup failure\n"); 501 499 n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); 502 - selftest(n2, "testcase setup failure\n"); 500 + unittest(n2, "testcase setup failure\n"); 503 501 n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); 504 - selftest(n21, "testcase setup failure %p\n", n21); 502 + unittest(n21, "testcase setup failure %p\n", n21); 505 503 nremove = of_find_node_by_path("/testcase-data/changeset/node-remove"); 506 - selftest(nremove, "testcase setup failure\n"); 504 + unittest(nremove, "testcase setup failure\n"); 507 505 ppadd = __of_prop_dup(&padd, GFP_KERNEL); 508 - selftest(ppadd, "testcase setup failure\n"); 506 + unittest(ppadd, "testcase setup failure\n"); 509 507 ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); 510 - selftest(ppupdate, "testcase setup failure\n"); 508 + unittest(ppupdate, "testcase setup failure\n"); 511 509 parent = nremove->parent; 512 510 n1->parent = parent; 513 511 n2->parent = parent; 514 512 n21->parent = n2; 515 513 n2->child = n21; 516 514 ppremove = of_find_property(parent, "prop-remove", NULL); 517 - selftest(ppremove, "failed to find removal prop"); 515 + unittest(ppremove, "failed to find removal prop"); 518 516 519 517 of_changeset_init(&chgset); 520 - selftest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); 521 - selftest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); 522 - selftest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); 523 - selftest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); 524 - selftest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n"); 525 - selftest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n"); 526 - selftest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); 518 + unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); 519 + unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); 520 + unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); 521 + unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); 522 + unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n"); 523 + unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n"); 524 + unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); 527 525 mutex_lock(&of_mutex); 528 - selftest(!of_changeset_apply(&chgset), "apply failed\n"); 526 + unittest(!of_changeset_apply(&chgset), "apply failed\n"); 529 527 mutex_unlock(&of_mutex); 530 528 531 529 /* Make sure node names are constructed correctly */ 532 - selftest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), 530 + unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), 533 531 "'%s' not added\n", n21->full_name); 534 532 of_node_put(np); 535 533 536 534 mutex_lock(&of_mutex); 537 - selftest(!of_changeset_revert(&chgset), "revert failed\n"); 535 + unittest(!of_changeset_revert(&chgset), "revert failed\n"); 538 536 mutex_unlock(&of_mutex); 539 537 540 538 of_changeset_destroy(&chgset); 541 539 #endif 542 540 } 543 541 544 - static void __init of_selftest_parse_interrupts(void) 542 + static void __init of_unittest_parse_interrupts(void) 545 543 { 546 544 struct device_node *np; 547 545 struct of_phandle_args args; ··· 555 553 556 554 for (i = 0; i < 4; i++) { 557 555 bool passed = true; 556 + 558 557 args.args_count = 0; 559 558 rc = of_irq_parse_one(np, i, &args); 560 559 ··· 563 560 passed &= (args.args_count == 1); 564 561 passed &= (args.args[0] == (i + 1)); 565 562 566 - selftest(passed, "index %i - data error on node %s rc=%i\n", 563 + unittest(passed, "index %i - data error on node %s rc=%i\n", 567 564 i, args.np->full_name, rc); 568 565 } 569 566 of_node_put(np); ··· 576 573 577 574 for (i = 0; i < 4; i++) { 578 575 bool passed = true; 576 + 579 577 args.args_count = 0; 580 578 rc = of_irq_parse_one(np, i, &args); 581 579 ··· 609 605 default: 610 606 passed = false; 611 607 } 612 - selftest(passed, "index %i - data error on node %s rc=%i\n", 608 + unittest(passed, "index %i - data error on node %s rc=%i\n", 613 609 i, args.np->full_name, rc); 614 610 } 615 611 of_node_put(np); 616 612 } 617 613 618 - static void __init of_selftest_parse_interrupts_extended(void) 614 + static void __init of_unittest_parse_interrupts_extended(void) 619 615 { 620 616 struct device_node *np; 621 617 struct of_phandle_args args; ··· 629 625 630 626 for (i = 0; i < 7; i++) { 631 627 bool passed = true; 628 + 632 629 rc = of_irq_parse_one(np, i, &args); 633 630 634 631 /* Test the values from tests-phandle.dtsi */ ··· 679 674 passed = false; 680 675 } 681 676 682 - selftest(passed, "index %i - data error on node %s rc=%i\n", 677 + unittest(passed, "index %i - data error on node %s rc=%i\n", 683 678 i, args.np->full_name, rc); 684 679 } 685 680 of_node_put(np); 686 681 } 687 682 688 - static struct of_device_id match_node_table[] = { 683 + static const struct of_device_id match_node_table[] = { 689 684 { .data = "A", .name = "name0", }, /* Name alone is lowest priority */ 690 685 { .data = "B", .type = "type1", }, /* followed by type alone */ 691 686 ··· 720 715 { .path = "/testcase-data/match-node/name9", .data = "K", }, 721 716 }; 722 717 723 - static void __init of_selftest_match_node(void) 718 + static void __init of_unittest_match_node(void) 724 719 { 725 720 struct device_node *np; 726 721 const struct of_device_id *match; ··· 729 724 for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) { 730 725 np = of_find_node_by_path(match_node_tests[i].path); 731 726 if (!np) { 732 - selftest(0, "missing testcase node %s\n", 727 + unittest(0, "missing testcase node %s\n", 733 728 match_node_tests[i].path); 734 729 continue; 735 730 } 736 731 737 732 match = of_match_node(match_node_table, np); 738 733 if (!match) { 739 - selftest(0, "%s didn't match anything\n", 734 + unittest(0, "%s didn't match anything\n", 740 735 match_node_tests[i].path); 741 736 continue; 742 737 } 743 738 744 739 if (strcmp(match->data, match_node_tests[i].data) != 0) { 745 - selftest(0, "%s got wrong match. expected %s, got %s\n", 740 + unittest(0, "%s got wrong match. expected %s, got %s\n", 746 741 match_node_tests[i].path, match_node_tests[i].data, 747 742 (const char *)match->data); 748 743 continue; 749 744 } 750 - selftest(1, "passed"); 745 + unittest(1, "passed"); 751 746 } 752 747 } 753 748 754 - struct device test_bus = { 755 - .init_name = "unittest-bus", 749 + static const struct platform_device_info test_bus_info = { 750 + .name = "unittest-bus", 756 751 }; 757 - static void __init of_selftest_platform_populate(void) 752 + static void __init of_unittest_platform_populate(void) 758 753 { 759 754 int irq, rc; 760 755 struct device_node *np, *child, *grandchild; 761 - struct platform_device *pdev; 762 - struct of_device_id match[] = { 756 + struct platform_device *pdev, *test_bus; 757 + const struct of_device_id match[] = { 763 758 { .compatible = "test-device", }, 764 759 {} 765 760 }; ··· 770 765 /* Test that a missing irq domain returns -EPROBE_DEFER */ 771 766 np = of_find_node_by_path("/testcase-data/testcase-device1"); 772 767 pdev = of_find_device_by_node(np); 773 - selftest(pdev, "device 1 creation failed\n"); 768 + unittest(pdev, "device 1 creation failed\n"); 774 769 775 770 irq = platform_get_irq(pdev, 0); 776 - selftest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq); 771 + unittest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq); 777 772 778 773 /* Test that a parsing failure does not return -EPROBE_DEFER */ 779 774 np = of_find_node_by_path("/testcase-data/testcase-device2"); 780 775 pdev = of_find_device_by_node(np); 781 - selftest(pdev, "device 2 creation failed\n"); 776 + unittest(pdev, "device 2 creation failed\n"); 782 777 irq = platform_get_irq(pdev, 0); 783 - selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); 778 + unittest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); 784 779 785 - if (selftest(np = of_find_node_by_path("/testcase-data/platform-tests"), 786 - "No testcase data in device tree\n")); 780 + np = of_find_node_by_path("/testcase-data/platform-tests"); 781 + unittest(np, "No testcase data in device tree\n"); 782 + if (!np) 787 783 return; 788 784 789 - if (selftest(!(rc = device_register(&test_bus)), 790 - "testbus registration failed; rc=%i\n", rc)); 785 + test_bus = platform_device_register_full(&test_bus_info); 786 + rc = PTR_ERR_OR_ZERO(test_bus); 787 + unittest(!rc, "testbus registration failed; rc=%i\n", rc); 788 + if (rc) 791 789 return; 790 + test_bus->dev.of_node = np; 792 791 792 + of_platform_populate(np, match, NULL, &test_bus->dev); 793 793 for_each_child_of_node(np, child) { 794 - of_platform_populate(child, match, NULL, &test_bus); 795 794 for_each_child_of_node(child, grandchild) 796 - selftest(of_find_device_by_node(grandchild), 795 + unittest(of_find_device_by_node(grandchild), 797 796 "Could not create device for node '%s'\n", 798 797 grandchild->name); 799 798 } 800 799 801 - of_platform_depopulate(&test_bus); 800 + of_platform_depopulate(&test_bus->dev); 802 801 for_each_child_of_node(np, child) { 803 802 for_each_child_of_node(child, grandchild) 804 - selftest(!of_find_device_by_node(grandchild), 803 + unittest(!of_find_device_by_node(grandchild), 805 804 "device didn't get destroyed '%s'\n", 806 805 grandchild->name); 807 806 } 808 807 809 - device_unregister(&test_bus); 808 + platform_device_unregister(test_bus); 810 809 of_node_put(np); 811 810 } 812 811 ··· 875 866 } 876 867 877 868 /** 878 - * selftest_data_add - Reads, copies data from 869 + * unittest_data_add - Reads, copies data from 879 870 * linked tree and attaches it to the live tree 880 871 */ 881 - static int __init selftest_data_add(void) 872 + static int __init unittest_data_add(void) 882 873 { 883 - void *selftest_data; 884 - struct device_node *selftest_data_node, *np; 874 + void *unittest_data; 875 + struct device_node *unittest_data_node, *np; 876 + /* 877 + * __dtb_testcases_begin[] and __dtb_testcases_end[] are magically 878 + * created by cmd_dt_S_dtb in scripts/Makefile.lib 879 + */ 885 880 extern uint8_t __dtb_testcases_begin[]; 886 881 extern uint8_t __dtb_testcases_end[]; 887 882 const int size = __dtb_testcases_end - __dtb_testcases_begin; ··· 898 885 } 899 886 900 887 /* creating copy */ 901 - selftest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL); 888 + unittest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL); 902 889 903 - if (!selftest_data) { 904 - pr_warn("%s: Failed to allocate memory for selftest_data; " 890 + if (!unittest_data) { 891 + pr_warn("%s: Failed to allocate memory for unittest_data; " 905 892 "not running tests\n", __func__); 906 893 return -ENOMEM; 907 894 } 908 - of_fdt_unflatten_tree(selftest_data, &selftest_data_node); 909 - if (!selftest_data_node) { 895 + of_fdt_unflatten_tree(unittest_data, &unittest_data_node); 896 + if (!unittest_data_node) { 910 897 pr_warn("%s: No tree to attach; not running tests\n", __func__); 911 898 return -ENODATA; 912 899 } 913 - of_node_set_flag(selftest_data_node, OF_DETACHED); 914 - rc = of_resolve_phandles(selftest_data_node); 900 + of_node_set_flag(unittest_data_node, OF_DETACHED); 901 + rc = of_resolve_phandles(unittest_data_node); 915 902 if (rc) { 916 903 pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); 917 904 return -EINVAL; 918 905 } 919 906 920 907 if (!of_root) { 921 - of_root = selftest_data_node; 908 + of_root = unittest_data_node; 922 909 for_each_of_allnodes(np) 923 910 __of_attach_node_sysfs(np); 924 911 of_aliases = of_find_node_by_path("/aliases"); ··· 927 914 } 928 915 929 916 /* attach the sub-tree to live tree */ 930 - np = selftest_data_node->child; 917 + np = unittest_data_node->child; 931 918 while (np) { 932 919 struct device_node *next = np->sibling; 920 + 933 921 np->parent = of_root; 934 922 attach_node_and_children(np); 935 923 np = next; ··· 940 926 941 927 #ifdef CONFIG_OF_OVERLAY 942 928 943 - static int selftest_probe(struct platform_device *pdev) 929 + static int unittest_probe(struct platform_device *pdev) 944 930 { 945 931 struct device *dev = &pdev->dev; 946 932 struct device_node *np = dev->of_node; ··· 958 944 return 0; 959 945 } 960 946 961 - static int selftest_remove(struct platform_device *pdev) 947 + static int unittest_remove(struct platform_device *pdev) 962 948 { 963 949 struct device *dev = &pdev->dev; 964 950 struct device_node *np = dev->of_node; ··· 967 953 return 0; 968 954 } 969 955 970 - static struct of_device_id selftest_match[] = { 971 - { .compatible = "selftest", }, 956 + static const struct of_device_id unittest_match[] = { 957 + { .compatible = "unittest", }, 972 958 {}, 973 959 }; 974 960 975 - static struct platform_driver selftest_driver = { 976 - .probe = selftest_probe, 977 - .remove = selftest_remove, 961 + static struct platform_driver unittest_driver = { 962 + .probe = unittest_probe, 963 + .remove = unittest_remove, 978 964 .driver = { 979 - .name = "selftest", 965 + .name = "unittest", 980 966 .owner = THIS_MODULE, 981 - .of_match_table = of_match_ptr(selftest_match), 967 + .of_match_table = of_match_ptr(unittest_match), 982 968 }, 983 969 }; 984 970 ··· 1060 1046 return 0; 1061 1047 } 1062 1048 1063 - static const char *selftest_path(int nr, enum overlay_type ovtype) 1049 + static const char *unittest_path(int nr, enum overlay_type ovtype) 1064 1050 { 1065 1051 const char *base; 1066 1052 static char buf[256]; ··· 1076 1062 buf[0] = '\0'; 1077 1063 return buf; 1078 1064 } 1079 - snprintf(buf, sizeof(buf) - 1, "%s/test-selftest%d", base, nr); 1065 + snprintf(buf, sizeof(buf) - 1, "%s/test-unittest%d", base, nr); 1080 1066 buf[sizeof(buf) - 1] = '\0'; 1081 1067 return buf; 1082 1068 } 1083 1069 1084 - static int of_selftest_device_exists(int selftest_nr, enum overlay_type ovtype) 1070 + static int of_unittest_device_exists(int unittest_nr, enum overlay_type ovtype) 1085 1071 { 1086 1072 const char *path; 1087 1073 1088 - path = selftest_path(selftest_nr, ovtype); 1074 + path = unittest_path(unittest_nr, ovtype); 1089 1075 1090 1076 switch (ovtype) { 1091 1077 case PDEV_OVERLAY: ··· 1109 1095 1110 1096 static const char *bus_path = "/testcase-data/overlay-node/test-bus"; 1111 1097 1112 - static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr, 1098 + static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr, 1113 1099 int *overlay_id) 1114 1100 { 1115 1101 struct device_node *np = NULL; ··· 1117 1103 1118 1104 np = of_find_node_by_path(overlay_path(overlay_nr)); 1119 1105 if (np == NULL) { 1120 - selftest(0, "could not find overlay node @\"%s\"\n", 1106 + unittest(0, "could not find overlay node @\"%s\"\n", 1121 1107 overlay_path(overlay_nr)); 1122 1108 ret = -EINVAL; 1123 1109 goto out; ··· 1125 1111 1126 1112 ret = of_overlay_create(np); 1127 1113 if (ret < 0) { 1128 - selftest(0, "could not create overlay from \"%s\"\n", 1114 + unittest(0, "could not create overlay from \"%s\"\n", 1129 1115 overlay_path(overlay_nr)); 1130 1116 goto out; 1131 1117 } ··· 1143 1129 } 1144 1130 1145 1131 /* apply an overlay while checking before and after states */ 1146 - static int of_selftest_apply_overlay_check(int overlay_nr, int selftest_nr, 1132 + static int of_unittest_apply_overlay_check(int overlay_nr, int unittest_nr, 1147 1133 int before, int after, enum overlay_type ovtype) 1148 1134 { 1149 1135 int ret; 1150 1136 1151 - /* selftest device must not be in before state */ 1152 - if (of_selftest_device_exists(selftest_nr, ovtype) != before) { 1153 - selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1137 + /* unittest device must not be in before state */ 1138 + if (of_unittest_device_exists(unittest_nr, ovtype) != before) { 1139 + unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1154 1140 overlay_path(overlay_nr), 1155 - selftest_path(selftest_nr, ovtype), 1141 + unittest_path(unittest_nr, ovtype), 1156 1142 !before ? "enabled" : "disabled"); 1157 1143 return -EINVAL; 1158 1144 } 1159 1145 1160 - ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, NULL); 1146 + ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, NULL); 1161 1147 if (ret != 0) { 1162 - /* of_selftest_apply_overlay already called selftest() */ 1148 + /* of_unittest_apply_overlay already called unittest() */ 1163 1149 return ret; 1164 1150 } 1165 1151 1166 - /* selftest device must be to set to after state */ 1167 - if (of_selftest_device_exists(selftest_nr, ovtype) != after) { 1168 - selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1152 + /* unittest device must be to set to after state */ 1153 + if (of_unittest_device_exists(unittest_nr, ovtype) != after) { 1154 + unittest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1169 1155 overlay_path(overlay_nr), 1170 - selftest_path(selftest_nr, ovtype), 1156 + unittest_path(unittest_nr, ovtype), 1171 1157 !after ? "enabled" : "disabled"); 1172 1158 return -EINVAL; 1173 1159 } ··· 1176 1162 } 1177 1163 1178 1164 /* apply an overlay and then revert it while checking before, after states */ 1179 - static int of_selftest_apply_revert_overlay_check(int overlay_nr, 1180 - int selftest_nr, int before, int after, 1165 + static int of_unittest_apply_revert_overlay_check(int overlay_nr, 1166 + int unittest_nr, int before, int after, 1181 1167 enum overlay_type ovtype) 1182 1168 { 1183 1169 int ret, ov_id; 1184 1170 1185 - /* selftest device must be in before state */ 1186 - if (of_selftest_device_exists(selftest_nr, ovtype) != before) { 1187 - selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1171 + /* unittest device must be in before state */ 1172 + if (of_unittest_device_exists(unittest_nr, ovtype) != before) { 1173 + unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1188 1174 overlay_path(overlay_nr), 1189 - selftest_path(selftest_nr, ovtype), 1175 + unittest_path(unittest_nr, ovtype), 1190 1176 !before ? "enabled" : "disabled"); 1191 1177 return -EINVAL; 1192 1178 } 1193 1179 1194 1180 /* apply the overlay */ 1195 - ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, &ov_id); 1181 + ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, &ov_id); 1196 1182 if (ret != 0) { 1197 - /* of_selftest_apply_overlay already called selftest() */ 1183 + /* of_unittest_apply_overlay already called unittest() */ 1198 1184 return ret; 1199 1185 } 1200 1186 1201 - /* selftest device must be in after state */ 1202 - if (of_selftest_device_exists(selftest_nr, ovtype) != after) { 1203 - selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1187 + /* unittest device must be in after state */ 1188 + if (of_unittest_device_exists(unittest_nr, ovtype) != after) { 1189 + unittest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1204 1190 overlay_path(overlay_nr), 1205 - selftest_path(selftest_nr, ovtype), 1191 + unittest_path(unittest_nr, ovtype), 1206 1192 !after ? "enabled" : "disabled"); 1207 1193 return -EINVAL; 1208 1194 } 1209 1195 1210 1196 ret = of_overlay_destroy(ov_id); 1211 1197 if (ret != 0) { 1212 - selftest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n", 1198 + unittest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n", 1213 1199 overlay_path(overlay_nr), 1214 - selftest_path(selftest_nr, ovtype)); 1200 + unittest_path(unittest_nr, ovtype)); 1215 1201 return ret; 1216 1202 } 1217 1203 1218 - /* selftest device must be again in before state */ 1219 - if (of_selftest_device_exists(selftest_nr, PDEV_OVERLAY) != before) { 1220 - selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1204 + /* unittest device must be again in before state */ 1205 + if (of_unittest_device_exists(unittest_nr, PDEV_OVERLAY) != before) { 1206 + unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1221 1207 overlay_path(overlay_nr), 1222 - selftest_path(selftest_nr, ovtype), 1208 + unittest_path(unittest_nr, ovtype), 1223 1209 !before ? "enabled" : "disabled"); 1224 1210 return -EINVAL; 1225 1211 } ··· 1228 1214 } 1229 1215 1230 1216 /* test activation of device */ 1231 - static void of_selftest_overlay_0(void) 1217 + static void of_unittest_overlay_0(void) 1232 1218 { 1233 1219 int ret; 1234 1220 1235 1221 /* device should enable */ 1236 - ret = of_selftest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY); 1222 + ret = of_unittest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY); 1237 1223 if (ret != 0) 1238 1224 return; 1239 1225 1240 - selftest(1, "overlay test %d passed\n", 0); 1226 + unittest(1, "overlay test %d passed\n", 0); 1241 1227 } 1242 1228 1243 1229 /* test deactivation of device */ 1244 - static void of_selftest_overlay_1(void) 1230 + static void of_unittest_overlay_1(void) 1245 1231 { 1246 1232 int ret; 1247 1233 1248 1234 /* device should disable */ 1249 - ret = of_selftest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY); 1235 + ret = of_unittest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY); 1250 1236 if (ret != 0) 1251 1237 return; 1252 1238 1253 - selftest(1, "overlay test %d passed\n", 1); 1239 + unittest(1, "overlay test %d passed\n", 1); 1254 1240 } 1255 1241 1256 1242 /* test activation of device */ 1257 - static void of_selftest_overlay_2(void) 1243 + static void of_unittest_overlay_2(void) 1258 1244 { 1259 1245 int ret; 1260 1246 1261 1247 /* device should enable */ 1262 - ret = of_selftest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY); 1248 + ret = of_unittest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY); 1263 1249 if (ret != 0) 1264 1250 return; 1265 1251 1266 - selftest(1, "overlay test %d passed\n", 2); 1252 + unittest(1, "overlay test %d passed\n", 2); 1267 1253 } 1268 1254 1269 1255 /* test deactivation of device */ 1270 - static void of_selftest_overlay_3(void) 1256 + static void of_unittest_overlay_3(void) 1271 1257 { 1272 1258 int ret; 1273 1259 1274 1260 /* device should disable */ 1275 - ret = of_selftest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY); 1261 + ret = of_unittest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY); 1276 1262 if (ret != 0) 1277 1263 return; 1278 1264 1279 - selftest(1, "overlay test %d passed\n", 3); 1265 + unittest(1, "overlay test %d passed\n", 3); 1280 1266 } 1281 1267 1282 1268 /* test activation of a full device node */ 1283 - static void of_selftest_overlay_4(void) 1269 + static void of_unittest_overlay_4(void) 1284 1270 { 1285 1271 int ret; 1286 1272 1287 1273 /* device should disable */ 1288 - ret = of_selftest_apply_overlay_check(4, 4, 0, 1, PDEV_OVERLAY); 1274 + ret = of_unittest_apply_overlay_check(4, 4, 0, 1, PDEV_OVERLAY); 1289 1275 if (ret != 0) 1290 1276 return; 1291 1277 1292 - selftest(1, "overlay test %d passed\n", 4); 1278 + unittest(1, "overlay test %d passed\n", 4); 1293 1279 } 1294 1280 1295 1281 /* test overlay apply/revert sequence */ 1296 - static void of_selftest_overlay_5(void) 1282 + static void of_unittest_overlay_5(void) 1297 1283 { 1298 1284 int ret; 1299 1285 1300 1286 /* device should disable */ 1301 - ret = of_selftest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY); 1287 + ret = of_unittest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY); 1302 1288 if (ret != 0) 1303 1289 return; 1304 1290 1305 - selftest(1, "overlay test %d passed\n", 5); 1291 + unittest(1, "overlay test %d passed\n", 5); 1306 1292 } 1307 1293 1308 1294 /* test overlay application in sequence */ 1309 - static void of_selftest_overlay_6(void) 1295 + static void of_unittest_overlay_6(void) 1310 1296 { 1311 1297 struct device_node *np; 1312 1298 int ret, i, ov_id[2]; 1313 - int overlay_nr = 6, selftest_nr = 6; 1299 + int overlay_nr = 6, unittest_nr = 6; 1314 1300 int before = 0, after = 1; 1315 1301 1316 - /* selftest device must be in before state */ 1302 + /* unittest device must be in before state */ 1317 1303 for (i = 0; i < 2; i++) { 1318 - if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1304 + if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) 1319 1305 != before) { 1320 - selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1306 + unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1321 1307 overlay_path(overlay_nr + i), 1322 - selftest_path(selftest_nr + i, 1308 + unittest_path(unittest_nr + i, 1323 1309 PDEV_OVERLAY), 1324 1310 !before ? "enabled" : "disabled"); 1325 1311 return; ··· 1331 1317 1332 1318 np = of_find_node_by_path(overlay_path(overlay_nr + i)); 1333 1319 if (np == NULL) { 1334 - selftest(0, "could not find overlay node @\"%s\"\n", 1320 + unittest(0, "could not find overlay node @\"%s\"\n", 1335 1321 overlay_path(overlay_nr + i)); 1336 1322 return; 1337 1323 } 1338 1324 1339 1325 ret = of_overlay_create(np); 1340 1326 if (ret < 0) { 1341 - selftest(0, "could not create overlay from \"%s\"\n", 1327 + unittest(0, "could not create overlay from \"%s\"\n", 1342 1328 overlay_path(overlay_nr + i)); 1343 1329 return; 1344 1330 } ··· 1346 1332 } 1347 1333 1348 1334 for (i = 0; i < 2; i++) { 1349 - /* selftest device must be in after state */ 1350 - if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1335 + /* unittest device must be in after state */ 1336 + if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) 1351 1337 != after) { 1352 - selftest(0, "overlay @\"%s\" failed @\"%s\" %s\n", 1338 + unittest(0, "overlay @\"%s\" failed @\"%s\" %s\n", 1353 1339 overlay_path(overlay_nr + i), 1354 - selftest_path(selftest_nr + i, 1340 + unittest_path(unittest_nr + i, 1355 1341 PDEV_OVERLAY), 1356 1342 !after ? "enabled" : "disabled"); 1357 1343 return; ··· 1361 1347 for (i = 1; i >= 0; i--) { 1362 1348 ret = of_overlay_destroy(ov_id[i]); 1363 1349 if (ret != 0) { 1364 - selftest(0, "overlay @\"%s\" failed destroy @\"%s\"\n", 1350 + unittest(0, "overlay @\"%s\" failed destroy @\"%s\"\n", 1365 1351 overlay_path(overlay_nr + i), 1366 - selftest_path(selftest_nr + i, 1352 + unittest_path(unittest_nr + i, 1367 1353 PDEV_OVERLAY)); 1368 1354 return; 1369 1355 } 1370 1356 } 1371 1357 1372 1358 for (i = 0; i < 2; i++) { 1373 - /* selftest device must be again in before state */ 1374 - if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1359 + /* unittest device must be again in before state */ 1360 + if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) 1375 1361 != before) { 1376 - selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1362 + unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1377 1363 overlay_path(overlay_nr + i), 1378 - selftest_path(selftest_nr + i, 1364 + unittest_path(unittest_nr + i, 1379 1365 PDEV_OVERLAY), 1380 1366 !before ? "enabled" : "disabled"); 1381 1367 return; 1382 1368 } 1383 1369 } 1384 1370 1385 - selftest(1, "overlay test %d passed\n", 6); 1371 + unittest(1, "overlay test %d passed\n", 6); 1386 1372 } 1387 1373 1388 1374 /* test overlay application in sequence */ 1389 - static void of_selftest_overlay_8(void) 1375 + static void of_unittest_overlay_8(void) 1390 1376 { 1391 1377 struct device_node *np; 1392 1378 int ret, i, ov_id[2]; 1393 - int overlay_nr = 8, selftest_nr = 8; 1379 + int overlay_nr = 8, unittest_nr = 8; 1394 1380 1395 1381 /* we don't care about device state in this test */ 1396 1382 ··· 1399 1385 1400 1386 np = of_find_node_by_path(overlay_path(overlay_nr + i)); 1401 1387 if (np == NULL) { 1402 - selftest(0, "could not find overlay node @\"%s\"\n", 1388 + unittest(0, "could not find overlay node @\"%s\"\n", 1403 1389 overlay_path(overlay_nr + i)); 1404 1390 return; 1405 1391 } 1406 1392 1407 1393 ret = of_overlay_create(np); 1408 1394 if (ret < 0) { 1409 - selftest(0, "could not create overlay from \"%s\"\n", 1395 + unittest(0, "could not create overlay from \"%s\"\n", 1410 1396 overlay_path(overlay_nr + i)); 1411 1397 return; 1412 1398 } ··· 1416 1402 /* now try to remove first overlay (it should fail) */ 1417 1403 ret = of_overlay_destroy(ov_id[0]); 1418 1404 if (ret == 0) { 1419 - selftest(0, "overlay @\"%s\" was destroyed @\"%s\"\n", 1405 + unittest(0, "overlay @\"%s\" was destroyed @\"%s\"\n", 1420 1406 overlay_path(overlay_nr + 0), 1421 - selftest_path(selftest_nr, 1407 + unittest_path(unittest_nr, 1422 1408 PDEV_OVERLAY)); 1423 1409 return; 1424 1410 } ··· 1427 1413 for (i = 1; i >= 0; i--) { 1428 1414 ret = of_overlay_destroy(ov_id[i]); 1429 1415 if (ret != 0) { 1430 - selftest(0, "overlay @\"%s\" not destroyed @\"%s\"\n", 1416 + unittest(0, "overlay @\"%s\" not destroyed @\"%s\"\n", 1431 1417 overlay_path(overlay_nr + i), 1432 - selftest_path(selftest_nr, 1418 + unittest_path(unittest_nr, 1433 1419 PDEV_OVERLAY)); 1434 1420 return; 1435 1421 } 1436 1422 } 1437 1423 1438 - selftest(1, "overlay test %d passed\n", 8); 1424 + unittest(1, "overlay test %d passed\n", 8); 1439 1425 } 1440 1426 1441 1427 /* test insertion of a bus with parent devices */ 1442 - static void of_selftest_overlay_10(void) 1428 + static void of_unittest_overlay_10(void) 1443 1429 { 1444 1430 int ret; 1445 1431 char *child_path; 1446 1432 1447 1433 /* device should disable */ 1448 - ret = of_selftest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY); 1449 - if (selftest(ret == 0, 1434 + ret = of_unittest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY); 1435 + if (unittest(ret == 0, 1450 1436 "overlay test %d failed; overlay application\n", 10)) 1451 1437 return; 1452 1438 1453 - child_path = kasprintf(GFP_KERNEL, "%s/test-selftest101", 1454 - selftest_path(10, PDEV_OVERLAY)); 1455 - if (selftest(child_path, "overlay test %d failed; kasprintf\n", 10)) 1439 + child_path = kasprintf(GFP_KERNEL, "%s/test-unittest101", 1440 + unittest_path(10, PDEV_OVERLAY)); 1441 + if (unittest(child_path, "overlay test %d failed; kasprintf\n", 10)) 1456 1442 return; 1457 1443 1458 1444 ret = of_path_device_type_exists(child_path, PDEV_OVERLAY); 1459 1445 kfree(child_path); 1460 - if (selftest(ret, "overlay test %d failed; no child device\n", 10)) 1446 + if (unittest(ret, "overlay test %d failed; no child device\n", 10)) 1461 1447 return; 1462 1448 } 1463 1449 1464 1450 /* test insertion of a bus with parent devices (and revert) */ 1465 - static void of_selftest_overlay_11(void) 1451 + static void of_unittest_overlay_11(void) 1466 1452 { 1467 1453 int ret; 1468 1454 1469 1455 /* device should disable */ 1470 - ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1, 1456 + ret = of_unittest_apply_revert_overlay_check(11, 11, 0, 1, 1471 1457 PDEV_OVERLAY); 1472 - if (selftest(ret == 0, 1458 + if (unittest(ret == 0, 1473 1459 "overlay test %d failed; overlay application\n", 11)) 1474 1460 return; 1475 1461 } 1476 1462 1477 1463 #if IS_BUILTIN(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) 1478 1464 1479 - struct selftest_i2c_bus_data { 1465 + struct unittest_i2c_bus_data { 1480 1466 struct platform_device *pdev; 1481 1467 struct i2c_adapter adap; 1482 1468 }; 1483 1469 1484 - static int selftest_i2c_master_xfer(struct i2c_adapter *adap, 1470 + static int unittest_i2c_master_xfer(struct i2c_adapter *adap, 1485 1471 struct i2c_msg *msgs, int num) 1486 1472 { 1487 - struct selftest_i2c_bus_data *std = i2c_get_adapdata(adap); 1473 + struct unittest_i2c_bus_data *std = i2c_get_adapdata(adap); 1488 1474 1489 1475 (void)std; 1490 1476 1491 1477 return num; 1492 1478 } 1493 1479 1494 - static u32 selftest_i2c_functionality(struct i2c_adapter *adap) 1480 + static u32 unittest_i2c_functionality(struct i2c_adapter *adap) 1495 1481 { 1496 1482 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 1497 1483 } 1498 1484 1499 - static const struct i2c_algorithm selftest_i2c_algo = { 1500 - .master_xfer = selftest_i2c_master_xfer, 1501 - .functionality = selftest_i2c_functionality, 1485 + static const struct i2c_algorithm unittest_i2c_algo = { 1486 + .master_xfer = unittest_i2c_master_xfer, 1487 + .functionality = unittest_i2c_functionality, 1502 1488 }; 1503 1489 1504 - static int selftest_i2c_bus_probe(struct platform_device *pdev) 1490 + static int unittest_i2c_bus_probe(struct platform_device *pdev) 1505 1491 { 1506 1492 struct device *dev = &pdev->dev; 1507 1493 struct device_node *np = dev->of_node; 1508 - struct selftest_i2c_bus_data *std; 1494 + struct unittest_i2c_bus_data *std; 1509 1495 struct i2c_adapter *adap; 1510 1496 int ret; 1511 1497 ··· 1519 1505 1520 1506 std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); 1521 1507 if (!std) { 1522 - dev_err(dev, "Failed to allocate selftest i2c data\n"); 1508 + dev_err(dev, "Failed to allocate unittest i2c data\n"); 1523 1509 return -ENOMEM; 1524 1510 } 1525 1511 ··· 1532 1518 adap->nr = -1; 1533 1519 strlcpy(adap->name, pdev->name, sizeof(adap->name)); 1534 1520 adap->class = I2C_CLASS_DEPRECATED; 1535 - adap->algo = &selftest_i2c_algo; 1521 + adap->algo = &unittest_i2c_algo; 1536 1522 adap->dev.parent = dev; 1537 1523 adap->dev.of_node = dev->of_node; 1538 1524 adap->timeout = 5 * HZ; ··· 1547 1533 return 0; 1548 1534 } 1549 1535 1550 - static int selftest_i2c_bus_remove(struct platform_device *pdev) 1536 + static int unittest_i2c_bus_remove(struct platform_device *pdev) 1551 1537 { 1552 1538 struct device *dev = &pdev->dev; 1553 1539 struct device_node *np = dev->of_node; 1554 - struct selftest_i2c_bus_data *std = platform_get_drvdata(pdev); 1540 + struct unittest_i2c_bus_data *std = platform_get_drvdata(pdev); 1555 1541 1556 1542 dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1557 1543 i2c_del_adapter(&std->adap); ··· 1559 1545 return 0; 1560 1546 } 1561 1547 1562 - static struct of_device_id selftest_i2c_bus_match[] = { 1563 - { .compatible = "selftest-i2c-bus", }, 1548 + static const struct of_device_id unittest_i2c_bus_match[] = { 1549 + { .compatible = "unittest-i2c-bus", }, 1564 1550 {}, 1565 1551 }; 1566 1552 1567 - static struct platform_driver selftest_i2c_bus_driver = { 1568 - .probe = selftest_i2c_bus_probe, 1569 - .remove = selftest_i2c_bus_remove, 1553 + static struct platform_driver unittest_i2c_bus_driver = { 1554 + .probe = unittest_i2c_bus_probe, 1555 + .remove = unittest_i2c_bus_remove, 1570 1556 .driver = { 1571 - .name = "selftest-i2c-bus", 1572 - .of_match_table = of_match_ptr(selftest_i2c_bus_match), 1557 + .name = "unittest-i2c-bus", 1558 + .of_match_table = of_match_ptr(unittest_i2c_bus_match), 1573 1559 }, 1574 1560 }; 1575 1561 1576 - static int selftest_i2c_dev_probe(struct i2c_client *client, 1562 + static int unittest_i2c_dev_probe(struct i2c_client *client, 1577 1563 const struct i2c_device_id *id) 1578 1564 { 1579 1565 struct device *dev = &client->dev; ··· 1589 1575 return 0; 1590 1576 }; 1591 1577 1592 - static int selftest_i2c_dev_remove(struct i2c_client *client) 1578 + static int unittest_i2c_dev_remove(struct i2c_client *client) 1593 1579 { 1594 1580 struct device *dev = &client->dev; 1595 1581 struct device_node *np = client->dev.of_node; ··· 1598 1584 return 0; 1599 1585 } 1600 1586 1601 - static const struct i2c_device_id selftest_i2c_dev_id[] = { 1602 - { .name = "selftest-i2c-dev" }, 1587 + static const struct i2c_device_id unittest_i2c_dev_id[] = { 1588 + { .name = "unittest-i2c-dev" }, 1603 1589 { } 1604 1590 }; 1605 1591 1606 - static struct i2c_driver selftest_i2c_dev_driver = { 1592 + static struct i2c_driver unittest_i2c_dev_driver = { 1607 1593 .driver = { 1608 - .name = "selftest-i2c-dev", 1594 + .name = "unittest-i2c-dev", 1609 1595 .owner = THIS_MODULE, 1610 1596 }, 1611 - .probe = selftest_i2c_dev_probe, 1612 - .remove = selftest_i2c_dev_remove, 1613 - .id_table = selftest_i2c_dev_id, 1597 + .probe = unittest_i2c_dev_probe, 1598 + .remove = unittest_i2c_dev_remove, 1599 + .id_table = unittest_i2c_dev_id, 1614 1600 }; 1615 1601 1616 1602 #if IS_BUILTIN(CONFIG_I2C_MUX) 1617 1603 1618 - struct selftest_i2c_mux_data { 1604 + struct unittest_i2c_mux_data { 1619 1605 int nchans; 1620 1606 struct i2c_adapter *adap[]; 1621 1607 }; 1622 1608 1623 - static int selftest_i2c_mux_select_chan(struct i2c_adapter *adap, 1609 + static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap, 1624 1610 void *client, u32 chan) 1625 1611 { 1626 1612 return 0; 1627 1613 } 1628 1614 1629 - static int selftest_i2c_mux_probe(struct i2c_client *client, 1615 + static int unittest_i2c_mux_probe(struct i2c_client *client, 1630 1616 const struct i2c_device_id *id) 1631 1617 { 1632 1618 int ret, i, nchans, size; 1633 1619 struct device *dev = &client->dev; 1634 1620 struct i2c_adapter *adap = to_i2c_adapter(dev->parent); 1635 1621 struct device_node *np = client->dev.of_node, *child; 1636 - struct selftest_i2c_mux_data *stm; 1622 + struct unittest_i2c_mux_data *stm; 1637 1623 u32 reg, max_reg; 1638 1624 1639 1625 dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); ··· 1657 1643 return -EINVAL; 1658 1644 } 1659 1645 1660 - size = offsetof(struct selftest_i2c_mux_data, adap[nchans]); 1646 + size = offsetof(struct unittest_i2c_mux_data, adap[nchans]); 1661 1647 stm = devm_kzalloc(dev, size, GFP_KERNEL); 1662 1648 if (!stm) { 1663 1649 dev_err(dev, "Out of memory\n"); ··· 1666 1652 stm->nchans = nchans; 1667 1653 for (i = 0; i < nchans; i++) { 1668 1654 stm->adap[i] = i2c_add_mux_adapter(adap, dev, client, 1669 - 0, i, 0, selftest_i2c_mux_select_chan, NULL); 1655 + 0, i, 0, unittest_i2c_mux_select_chan, NULL); 1670 1656 if (!stm->adap[i]) { 1671 1657 dev_err(dev, "Failed to register mux #%d\n", i); 1672 1658 for (i--; i >= 0; i--) ··· 1680 1666 return 0; 1681 1667 }; 1682 1668 1683 - static int selftest_i2c_mux_remove(struct i2c_client *client) 1669 + static int unittest_i2c_mux_remove(struct i2c_client *client) 1684 1670 { 1685 1671 struct device *dev = &client->dev; 1686 1672 struct device_node *np = client->dev.of_node; 1687 - struct selftest_i2c_mux_data *stm = i2c_get_clientdata(client); 1673 + struct unittest_i2c_mux_data *stm = i2c_get_clientdata(client); 1688 1674 int i; 1689 1675 1690 1676 dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); ··· 1693 1679 return 0; 1694 1680 } 1695 1681 1696 - static const struct i2c_device_id selftest_i2c_mux_id[] = { 1697 - { .name = "selftest-i2c-mux" }, 1682 + static const struct i2c_device_id unittest_i2c_mux_id[] = { 1683 + { .name = "unittest-i2c-mux" }, 1698 1684 { } 1699 1685 }; 1700 1686 1701 - static struct i2c_driver selftest_i2c_mux_driver = { 1687 + static struct i2c_driver unittest_i2c_mux_driver = { 1702 1688 .driver = { 1703 - .name = "selftest-i2c-mux", 1689 + .name = "unittest-i2c-mux", 1704 1690 .owner = THIS_MODULE, 1705 1691 }, 1706 - .probe = selftest_i2c_mux_probe, 1707 - .remove = selftest_i2c_mux_remove, 1708 - .id_table = selftest_i2c_mux_id, 1692 + .probe = unittest_i2c_mux_probe, 1693 + .remove = unittest_i2c_mux_remove, 1694 + .id_table = unittest_i2c_mux_id, 1709 1695 }; 1710 1696 1711 1697 #endif 1712 1698 1713 - static int of_selftest_overlay_i2c_init(void) 1699 + static int of_unittest_overlay_i2c_init(void) 1714 1700 { 1715 1701 int ret; 1716 1702 1717 - ret = i2c_add_driver(&selftest_i2c_dev_driver); 1718 - if (selftest(ret == 0, 1719 - "could not register selftest i2c device driver\n")) 1703 + ret = i2c_add_driver(&unittest_i2c_dev_driver); 1704 + if (unittest(ret == 0, 1705 + "could not register unittest i2c device driver\n")) 1720 1706 return ret; 1721 1707 1722 - ret = platform_driver_register(&selftest_i2c_bus_driver); 1723 - if (selftest(ret == 0, 1724 - "could not register selftest i2c bus driver\n")) 1708 + ret = platform_driver_register(&unittest_i2c_bus_driver); 1709 + if (unittest(ret == 0, 1710 + "could not register unittest i2c bus driver\n")) 1725 1711 return ret; 1726 1712 1727 1713 #if IS_BUILTIN(CONFIG_I2C_MUX) 1728 - ret = i2c_add_driver(&selftest_i2c_mux_driver); 1729 - if (selftest(ret == 0, 1730 - "could not register selftest i2c mux driver\n")) 1714 + ret = i2c_add_driver(&unittest_i2c_mux_driver); 1715 + if (unittest(ret == 0, 1716 + "could not register unittest i2c mux driver\n")) 1731 1717 return ret; 1732 1718 #endif 1733 1719 1734 1720 return 0; 1735 1721 } 1736 1722 1737 - static void of_selftest_overlay_i2c_cleanup(void) 1723 + static void of_unittest_overlay_i2c_cleanup(void) 1738 1724 { 1739 1725 #if IS_BUILTIN(CONFIG_I2C_MUX) 1740 - i2c_del_driver(&selftest_i2c_mux_driver); 1726 + i2c_del_driver(&unittest_i2c_mux_driver); 1741 1727 #endif 1742 - platform_driver_unregister(&selftest_i2c_bus_driver); 1743 - i2c_del_driver(&selftest_i2c_dev_driver); 1728 + platform_driver_unregister(&unittest_i2c_bus_driver); 1729 + i2c_del_driver(&unittest_i2c_dev_driver); 1744 1730 } 1745 1731 1746 - static void of_selftest_overlay_i2c_12(void) 1732 + static void of_unittest_overlay_i2c_12(void) 1747 1733 { 1748 1734 int ret; 1749 1735 1750 1736 /* device should enable */ 1751 - ret = of_selftest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY); 1737 + ret = of_unittest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY); 1752 1738 if (ret != 0) 1753 1739 return; 1754 1740 1755 - selftest(1, "overlay test %d passed\n", 12); 1741 + unittest(1, "overlay test %d passed\n", 12); 1756 1742 } 1757 1743 1758 1744 /* test deactivation of device */ 1759 - static void of_selftest_overlay_i2c_13(void) 1745 + static void of_unittest_overlay_i2c_13(void) 1760 1746 { 1761 1747 int ret; 1762 1748 1763 1749 /* device should disable */ 1764 - ret = of_selftest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY); 1750 + ret = of_unittest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY); 1765 1751 if (ret != 0) 1766 1752 return; 1767 1753 1768 - selftest(1, "overlay test %d passed\n", 13); 1754 + unittest(1, "overlay test %d passed\n", 13); 1769 1755 } 1770 1756 1771 1757 /* just check for i2c mux existence */ 1772 - static void of_selftest_overlay_i2c_14(void) 1758 + static void of_unittest_overlay_i2c_14(void) 1773 1759 { 1774 1760 } 1775 1761 1776 - static void of_selftest_overlay_i2c_15(void) 1762 + static void of_unittest_overlay_i2c_15(void) 1777 1763 { 1778 1764 int ret; 1779 1765 1780 1766 /* device should enable */ 1781 - ret = of_selftest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); 1767 + ret = of_unittest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); 1782 1768 if (ret != 0) 1783 1769 return; 1784 1770 1785 - selftest(1, "overlay test %d passed\n", 15); 1771 + unittest(1, "overlay test %d passed\n", 15); 1786 1772 } 1787 1773 1788 1774 #else 1789 1775 1790 - static inline void of_selftest_overlay_i2c_14(void) { } 1791 - static inline void of_selftest_overlay_i2c_15(void) { } 1776 + static inline void of_unittest_overlay_i2c_14(void) { } 1777 + static inline void of_unittest_overlay_i2c_15(void) { } 1792 1778 1793 1779 #endif 1794 1780 1795 - static void __init of_selftest_overlay(void) 1781 + static void __init of_unittest_overlay(void) 1796 1782 { 1797 1783 struct device_node *bus_np = NULL; 1798 1784 int ret; 1799 1785 1800 - ret = platform_driver_register(&selftest_driver); 1786 + ret = platform_driver_register(&unittest_driver); 1801 1787 if (ret != 0) { 1802 - selftest(0, "could not register selftest driver\n"); 1788 + unittest(0, "could not register unittest driver\n"); 1803 1789 goto out; 1804 1790 } 1805 1791 1806 1792 bus_np = of_find_node_by_path(bus_path); 1807 1793 if (bus_np == NULL) { 1808 - selftest(0, "could not find bus_path \"%s\"\n", bus_path); 1794 + unittest(0, "could not find bus_path \"%s\"\n", bus_path); 1809 1795 goto out; 1810 1796 } 1811 1797 1812 1798 ret = of_platform_populate(bus_np, of_default_bus_match_table, 1813 1799 NULL, NULL); 1814 1800 if (ret != 0) { 1815 - selftest(0, "could not populate bus @ \"%s\"\n", bus_path); 1801 + unittest(0, "could not populate bus @ \"%s\"\n", bus_path); 1816 1802 goto out; 1817 1803 } 1818 1804 1819 - if (!of_selftest_device_exists(100, PDEV_OVERLAY)) { 1820 - selftest(0, "could not find selftest0 @ \"%s\"\n", 1821 - selftest_path(100, PDEV_OVERLAY)); 1805 + if (!of_unittest_device_exists(100, PDEV_OVERLAY)) { 1806 + unittest(0, "could not find unittest0 @ \"%s\"\n", 1807 + unittest_path(100, PDEV_OVERLAY)); 1822 1808 goto out; 1823 1809 } 1824 1810 1825 - if (of_selftest_device_exists(101, PDEV_OVERLAY)) { 1826 - selftest(0, "selftest1 @ \"%s\" should not exist\n", 1827 - selftest_path(101, PDEV_OVERLAY)); 1811 + if (of_unittest_device_exists(101, PDEV_OVERLAY)) { 1812 + unittest(0, "unittest1 @ \"%s\" should not exist\n", 1813 + unittest_path(101, PDEV_OVERLAY)); 1828 1814 goto out; 1829 1815 } 1830 1816 1831 - selftest(1, "basic infrastructure of overlays passed"); 1817 + unittest(1, "basic infrastructure of overlays passed"); 1832 1818 1833 1819 /* tests in sequence */ 1834 - of_selftest_overlay_0(); 1835 - of_selftest_overlay_1(); 1836 - of_selftest_overlay_2(); 1837 - of_selftest_overlay_3(); 1838 - of_selftest_overlay_4(); 1839 - of_selftest_overlay_5(); 1840 - of_selftest_overlay_6(); 1841 - of_selftest_overlay_8(); 1820 + of_unittest_overlay_0(); 1821 + of_unittest_overlay_1(); 1822 + of_unittest_overlay_2(); 1823 + of_unittest_overlay_3(); 1824 + of_unittest_overlay_4(); 1825 + of_unittest_overlay_5(); 1826 + of_unittest_overlay_6(); 1827 + of_unittest_overlay_8(); 1842 1828 1843 - of_selftest_overlay_10(); 1844 - of_selftest_overlay_11(); 1829 + of_unittest_overlay_10(); 1830 + of_unittest_overlay_11(); 1845 1831 1846 1832 #if IS_BUILTIN(CONFIG_I2C) 1847 - if (selftest(of_selftest_overlay_i2c_init() == 0, "i2c init failed\n")) 1833 + if (unittest(of_unittest_overlay_i2c_init() == 0, "i2c init failed\n")) 1848 1834 goto out; 1849 1835 1850 - of_selftest_overlay_i2c_12(); 1851 - of_selftest_overlay_i2c_13(); 1852 - of_selftest_overlay_i2c_14(); 1853 - of_selftest_overlay_i2c_15(); 1836 + of_unittest_overlay_i2c_12(); 1837 + of_unittest_overlay_i2c_13(); 1838 + of_unittest_overlay_i2c_14(); 1839 + of_unittest_overlay_i2c_15(); 1854 1840 1855 - of_selftest_overlay_i2c_cleanup(); 1841 + of_unittest_overlay_i2c_cleanup(); 1856 1842 #endif 1857 1843 1858 1844 out: ··· 1860 1846 } 1861 1847 1862 1848 #else 1863 - static inline void __init of_selftest_overlay(void) { } 1849 + static inline void __init of_unittest_overlay(void) { } 1864 1850 #endif 1865 1851 1866 - static int __init of_selftest(void) 1852 + static int __init of_unittest(void) 1867 1853 { 1868 1854 struct device_node *np; 1869 1855 int res; 1870 1856 1871 - /* adding data for selftest */ 1872 - res = selftest_data_add(); 1857 + /* adding data for unittest */ 1858 + res = unittest_data_add(); 1873 1859 if (res) 1874 1860 return res; 1875 1861 if (!of_aliases) ··· 1882 1868 } 1883 1869 of_node_put(np); 1884 1870 1885 - pr_info("start of selftest - you will see error messages\n"); 1886 - of_selftest_check_tree_linkage(); 1887 - of_selftest_check_phandles(); 1888 - of_selftest_find_node_by_name(); 1889 - of_selftest_dynamic(); 1890 - of_selftest_parse_phandle_with_args(); 1891 - of_selftest_property_string(); 1892 - of_selftest_property_copy(); 1893 - of_selftest_changeset(); 1894 - of_selftest_parse_interrupts(); 1895 - of_selftest_parse_interrupts_extended(); 1896 - of_selftest_match_node(); 1897 - of_selftest_platform_populate(); 1898 - of_selftest_overlay(); 1871 + pr_info("start of unittest - you will see error messages\n"); 1872 + of_unittest_check_tree_linkage(); 1873 + of_unittest_check_phandles(); 1874 + of_unittest_find_node_by_name(); 1875 + of_unittest_dynamic(); 1876 + of_unittest_parse_phandle_with_args(); 1877 + of_unittest_property_string(); 1878 + of_unittest_property_copy(); 1879 + of_unittest_changeset(); 1880 + of_unittest_parse_interrupts(); 1881 + of_unittest_parse_interrupts_extended(); 1882 + of_unittest_match_node(); 1883 + of_unittest_platform_populate(); 1884 + of_unittest_overlay(); 1899 1885 1900 1886 /* Double check linkage after removing testcase data */ 1901 - of_selftest_check_tree_linkage(); 1887 + of_unittest_check_tree_linkage(); 1902 1888 1903 - pr_info("end of selftest - %i passed, %i failed\n", 1904 - selftest_results.passed, selftest_results.failed); 1889 + pr_info("end of unittest - %i passed, %i failed\n", 1890 + unittest_results.passed, unittest_results.failed); 1905 1891 1906 1892 return 0; 1907 1893 } 1908 - late_initcall(of_selftest); 1894 + late_initcall(of_unittest);
+1 -6
drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
··· 164 164 165 165 pn = of_graph_get_remote_port_parent(n); 166 166 167 - if (!pn) { 168 - of_node_put(n); 167 + if (!pn) 169 168 continue; 170 - } 171 169 172 170 if (!of_device_is_available(pn) || omapdss_list_contains(pn)) { 173 171 of_node_put(pn); 174 - of_node_put(n); 175 172 continue; 176 173 } 177 174 178 175 omapdss_walk_device(pn, false); 179 - 180 - of_node_put(n); 181 176 } 182 177 } 183 178
+32
include/linux/of.h
··· 622 622 return NULL; 623 623 } 624 624 625 + static inline int of_node_check_flag(struct device_node *n, unsigned long flag) 626 + { 627 + return 0; 628 + } 629 + 630 + static inline int of_node_test_and_set_flag(struct device_node *n, 631 + unsigned long flag) 632 + { 633 + return 0; 634 + } 635 + 636 + static inline void of_node_set_flag(struct device_node *n, unsigned long flag) 637 + { 638 + } 639 + 640 + static inline void of_node_clear_flag(struct device_node *n, unsigned long flag) 641 + { 642 + } 643 + 644 + static inline int of_property_check_flag(struct property *p, unsigned long flag) 645 + { 646 + return 0; 647 + } 648 + 649 + static inline void of_property_set_flag(struct property *p, unsigned long flag) 650 + { 651 + } 652 + 653 + static inline void of_property_clear_flag(struct property *p, unsigned long flag) 654 + { 655 + } 656 + 625 657 #define of_match_ptr(_ptr) NULL 626 658 #define of_match_node(_matches, _node) NULL 627 659 #endif /* CONFIG_OF */
+20
include/linux/of_graph.h
··· 14 14 #ifndef __LINUX_OF_GRAPH_H 15 15 #define __LINUX_OF_GRAPH_H 16 16 17 + #include <linux/types.h> 18 + 17 19 /** 18 20 * struct of_endpoint - the OF graph endpoint data structure 19 21 * @port: identifier (value of reg property) of a port this endpoint belongs to ··· 28 26 const struct device_node *local_node; 29 27 }; 30 28 29 + /** 30 + * for_each_endpoint_of_node - iterate over every endpoint in a device node 31 + * @parent: parent device node containing ports and endpoints 32 + * @child: loop variable pointing to the current endpoint node 33 + * 34 + * When breaking out of the loop, of_node_put(child) has to be called manually. 35 + */ 36 + #define for_each_endpoint_of_node(parent, child) \ 37 + for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \ 38 + child = of_graph_get_next_endpoint(parent, child)) 39 + 31 40 #ifdef CONFIG_OF 32 41 int of_graph_parse_endpoint(const struct device_node *node, 33 42 struct of_endpoint *endpoint); 43 + struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); 34 44 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, 35 45 struct device_node *previous); 36 46 struct device_node *of_graph_get_remote_port_parent( ··· 54 40 struct of_endpoint *endpoint) 55 41 { 56 42 return -ENOSYS; 43 + } 44 + 45 + static inline struct device_node *of_graph_get_port_by_id( 46 + struct device_node *node, u32 id) 47 + { 48 + return NULL; 57 49 } 58 50 59 51 static inline struct device_node *of_graph_get_next_endpoint(