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