diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-18 08:30:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-18 08:30:10 -0400 |
commit | 7505256626b0b3d11ea5a3ec1a89046d07c3c366 (patch) | |
tree | b1978634cdfa7d71b6eb9e5db6279ff99a15659f /drivers | |
parent | 510965dd4a0a59504ba38455f77339ea8b4c6a70 (diff) | |
parent | a2166ca5f3204794e8b59f01c93a0f1564e3e138 (diff) |
Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux
Pull devicetree changes from Grant Likely:
"Here are the devicetree changes queued up for v4.1. Nothing really
exciting here. Rob has another few commits for big-endian attached
UARTs, but those will be sent in a separate merge request since they
haven't been as thoroughly tested as this batch.
Here are the highlights:
- lots of unittest cleanup from Frank Rowand
- bugfixes and updates to the of_graph code
- tighten up of_get_mac_address() code
- documentation updates"
* tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux:
of/unittest: Fix of_platform_depopulate test case
of/unittest: early return from test skips tests
of/unittest: breadcrumbs to reduce pain of future maintainers
of/unittest: reduce checkpatch noise - line after declarations
of/unittest: typo in error string
of/unittest: add const where needed
of_net: factor out repetitive code from of_get_mac_address()
drivers/of: Add empty ranges quirk for PA-Semi
of: Allow selection of OF_DYNAMIC and OF_OVERLAY if OF_UNITTEST
of: Empty node & property flag accessors when !OF
of: Explicitly include linux/types.h in of_graph.h
dt-bindings: brcm: rationalize Broadcom documentation naming
of/unittest: replace 'selftest' with 'unittest'
Documentation: rename of_selftest.txt to of_unittest.txt
Documentation: update the of_selftest.txt
dt: OF_UNITTEST make dependency broken
MAINTAINERS: Pantelis Antoniou device tree overlay maintainer
of: Add of_graph_get_port_by_id function
of: Add for_each_endpoint_of_node helper macro
of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/coresight/of_coresight.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/imx/imx-drm-core.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_kms.c | 15 | ||||
-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/Kconfig | 11 | ||||
-rw-r--r-- | drivers/of/Makefile | 5 | ||||
-rw-r--r-- | drivers/of/base.c | 41 | ||||
-rw-r--r-- | drivers/of/of_net.c | 29 | ||||
-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 | 744 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 7 |
14 files changed, 515 insertions, 482 deletions
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/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index a002f53aab0e..84cf99f8d957 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 |
@@ -457,7 +448,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, | |||
457 | return -EINVAL; | 448 | return -EINVAL; |
458 | 449 | ||
459 | do { | 450 | do { |
460 | ep = imx_drm_of_get_next_endpoint(node, ep); | 451 | ep = of_graph_get_next_endpoint(node, ep); |
461 | if (!ep) | 452 | if (!ep) |
462 | break; | 453 | break; |
463 | 454 | ||
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index cc9136e8ee9c..68dab2601bf5 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c | |||
@@ -206,7 +206,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
206 | enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE; | 206 | enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE; |
207 | struct device_node *connector = NULL; | 207 | struct device_node *connector = NULL; |
208 | struct device_node *encoder = NULL; | 208 | struct device_node *encoder = NULL; |
209 | struct device_node *prev = NULL; | 209 | struct device_node *ep_node = NULL; |
210 | struct device_node *entity_ep_node; | 210 | struct device_node *entity_ep_node; |
211 | struct device_node *entity; | 211 | struct device_node *entity; |
212 | int ret; | 212 | int ret; |
@@ -225,11 +225,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
225 | entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0); | 225 | entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0); |
226 | 226 | ||
227 | while (1) { | 227 | while (1) { |
228 | struct device_node *ep_node; | 228 | ep_node = of_graph_get_next_endpoint(entity, ep_node); |
229 | |||
230 | ep_node = of_graph_get_next_endpoint(entity, prev); | ||
231 | of_node_put(prev); | ||
232 | prev = ep_node; | ||
233 | 229 | ||
234 | if (!ep_node) | 230 | if (!ep_node) |
235 | break; | 231 | break; |
@@ -300,7 +296,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
300 | static int rcar_du_encoders_init(struct rcar_du_device *rcdu) | 296 | static int rcar_du_encoders_init(struct rcar_du_device *rcdu) |
301 | { | 297 | { |
302 | struct device_node *np = rcdu->dev->of_node; | 298 | struct device_node *np = rcdu->dev->of_node; |
303 | struct device_node *prev = NULL; | 299 | struct device_node *ep_node = NULL; |
304 | unsigned int num_encoders = 0; | 300 | unsigned int num_encoders = 0; |
305 | 301 | ||
306 | /* | 302 | /* |
@@ -308,15 +304,12 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) | |||
308 | * pipeline. | 304 | * pipeline. |
309 | */ | 305 | */ |
310 | while (1) { | 306 | while (1) { |
311 | struct device_node *ep_node; | ||
312 | enum rcar_du_output output; | 307 | enum rcar_du_output output; |
313 | struct of_endpoint ep; | 308 | struct of_endpoint ep; |
314 | unsigned int i; | 309 | unsigned int i; |
315 | int ret; | 310 | int ret; |
316 | 311 | ||
317 | ep_node = of_graph_get_next_endpoint(np, prev); | 312 | ep_node = of_graph_get_next_endpoint(np, ep_node); |
318 | of_node_put(prev); | ||
319 | prev = ep_node; | ||
320 | 313 | ||
321 | if (ep_node == NULL) | 314 | if (ep_node == NULL) |
322 | break; | 315 | break; |
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 66634b469c98..9039d989c01c 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/Kconfig b/drivers/of/Kconfig index 7bcaeec876c0..1470b5227834 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -34,7 +34,11 @@ config OF_PROMTREE | |||
34 | # Hardly any platforms need this. It is safe to select, but only do so if you | 34 | # Hardly any platforms need this. It is safe to select, but only do so if you |
35 | # need it. | 35 | # need it. |
36 | config OF_DYNAMIC | 36 | config OF_DYNAMIC |
37 | bool | 37 | bool "Support for dynamic device trees" if OF_UNITTEST |
38 | help | ||
39 | On some platforms, the device tree can be manipulated at runtime. | ||
40 | While this option is selected automatically on such platforms, you | ||
41 | can enable it manually to improve device tree unit test coverage. | ||
38 | 42 | ||
39 | config OF_ADDRESS | 43 | config OF_ADDRESS |
40 | def_bool y | 44 | def_bool y |
@@ -87,5 +91,10 @@ config OF_OVERLAY | |||
87 | bool "Device Tree overlays" | 91 | bool "Device Tree overlays" |
88 | select OF_DYNAMIC | 92 | select OF_DYNAMIC |
89 | select OF_RESOLVE | 93 | select OF_RESOLVE |
94 | help | ||
95 | Overlays are a method to dynamically modify part of the kernel's | ||
96 | device tree with dynamically loaded data. | ||
97 | While this option is selected automatically when needed, you can | ||
98 | enable it manually to improve device tree unit test coverage. | ||
90 | 99 | ||
91 | endmenu # OF | 100 | endmenu # OF |
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 4cc06c702c41..a1aa0c7dee50 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -2109,13 +2109,44 @@ int of_graph_parse_endpoint(const struct device_node *node, | |||
2109 | EXPORT_SYMBOL(of_graph_parse_endpoint); | 2109 | EXPORT_SYMBOL(of_graph_parse_endpoint); |
2110 | 2110 | ||
2111 | /** | 2111 | /** |
2112 | * of_graph_get_port_by_id() - get the port matching a given id | ||
2113 | * @parent: pointer to the parent device node | ||
2114 | * @id: id of the port | ||
2115 | * | ||
2116 | * Return: A 'port' node pointer with refcount incremented. The caller | ||
2117 | * has to use of_node_put() on it when done. | ||
2118 | */ | ||
2119 | struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) | ||
2120 | { | ||
2121 | struct device_node *node, *port; | ||
2122 | |||
2123 | node = of_get_child_by_name(parent, "ports"); | ||
2124 | if (node) | ||
2125 | parent = node; | ||
2126 | |||
2127 | for_each_child_of_node(parent, port) { | ||
2128 | u32 port_id = 0; | ||
2129 | |||
2130 | if (of_node_cmp(port->name, "port") != 0) | ||
2131 | continue; | ||
2132 | of_property_read_u32(port, "reg", &port_id); | ||
2133 | if (id == port_id) | ||
2134 | break; | ||
2135 | } | ||
2136 | |||
2137 | of_node_put(node); | ||
2138 | |||
2139 | return port; | ||
2140 | } | ||
2141 | EXPORT_SYMBOL(of_graph_get_port_by_id); | ||
2142 | |||
2143 | /** | ||
2112 | * of_graph_get_next_endpoint() - get next endpoint node | 2144 | * of_graph_get_next_endpoint() - get next endpoint node |
2113 | * @parent: pointer to the parent device node | 2145 | * @parent: pointer to the parent device node |
2114 | * @prev: previous endpoint node, or NULL to get first | 2146 | * @prev: previous endpoint node, or NULL to get first |
2115 | * | 2147 | * |
2116 | * Return: An 'endpoint' node pointer with refcount incremented. Refcount | 2148 | * Return: An 'endpoint' node pointer with refcount incremented. Refcount |
2117 | * of the passed @prev node is not decremented, the caller have to use | 2149 | * of the passed @prev node is decremented. |
2118 | * of_node_put() on it when done. | ||
2119 | */ | 2150 | */ |
2120 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | 2151 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, |
2121 | struct device_node *prev) | 2152 | struct device_node *prev) |
@@ -2151,12 +2182,6 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | |||
2151 | if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", | 2182 | if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", |
2152 | __func__, prev->full_name)) | 2183 | __func__, prev->full_name)) |
2153 | return NULL; | 2184 | return NULL; |
2154 | |||
2155 | /* | ||
2156 | * Avoid dropping prev node refcount to 0 when getting the next | ||
2157 | * child below. | ||
2158 | */ | ||
2159 | of_node_get(prev); | ||
2160 | } | 2185 | } |
2161 | 2186 | ||
2162 | while (1) { | 2187 | while (1) { |
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 73e14184aafe..d820f3edd431 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c | |||
@@ -38,6 +38,15 @@ int of_get_phy_mode(struct device_node *np) | |||
38 | } | 38 | } |
39 | EXPORT_SYMBOL_GPL(of_get_phy_mode); | 39 | EXPORT_SYMBOL_GPL(of_get_phy_mode); |
40 | 40 | ||
41 | static const void *of_get_mac_addr(struct device_node *np, const char *name) | ||
42 | { | ||
43 | struct property *pp = of_find_property(np, name, NULL); | ||
44 | |||
45 | if (pp && pp->length == ETH_ALEN && is_valid_ether_addr(pp->value)) | ||
46 | return pp->value; | ||
47 | return NULL; | ||
48 | } | ||
49 | |||
41 | /** | 50 | /** |
42 | * Search the device tree for the best MAC address to use. 'mac-address' is | 51 | * Search the device tree for the best MAC address to use. 'mac-address' is |
43 | * checked first, because that is supposed to contain to "most recent" MAC | 52 | * checked first, because that is supposed to contain to "most recent" MAC |
@@ -58,20 +67,16 @@ EXPORT_SYMBOL_GPL(of_get_phy_mode); | |||
58 | */ | 67 | */ |
59 | const void *of_get_mac_address(struct device_node *np) | 68 | const void *of_get_mac_address(struct device_node *np) |
60 | { | 69 | { |
61 | struct property *pp; | 70 | const void *addr; |
62 | 71 | ||
63 | pp = of_find_property(np, "mac-address", NULL); | 72 | addr = of_get_mac_addr(np, "mac-address"); |
64 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | 73 | if (addr) |
65 | return pp->value; | 74 | return addr; |
66 | 75 | ||
67 | pp = of_find_property(np, "local-mac-address", NULL); | 76 | addr = of_get_mac_addr(np, "local-mac-address"); |
68 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | 77 | if (addr) |
69 | return pp->value; | 78 | return addr; |
70 | 79 | ||
71 | pp = of_find_property(np, "address", NULL); | 80 | return of_get_mac_addr(np, "address"); |
72 | if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) | ||
73 | return pp->value; | ||
74 | |||
75 | return NULL; | ||
76 | } | 81 | } |
77 | EXPORT_SYMBOL(of_get_mac_address); | 82 | EXPORT_SYMBOL(of_get_mac_address); |
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..e844907c9efa 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,11 +225,12 @@ 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, |
232 | "sibling lists size (%i)\n", allnode_count, child_count); | 232 | "allnodes list size (%i) doesn't match sibling lists size (%i)\n", |
233 | allnode_count, child_count); | ||
233 | pr_debug("allnodes list size (%i); sibling lists size (%i)\n", allnode_count, child_count); | 234 | pr_debug("allnodes list size (%i); sibling lists size (%i)\n", allnode_count, child_count); |
234 | } | 235 | } |
235 | 236 | ||
@@ -239,7 +240,7 @@ struct node_hash { | |||
239 | }; | 240 | }; |
240 | 241 | ||
241 | static DEFINE_HASHTABLE(phandle_ht, 8); | 242 | static DEFINE_HASHTABLE(phandle_ht, 8); |
242 | static void __init of_selftest_check_phandles(void) | 243 | static void __init of_unittest_check_phandles(void) |
243 | { | 244 | { |
244 | struct device_node *np; | 245 | struct device_node *np; |
245 | struct node_hash *nh; | 246 | struct node_hash *nh; |
@@ -267,7 +268,7 @@ static void __init of_selftest_check_phandles(void) | |||
267 | hash_add(phandle_ht, &nh->node, np->phandle); | 268 | hash_add(phandle_ht, &nh->node, np->phandle); |
268 | phandle_count++; | 269 | phandle_count++; |
269 | } | 270 | } |
270 | selftest(dup_count == 0, "Found %i duplicates in %i phandles\n", | 271 | unittest(dup_count == 0, "Found %i duplicates in %i phandles\n", |
271 | dup_count, phandle_count); | 272 | dup_count, phandle_count); |
272 | 273 | ||
273 | /* Clean up */ | 274 | /* Clean up */ |
@@ -277,7 +278,7 @@ static void __init of_selftest_check_phandles(void) | |||
277 | } | 278 | } |
278 | } | 279 | } |
279 | 280 | ||
280 | static void __init of_selftest_parse_phandle_with_args(void) | 281 | static void __init of_unittest_parse_phandle_with_args(void) |
281 | { | 282 | { |
282 | struct device_node *np; | 283 | struct device_node *np; |
283 | struct of_phandle_args args; | 284 | struct of_phandle_args args; |
@@ -290,10 +291,11 @@ static void __init of_selftest_parse_phandle_with_args(void) | |||
290 | } | 291 | } |
291 | 292 | ||
292 | rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); | 293 | 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); | 294 | unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); |
294 | 295 | ||
295 | for (i = 0; i < 8; i++) { | 296 | for (i = 0; i < 8; i++) { |
296 | bool passed = true; | 297 | bool passed = true; |
298 | |||
297 | rc = of_parse_phandle_with_args(np, "phandle-list", | 299 | rc = of_parse_phandle_with_args(np, "phandle-list", |
298 | "#phandle-cells", i, &args); | 300 | "#phandle-cells", i, &args); |
299 | 301 | ||
@@ -342,44 +344,44 @@ static void __init of_selftest_parse_phandle_with_args(void) | |||
342 | passed = false; | 344 | passed = false; |
343 | } | 345 | } |
344 | 346 | ||
345 | selftest(passed, "index %i - data error on node %s rc=%i\n", | 347 | unittest(passed, "index %i - data error on node %s rc=%i\n", |
346 | i, args.np->full_name, rc); | 348 | i, args.np->full_name, rc); |
347 | } | 349 | } |
348 | 350 | ||
349 | /* Check for missing list property */ | 351 | /* Check for missing list property */ |
350 | rc = of_parse_phandle_with_args(np, "phandle-list-missing", | 352 | rc = of_parse_phandle_with_args(np, "phandle-list-missing", |
351 | "#phandle-cells", 0, &args); | 353 | "#phandle-cells", 0, &args); |
352 | selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); | 354 | unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); |
353 | rc = of_count_phandle_with_args(np, "phandle-list-missing", | 355 | rc = of_count_phandle_with_args(np, "phandle-list-missing", |
354 | "#phandle-cells"); | 356 | "#phandle-cells"); |
355 | selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); | 357 | unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); |
356 | 358 | ||
357 | /* Check for missing cells property */ | 359 | /* Check for missing cells property */ |
358 | rc = of_parse_phandle_with_args(np, "phandle-list", | 360 | rc = of_parse_phandle_with_args(np, "phandle-list", |
359 | "#phandle-cells-missing", 0, &args); | 361 | "#phandle-cells-missing", 0, &args); |
360 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 362 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
361 | rc = of_count_phandle_with_args(np, "phandle-list", | 363 | rc = of_count_phandle_with_args(np, "phandle-list", |
362 | "#phandle-cells-missing"); | 364 | "#phandle-cells-missing"); |
363 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 365 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
364 | 366 | ||
365 | /* Check for bad phandle in list */ | 367 | /* Check for bad phandle in list */ |
366 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", | 368 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", |
367 | "#phandle-cells", 0, &args); | 369 | "#phandle-cells", 0, &args); |
368 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 370 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
369 | rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle", | 371 | rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle", |
370 | "#phandle-cells"); | 372 | "#phandle-cells"); |
371 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 373 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
372 | 374 | ||
373 | /* Check for incorrectly formed argument list */ | 375 | /* Check for incorrectly formed argument list */ |
374 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", | 376 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", |
375 | "#phandle-cells", 1, &args); | 377 | "#phandle-cells", 1, &args); |
376 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 378 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
377 | rc = of_count_phandle_with_args(np, "phandle-list-bad-args", | 379 | rc = of_count_phandle_with_args(np, "phandle-list-bad-args", |
378 | "#phandle-cells"); | 380 | "#phandle-cells"); |
379 | selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | 381 | unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); |
380 | } | 382 | } |
381 | 383 | ||
382 | static void __init of_selftest_property_string(void) | 384 | static void __init of_unittest_property_string(void) |
383 | { | 385 | { |
384 | const char *strings[4]; | 386 | const char *strings[4]; |
385 | struct device_node *np; | 387 | struct device_node *np; |
@@ -392,79 +394,79 @@ static void __init of_selftest_property_string(void) | |||
392 | } | 394 | } |
393 | 395 | ||
394 | rc = of_property_match_string(np, "phandle-list-names", "first"); | 396 | rc = of_property_match_string(np, "phandle-list-names", "first"); |
395 | selftest(rc == 0, "first expected:0 got:%i\n", rc); | 397 | unittest(rc == 0, "first expected:0 got:%i\n", rc); |
396 | rc = of_property_match_string(np, "phandle-list-names", "second"); | 398 | rc = of_property_match_string(np, "phandle-list-names", "second"); |
397 | selftest(rc == 1, "second expected:1 got:%i\n", rc); | 399 | unittest(rc == 1, "second expected:1 got:%i\n", rc); |
398 | rc = of_property_match_string(np, "phandle-list-names", "third"); | 400 | rc = of_property_match_string(np, "phandle-list-names", "third"); |
399 | selftest(rc == 2, "third expected:2 got:%i\n", rc); | 401 | unittest(rc == 2, "third expected:2 got:%i\n", rc); |
400 | rc = of_property_match_string(np, "phandle-list-names", "fourth"); | 402 | rc = of_property_match_string(np, "phandle-list-names", "fourth"); |
401 | selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); | 403 | unittest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); |
402 | rc = of_property_match_string(np, "missing-property", "blah"); | 404 | rc = of_property_match_string(np, "missing-property", "blah"); |
403 | selftest(rc == -EINVAL, "missing property; rc=%i\n", rc); | 405 | unittest(rc == -EINVAL, "missing property; rc=%i\n", rc); |
404 | rc = of_property_match_string(np, "empty-property", "blah"); | 406 | rc = of_property_match_string(np, "empty-property", "blah"); |
405 | selftest(rc == -ENODATA, "empty property; rc=%i\n", rc); | 407 | unittest(rc == -ENODATA, "empty property; rc=%i\n", rc); |
406 | rc = of_property_match_string(np, "unterminated-string", "blah"); | 408 | rc = of_property_match_string(np, "unterminated-string", "blah"); |
407 | selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); | 409 | unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); |
408 | 410 | ||
409 | /* of_property_count_strings() tests */ | 411 | /* of_property_count_strings() tests */ |
410 | rc = of_property_count_strings(np, "string-property"); | 412 | rc = of_property_count_strings(np, "string-property"); |
411 | selftest(rc == 1, "Incorrect string count; rc=%i\n", rc); | 413 | unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); |
412 | rc = of_property_count_strings(np, "phandle-list-names"); | 414 | rc = of_property_count_strings(np, "phandle-list-names"); |
413 | selftest(rc == 3, "Incorrect string count; rc=%i\n", rc); | 415 | unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); |
414 | rc = of_property_count_strings(np, "unterminated-string"); | 416 | rc = of_property_count_strings(np, "unterminated-string"); |
415 | selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); | 417 | unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); |
416 | rc = of_property_count_strings(np, "unterminated-string-list"); | 418 | rc = of_property_count_strings(np, "unterminated-string-list"); |
417 | selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); | 419 | unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); |
418 | 420 | ||
419 | /* of_property_read_string_index() tests */ | 421 | /* of_property_read_string_index() tests */ |
420 | rc = of_property_read_string_index(np, "string-property", 0, strings); | 422 | 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); | 423 | unittest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc); |
422 | strings[0] = NULL; | 424 | strings[0] = NULL; |
423 | rc = of_property_read_string_index(np, "string-property", 1, strings); | 425 | 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); | 426 | 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); | 427 | 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); | 428 | 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); | 429 | 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); | 430 | 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); | 431 | 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); | 432 | unittest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc); |
431 | strings[0] = NULL; | 433 | strings[0] = NULL; |
432 | rc = of_property_read_string_index(np, "phandle-list-names", 3, strings); | 434 | 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); | 435 | unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); |
434 | strings[0] = NULL; | 436 | strings[0] = NULL; |
435 | rc = of_property_read_string_index(np, "unterminated-string", 0, strings); | 437 | 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); | 438 | 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); | 439 | 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); | 440 | unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc); |
439 | strings[0] = NULL; | 441 | strings[0] = NULL; |
440 | rc = of_property_read_string_index(np, "unterminated-string-list", 2, strings); /* should fail */ | 442 | 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); | 443 | unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc); |
442 | strings[1] = NULL; | 444 | strings[1] = NULL; |
443 | 445 | ||
444 | /* of_property_read_string_array() tests */ | 446 | /* of_property_read_string_array() tests */ |
445 | rc = of_property_read_string_array(np, "string-property", strings, 4); | 447 | rc = of_property_read_string_array(np, "string-property", strings, 4); |
446 | selftest(rc == 1, "Incorrect string count; rc=%i\n", rc); | 448 | unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); |
447 | rc = of_property_read_string_array(np, "phandle-list-names", strings, 4); | 449 | rc = of_property_read_string_array(np, "phandle-list-names", strings, 4); |
448 | selftest(rc == 3, "Incorrect string count; rc=%i\n", rc); | 450 | unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); |
449 | rc = of_property_read_string_array(np, "unterminated-string", strings, 4); | 451 | rc = of_property_read_string_array(np, "unterminated-string", strings, 4); |
450 | selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); | 452 | unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); |
451 | /* -- An incorrectly formed string should cause a failure */ | 453 | /* -- An incorrectly formed string should cause a failure */ |
452 | rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4); | 454 | rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4); |
453 | selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); | 455 | unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); |
454 | /* -- parsing the correctly formed strings should still work: */ | 456 | /* -- parsing the correctly formed strings should still work: */ |
455 | strings[2] = NULL; | 457 | strings[2] = NULL; |
456 | rc = of_property_read_string_array(np, "unterminated-string-list", strings, 2); | 458 | 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); | 459 | unittest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc); |
458 | strings[1] = NULL; | 460 | strings[1] = NULL; |
459 | rc = of_property_read_string_array(np, "phandle-list-names", strings, 1); | 461 | 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]); | 462 | unittest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]); |
461 | } | 463 | } |
462 | 464 | ||
463 | #define propcmp(p1, p2) (((p1)->length == (p2)->length) && \ | 465 | #define propcmp(p1, p2) (((p1)->length == (p2)->length) && \ |
464 | (p1)->value && (p2)->value && \ | 466 | (p1)->value && (p2)->value && \ |
465 | !memcmp((p1)->value, (p2)->value, (p1)->length) && \ | 467 | !memcmp((p1)->value, (p2)->value, (p1)->length) && \ |
466 | !strcmp((p1)->name, (p2)->name)) | 468 | !strcmp((p1)->name, (p2)->name)) |
467 | static void __init of_selftest_property_copy(void) | 469 | static void __init of_unittest_property_copy(void) |
468 | { | 470 | { |
469 | #ifdef CONFIG_OF_DYNAMIC | 471 | #ifdef CONFIG_OF_DYNAMIC |
470 | struct property p1 = { .name = "p1", .length = 0, .value = "" }; | 472 | struct property p1 = { .name = "p1", .length = 0, .value = "" }; |
@@ -472,20 +474,20 @@ static void __init of_selftest_property_copy(void) | |||
472 | struct property *new; | 474 | struct property *new; |
473 | 475 | ||
474 | new = __of_prop_dup(&p1, GFP_KERNEL); | 476 | new = __of_prop_dup(&p1, GFP_KERNEL); |
475 | selftest(new && propcmp(&p1, new), "empty property didn't copy correctly\n"); | 477 | unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\n"); |
476 | kfree(new->value); | 478 | kfree(new->value); |
477 | kfree(new->name); | 479 | kfree(new->name); |
478 | kfree(new); | 480 | kfree(new); |
479 | 481 | ||
480 | new = __of_prop_dup(&p2, GFP_KERNEL); | 482 | new = __of_prop_dup(&p2, GFP_KERNEL); |
481 | selftest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); | 483 | unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); |
482 | kfree(new->value); | 484 | kfree(new->value); |
483 | kfree(new->name); | 485 | kfree(new->name); |
484 | kfree(new); | 486 | kfree(new); |
485 | #endif | 487 | #endif |
486 | } | 488 | } |
487 | 489 | ||
488 | static void __init of_selftest_changeset(void) | 490 | static void __init of_unittest_changeset(void) |
489 | { | 491 | { |
490 | #ifdef CONFIG_OF_DYNAMIC | 492 | #ifdef CONFIG_OF_DYNAMIC |
491 | struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" }; | 493 | struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" }; |
@@ -495,51 +497,51 @@ static void __init of_selftest_changeset(void) | |||
495 | struct of_changeset chgset; | 497 | struct of_changeset chgset; |
496 | 498 | ||
497 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); | 499 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); |
498 | selftest(n1, "testcase setup failure\n"); | 500 | unittest(n1, "testcase setup failure\n"); |
499 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); | 501 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); |
500 | selftest(n2, "testcase setup failure\n"); | 502 | unittest(n2, "testcase setup failure\n"); |
501 | n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); | 503 | n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); |
502 | selftest(n21, "testcase setup failure %p\n", n21); | 504 | unittest(n21, "testcase setup failure %p\n", n21); |
503 | nremove = of_find_node_by_path("/testcase-data/changeset/node-remove"); | 505 | nremove = of_find_node_by_path("/testcase-data/changeset/node-remove"); |
504 | selftest(nremove, "testcase setup failure\n"); | 506 | unittest(nremove, "testcase setup failure\n"); |
505 | ppadd = __of_prop_dup(&padd, GFP_KERNEL); | 507 | ppadd = __of_prop_dup(&padd, GFP_KERNEL); |
506 | selftest(ppadd, "testcase setup failure\n"); | 508 | unittest(ppadd, "testcase setup failure\n"); |
507 | ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); | 509 | ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); |
508 | selftest(ppupdate, "testcase setup failure\n"); | 510 | unittest(ppupdate, "testcase setup failure\n"); |
509 | parent = nremove->parent; | 511 | parent = nremove->parent; |
510 | n1->parent = parent; | 512 | n1->parent = parent; |
511 | n2->parent = parent; | 513 | n2->parent = parent; |
512 | n21->parent = n2; | 514 | n21->parent = n2; |
513 | n2->child = n21; | 515 | n2->child = n21; |
514 | ppremove = of_find_property(parent, "prop-remove", NULL); | 516 | ppremove = of_find_property(parent, "prop-remove", NULL); |
515 | selftest(ppremove, "failed to find removal prop"); | 517 | unittest(ppremove, "failed to find removal prop"); |
516 | 518 | ||
517 | of_changeset_init(&chgset); | 519 | of_changeset_init(&chgset); |
518 | selftest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); | 520 | unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); |
519 | selftest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); | 521 | unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); |
520 | selftest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); | 522 | unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); |
521 | selftest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); | 523 | unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); |
522 | selftest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n"); | 524 | 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"); | 525 | 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"); | 526 | unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); |
525 | mutex_lock(&of_mutex); | 527 | mutex_lock(&of_mutex); |
526 | selftest(!of_changeset_apply(&chgset), "apply failed\n"); | 528 | unittest(!of_changeset_apply(&chgset), "apply failed\n"); |
527 | mutex_unlock(&of_mutex); | 529 | mutex_unlock(&of_mutex); |
528 | 530 | ||
529 | /* Make sure node names are constructed correctly */ | 531 | /* Make sure node names are constructed correctly */ |
530 | selftest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), | 532 | unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), |
531 | "'%s' not added\n", n21->full_name); | 533 | "'%s' not added\n", n21->full_name); |
532 | of_node_put(np); | 534 | of_node_put(np); |
533 | 535 | ||
534 | mutex_lock(&of_mutex); | 536 | mutex_lock(&of_mutex); |
535 | selftest(!of_changeset_revert(&chgset), "revert failed\n"); | 537 | unittest(!of_changeset_revert(&chgset), "revert failed\n"); |
536 | mutex_unlock(&of_mutex); | 538 | mutex_unlock(&of_mutex); |
537 | 539 | ||
538 | of_changeset_destroy(&chgset); | 540 | of_changeset_destroy(&chgset); |
539 | #endif | 541 | #endif |
540 | } | 542 | } |
541 | 543 | ||
542 | static void __init of_selftest_parse_interrupts(void) | 544 | static void __init of_unittest_parse_interrupts(void) |
543 | { | 545 | { |
544 | struct device_node *np; | 546 | struct device_node *np; |
545 | struct of_phandle_args args; | 547 | struct of_phandle_args args; |
@@ -553,6 +555,7 @@ static void __init of_selftest_parse_interrupts(void) | |||
553 | 555 | ||
554 | for (i = 0; i < 4; i++) { | 556 | for (i = 0; i < 4; i++) { |
555 | bool passed = true; | 557 | bool passed = true; |
558 | |||
556 | args.args_count = 0; | 559 | args.args_count = 0; |
557 | rc = of_irq_parse_one(np, i, &args); | 560 | rc = of_irq_parse_one(np, i, &args); |
558 | 561 | ||
@@ -560,7 +563,7 @@ static void __init of_selftest_parse_interrupts(void) | |||
560 | passed &= (args.args_count == 1); | 563 | passed &= (args.args_count == 1); |
561 | passed &= (args.args[0] == (i + 1)); | 564 | passed &= (args.args[0] == (i + 1)); |
562 | 565 | ||
563 | selftest(passed, "index %i - data error on node %s rc=%i\n", | 566 | unittest(passed, "index %i - data error on node %s rc=%i\n", |
564 | i, args.np->full_name, rc); | 567 | i, args.np->full_name, rc); |
565 | } | 568 | } |
566 | of_node_put(np); | 569 | of_node_put(np); |
@@ -573,6 +576,7 @@ static void __init of_selftest_parse_interrupts(void) | |||
573 | 576 | ||
574 | for (i = 0; i < 4; i++) { | 577 | for (i = 0; i < 4; i++) { |
575 | bool passed = true; | 578 | bool passed = true; |
579 | |||
576 | args.args_count = 0; | 580 | args.args_count = 0; |
577 | rc = of_irq_parse_one(np, i, &args); | 581 | rc = of_irq_parse_one(np, i, &args); |
578 | 582 | ||
@@ -605,13 +609,13 @@ static void __init of_selftest_parse_interrupts(void) | |||
605 | default: | 609 | default: |
606 | passed = false; | 610 | passed = false; |
607 | } | 611 | } |
608 | selftest(passed, "index %i - data error on node %s rc=%i\n", | 612 | unittest(passed, "index %i - data error on node %s rc=%i\n", |
609 | i, args.np->full_name, rc); | 613 | i, args.np->full_name, rc); |
610 | } | 614 | } |
611 | of_node_put(np); | 615 | of_node_put(np); |
612 | } | 616 | } |
613 | 617 | ||
614 | static void __init of_selftest_parse_interrupts_extended(void) | 618 | static void __init of_unittest_parse_interrupts_extended(void) |
615 | { | 619 | { |
616 | struct device_node *np; | 620 | struct device_node *np; |
617 | struct of_phandle_args args; | 621 | struct of_phandle_args args; |
@@ -625,6 +629,7 @@ static void __init of_selftest_parse_interrupts_extended(void) | |||
625 | 629 | ||
626 | for (i = 0; i < 7; i++) { | 630 | for (i = 0; i < 7; i++) { |
627 | bool passed = true; | 631 | bool passed = true; |
632 | |||
628 | rc = of_irq_parse_one(np, i, &args); | 633 | rc = of_irq_parse_one(np, i, &args); |
629 | 634 | ||
630 | /* Test the values from tests-phandle.dtsi */ | 635 | /* Test the values from tests-phandle.dtsi */ |
@@ -674,13 +679,13 @@ static void __init of_selftest_parse_interrupts_extended(void) | |||
674 | passed = false; | 679 | passed = false; |
675 | } | 680 | } |
676 | 681 | ||
677 | selftest(passed, "index %i - data error on node %s rc=%i\n", | 682 | unittest(passed, "index %i - data error on node %s rc=%i\n", |
678 | i, args.np->full_name, rc); | 683 | i, args.np->full_name, rc); |
679 | } | 684 | } |
680 | of_node_put(np); | 685 | of_node_put(np); |
681 | } | 686 | } |
682 | 687 | ||
683 | static struct of_device_id match_node_table[] = { | 688 | static const struct of_device_id match_node_table[] = { |
684 | { .data = "A", .name = "name0", }, /* Name alone is lowest priority */ | 689 | { .data = "A", .name = "name0", }, /* Name alone is lowest priority */ |
685 | { .data = "B", .type = "type1", }, /* followed by type alone */ | 690 | { .data = "B", .type = "type1", }, /* followed by type alone */ |
686 | 691 | ||
@@ -715,7 +720,7 @@ static struct { | |||
715 | { .path = "/testcase-data/match-node/name9", .data = "K", }, | 720 | { .path = "/testcase-data/match-node/name9", .data = "K", }, |
716 | }; | 721 | }; |
717 | 722 | ||
718 | static void __init of_selftest_match_node(void) | 723 | static void __init of_unittest_match_node(void) |
719 | { | 724 | { |
720 | struct device_node *np; | 725 | struct device_node *np; |
721 | const struct of_device_id *match; | 726 | const struct of_device_id *match; |
@@ -724,37 +729,37 @@ static void __init of_selftest_match_node(void) | |||
724 | for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) { | 729 | for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) { |
725 | np = of_find_node_by_path(match_node_tests[i].path); | 730 | np = of_find_node_by_path(match_node_tests[i].path); |
726 | if (!np) { | 731 | if (!np) { |
727 | selftest(0, "missing testcase node %s\n", | 732 | unittest(0, "missing testcase node %s\n", |
728 | match_node_tests[i].path); | 733 | match_node_tests[i].path); |
729 | continue; | 734 | continue; |
730 | } | 735 | } |
731 | 736 | ||
732 | match = of_match_node(match_node_table, np); | 737 | match = of_match_node(match_node_table, np); |
733 | if (!match) { | 738 | if (!match) { |
734 | selftest(0, "%s didn't match anything\n", | 739 | unittest(0, "%s didn't match anything\n", |
735 | match_node_tests[i].path); | 740 | match_node_tests[i].path); |
736 | continue; | 741 | continue; |
737 | } | 742 | } |
738 | 743 | ||
739 | if (strcmp(match->data, match_node_tests[i].data) != 0) { | 744 | if (strcmp(match->data, match_node_tests[i].data) != 0) { |
740 | selftest(0, "%s got wrong match. expected %s, got %s\n", | 745 | unittest(0, "%s got wrong match. expected %s, got %s\n", |
741 | match_node_tests[i].path, match_node_tests[i].data, | 746 | match_node_tests[i].path, match_node_tests[i].data, |
742 | (const char *)match->data); | 747 | (const char *)match->data); |
743 | continue; | 748 | continue; |
744 | } | 749 | } |
745 | selftest(1, "passed"); | 750 | unittest(1, "passed"); |
746 | } | 751 | } |
747 | } | 752 | } |
748 | 753 | ||
749 | struct device test_bus = { | 754 | static const struct platform_device_info test_bus_info = { |
750 | .init_name = "unittest-bus", | 755 | .name = "unittest-bus", |
751 | }; | 756 | }; |
752 | static void __init of_selftest_platform_populate(void) | 757 | static void __init of_unittest_platform_populate(void) |
753 | { | 758 | { |
754 | int irq, rc; | 759 | int irq, rc; |
755 | struct device_node *np, *child, *grandchild; | 760 | struct device_node *np, *child, *grandchild; |
756 | struct platform_device *pdev; | 761 | struct platform_device *pdev, *test_bus; |
757 | struct of_device_id match[] = { | 762 | const struct of_device_id match[] = { |
758 | { .compatible = "test-device", }, | 763 | { .compatible = "test-device", }, |
759 | {} | 764 | {} |
760 | }; | 765 | }; |
@@ -765,43 +770,47 @@ static void __init of_selftest_platform_populate(void) | |||
765 | /* Test that a missing irq domain returns -EPROBE_DEFER */ | 770 | /* Test that a missing irq domain returns -EPROBE_DEFER */ |
766 | np = of_find_node_by_path("/testcase-data/testcase-device1"); | 771 | np = of_find_node_by_path("/testcase-data/testcase-device1"); |
767 | pdev = of_find_device_by_node(np); | 772 | pdev = of_find_device_by_node(np); |
768 | selftest(pdev, "device 1 creation failed\n"); | 773 | unittest(pdev, "device 1 creation failed\n"); |
769 | 774 | ||
770 | irq = platform_get_irq(pdev, 0); | 775 | irq = platform_get_irq(pdev, 0); |
771 | selftest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq); | 776 | unittest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq); |
772 | 777 | ||
773 | /* Test that a parsing failure does not return -EPROBE_DEFER */ | 778 | /* Test that a parsing failure does not return -EPROBE_DEFER */ |
774 | np = of_find_node_by_path("/testcase-data/testcase-device2"); | 779 | np = of_find_node_by_path("/testcase-data/testcase-device2"); |
775 | pdev = of_find_device_by_node(np); | 780 | pdev = of_find_device_by_node(np); |
776 | selftest(pdev, "device 2 creation failed\n"); | 781 | unittest(pdev, "device 2 creation failed\n"); |
777 | irq = platform_get_irq(pdev, 0); | 782 | irq = platform_get_irq(pdev, 0); |
778 | selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); | 783 | unittest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); |
779 | 784 | ||
780 | if (selftest(np = of_find_node_by_path("/testcase-data/platform-tests"), | 785 | np = of_find_node_by_path("/testcase-data/platform-tests"); |
781 | "No testcase data in device tree\n")); | 786 | unittest(np, "No testcase data in device tree\n"); |
787 | if (!np) | ||
782 | return; | 788 | return; |
783 | 789 | ||
784 | if (selftest(!(rc = device_register(&test_bus)), | 790 | test_bus = platform_device_register_full(&test_bus_info); |
785 | "testbus registration failed; rc=%i\n", rc)); | 791 | rc = PTR_ERR_OR_ZERO(test_bus); |
792 | unittest(!rc, "testbus registration failed; rc=%i\n", rc); | ||
793 | if (rc) | ||
786 | return; | 794 | return; |
795 | test_bus->dev.of_node = np; | ||
787 | 796 | ||
797 | of_platform_populate(np, match, NULL, &test_bus->dev); | ||
788 | for_each_child_of_node(np, child) { | 798 | for_each_child_of_node(np, child) { |
789 | of_platform_populate(child, match, NULL, &test_bus); | ||
790 | for_each_child_of_node(child, grandchild) | 799 | for_each_child_of_node(child, grandchild) |
791 | selftest(of_find_device_by_node(grandchild), | 800 | unittest(of_find_device_by_node(grandchild), |
792 | "Could not create device for node '%s'\n", | 801 | "Could not create device for node '%s'\n", |
793 | grandchild->name); | 802 | grandchild->name); |
794 | } | 803 | } |
795 | 804 | ||
796 | of_platform_depopulate(&test_bus); | 805 | of_platform_depopulate(&test_bus->dev); |
797 | for_each_child_of_node(np, child) { | 806 | for_each_child_of_node(np, child) { |
798 | for_each_child_of_node(child, grandchild) | 807 | for_each_child_of_node(child, grandchild) |
799 | selftest(!of_find_device_by_node(grandchild), | 808 | unittest(!of_find_device_by_node(grandchild), |
800 | "device didn't get destroyed '%s'\n", | 809 | "device didn't get destroyed '%s'\n", |
801 | grandchild->name); | 810 | grandchild->name); |
802 | } | 811 | } |
803 | 812 | ||
804 | device_unregister(&test_bus); | 813 | platform_device_unregister(test_bus); |
805 | of_node_put(np); | 814 | of_node_put(np); |
806 | } | 815 | } |
807 | 816 | ||
@@ -866,13 +875,17 @@ static int attach_node_and_children(struct device_node *np) | |||
866 | } | 875 | } |
867 | 876 | ||
868 | /** | 877 | /** |
869 | * selftest_data_add - Reads, copies data from | 878 | * unittest_data_add - Reads, copies data from |
870 | * linked tree and attaches it to the live tree | 879 | * linked tree and attaches it to the live tree |
871 | */ | 880 | */ |
872 | static int __init selftest_data_add(void) | 881 | static int __init unittest_data_add(void) |
873 | { | 882 | { |
874 | void *selftest_data; | 883 | void *unittest_data; |
875 | struct device_node *selftest_data_node, *np; | 884 | struct device_node *unittest_data_node, *np; |
885 | /* | ||
886 | * __dtb_testcases_begin[] and __dtb_testcases_end[] are magically | ||
887 | * created by cmd_dt_S_dtb in scripts/Makefile.lib | ||
888 | */ | ||
876 | extern uint8_t __dtb_testcases_begin[]; | 889 | extern uint8_t __dtb_testcases_begin[]; |
877 | extern uint8_t __dtb_testcases_end[]; | 890 | extern uint8_t __dtb_testcases_end[]; |
878 | const int size = __dtb_testcases_end - __dtb_testcases_begin; | 891 | const int size = __dtb_testcases_end - __dtb_testcases_begin; |
@@ -885,27 +898,27 @@ static int __init selftest_data_add(void) | |||
885 | } | 898 | } |
886 | 899 | ||
887 | /* creating copy */ | 900 | /* creating copy */ |
888 | selftest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL); | 901 | unittest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL); |
889 | 902 | ||
890 | if (!selftest_data) { | 903 | if (!unittest_data) { |
891 | pr_warn("%s: Failed to allocate memory for selftest_data; " | 904 | pr_warn("%s: Failed to allocate memory for unittest_data; " |
892 | "not running tests\n", __func__); | 905 | "not running tests\n", __func__); |
893 | return -ENOMEM; | 906 | return -ENOMEM; |
894 | } | 907 | } |
895 | of_fdt_unflatten_tree(selftest_data, &selftest_data_node); | 908 | of_fdt_unflatten_tree(unittest_data, &unittest_data_node); |
896 | if (!selftest_data_node) { | 909 | if (!unittest_data_node) { |
897 | pr_warn("%s: No tree to attach; not running tests\n", __func__); | 910 | pr_warn("%s: No tree to attach; not running tests\n", __func__); |
898 | return -ENODATA; | 911 | return -ENODATA; |
899 | } | 912 | } |
900 | of_node_set_flag(selftest_data_node, OF_DETACHED); | 913 | of_node_set_flag(unittest_data_node, OF_DETACHED); |
901 | rc = of_resolve_phandles(selftest_data_node); | 914 | rc = of_resolve_phandles(unittest_data_node); |
902 | if (rc) { | 915 | if (rc) { |
903 | pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); | 916 | pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); |
904 | return -EINVAL; | 917 | return -EINVAL; |
905 | } | 918 | } |
906 | 919 | ||
907 | if (!of_root) { | 920 | if (!of_root) { |
908 | of_root = selftest_data_node; | 921 | of_root = unittest_data_node; |
909 | for_each_of_allnodes(np) | 922 | for_each_of_allnodes(np) |
910 | __of_attach_node_sysfs(np); | 923 | __of_attach_node_sysfs(np); |
911 | of_aliases = of_find_node_by_path("/aliases"); | 924 | of_aliases = of_find_node_by_path("/aliases"); |
@@ -914,9 +927,10 @@ static int __init selftest_data_add(void) | |||
914 | } | 927 | } |
915 | 928 | ||
916 | /* attach the sub-tree to live tree */ | 929 | /* attach the sub-tree to live tree */ |
917 | np = selftest_data_node->child; | 930 | np = unittest_data_node->child; |
918 | while (np) { | 931 | while (np) { |
919 | struct device_node *next = np->sibling; | 932 | struct device_node *next = np->sibling; |
933 | |||
920 | np->parent = of_root; | 934 | np->parent = of_root; |
921 | attach_node_and_children(np); | 935 | attach_node_and_children(np); |
922 | np = next; | 936 | np = next; |
@@ -926,7 +940,7 @@ static int __init selftest_data_add(void) | |||
926 | 940 | ||
927 | #ifdef CONFIG_OF_OVERLAY | 941 | #ifdef CONFIG_OF_OVERLAY |
928 | 942 | ||
929 | static int selftest_probe(struct platform_device *pdev) | 943 | static int unittest_probe(struct platform_device *pdev) |
930 | { | 944 | { |
931 | struct device *dev = &pdev->dev; | 945 | struct device *dev = &pdev->dev; |
932 | struct device_node *np = dev->of_node; | 946 | struct device_node *np = dev->of_node; |
@@ -944,7 +958,7 @@ static int selftest_probe(struct platform_device *pdev) | |||
944 | return 0; | 958 | return 0; |
945 | } | 959 | } |
946 | 960 | ||
947 | static int selftest_remove(struct platform_device *pdev) | 961 | static int unittest_remove(struct platform_device *pdev) |
948 | { | 962 | { |
949 | struct device *dev = &pdev->dev; | 963 | struct device *dev = &pdev->dev; |
950 | struct device_node *np = dev->of_node; | 964 | struct device_node *np = dev->of_node; |
@@ -953,18 +967,18 @@ static int selftest_remove(struct platform_device *pdev) | |||
953 | return 0; | 967 | return 0; |
954 | } | 968 | } |
955 | 969 | ||
956 | static struct of_device_id selftest_match[] = { | 970 | static const struct of_device_id unittest_match[] = { |
957 | { .compatible = "selftest", }, | 971 | { .compatible = "unittest", }, |
958 | {}, | 972 | {}, |
959 | }; | 973 | }; |
960 | 974 | ||
961 | static struct platform_driver selftest_driver = { | 975 | static struct platform_driver unittest_driver = { |
962 | .probe = selftest_probe, | 976 | .probe = unittest_probe, |
963 | .remove = selftest_remove, | 977 | .remove = unittest_remove, |
964 | .driver = { | 978 | .driver = { |
965 | .name = "selftest", | 979 | .name = "unittest", |
966 | .owner = THIS_MODULE, | 980 | .owner = THIS_MODULE, |
967 | .of_match_table = of_match_ptr(selftest_match), | 981 | .of_match_table = of_match_ptr(unittest_match), |
968 | }, | 982 | }, |
969 | }; | 983 | }; |
970 | 984 | ||
@@ -1046,7 +1060,7 @@ static int of_path_device_type_exists(const char *path, | |||
1046 | return 0; | 1060 | return 0; |
1047 | } | 1061 | } |
1048 | 1062 | ||
1049 | static const char *selftest_path(int nr, enum overlay_type ovtype) | 1063 | static const char *unittest_path(int nr, enum overlay_type ovtype) |
1050 | { | 1064 | { |
1051 | const char *base; | 1065 | const char *base; |
1052 | static char buf[256]; | 1066 | static char buf[256]; |
@@ -1062,16 +1076,16 @@ static const char *selftest_path(int nr, enum overlay_type ovtype) | |||
1062 | buf[0] = '\0'; | 1076 | buf[0] = '\0'; |
1063 | return buf; | 1077 | return buf; |
1064 | } | 1078 | } |
1065 | snprintf(buf, sizeof(buf) - 1, "%s/test-selftest%d", base, nr); | 1079 | snprintf(buf, sizeof(buf) - 1, "%s/test-unittest%d", base, nr); |
1066 | buf[sizeof(buf) - 1] = '\0'; | 1080 | buf[sizeof(buf) - 1] = '\0'; |
1067 | return buf; | 1081 | return buf; |
1068 | } | 1082 | } |
1069 | 1083 | ||
1070 | static int of_selftest_device_exists(int selftest_nr, enum overlay_type ovtype) | 1084 | static int of_unittest_device_exists(int unittest_nr, enum overlay_type ovtype) |
1071 | { | 1085 | { |
1072 | const char *path; | 1086 | const char *path; |
1073 | 1087 | ||
1074 | path = selftest_path(selftest_nr, ovtype); | 1088 | path = unittest_path(unittest_nr, ovtype); |
1075 | 1089 | ||
1076 | switch (ovtype) { | 1090 | switch (ovtype) { |
1077 | case PDEV_OVERLAY: | 1091 | case PDEV_OVERLAY: |
@@ -1095,7 +1109,7 @@ static const char *overlay_path(int nr) | |||
1095 | 1109 | ||
1096 | static const char *bus_path = "/testcase-data/overlay-node/test-bus"; | 1110 | static const char *bus_path = "/testcase-data/overlay-node/test-bus"; |
1097 | 1111 | ||
1098 | static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr, | 1112 | static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr, |
1099 | int *overlay_id) | 1113 | int *overlay_id) |
1100 | { | 1114 | { |
1101 | struct device_node *np = NULL; | 1115 | struct device_node *np = NULL; |
@@ -1103,7 +1117,7 @@ static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr, | |||
1103 | 1117 | ||
1104 | np = of_find_node_by_path(overlay_path(overlay_nr)); | 1118 | np = of_find_node_by_path(overlay_path(overlay_nr)); |
1105 | if (np == NULL) { | 1119 | if (np == NULL) { |
1106 | selftest(0, "could not find overlay node @\"%s\"\n", | 1120 | unittest(0, "could not find overlay node @\"%s\"\n", |
1107 | overlay_path(overlay_nr)); | 1121 | overlay_path(overlay_nr)); |
1108 | ret = -EINVAL; | 1122 | ret = -EINVAL; |
1109 | goto out; | 1123 | goto out; |
@@ -1111,7 +1125,7 @@ static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr, | |||
1111 | 1125 | ||
1112 | ret = of_overlay_create(np); | 1126 | ret = of_overlay_create(np); |
1113 | if (ret < 0) { | 1127 | if (ret < 0) { |
1114 | selftest(0, "could not create overlay from \"%s\"\n", | 1128 | unittest(0, "could not create overlay from \"%s\"\n", |
1115 | overlay_path(overlay_nr)); | 1129 | overlay_path(overlay_nr)); |
1116 | goto out; | 1130 | goto out; |
1117 | } | 1131 | } |
@@ -1129,31 +1143,31 @@ out: | |||
1129 | } | 1143 | } |
1130 | 1144 | ||
1131 | /* apply an overlay while checking before and after states */ | 1145 | /* apply an overlay while checking before and after states */ |
1132 | static int of_selftest_apply_overlay_check(int overlay_nr, int selftest_nr, | 1146 | static int of_unittest_apply_overlay_check(int overlay_nr, int unittest_nr, |
1133 | int before, int after, enum overlay_type ovtype) | 1147 | int before, int after, enum overlay_type ovtype) |
1134 | { | 1148 | { |
1135 | int ret; | 1149 | int ret; |
1136 | 1150 | ||
1137 | /* selftest device must not be in before state */ | 1151 | /* unittest device must not be in before state */ |
1138 | if (of_selftest_device_exists(selftest_nr, ovtype) != before) { | 1152 | if (of_unittest_device_exists(unittest_nr, ovtype) != before) { |
1139 | selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", | 1153 | unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", |
1140 | overlay_path(overlay_nr), | 1154 | overlay_path(overlay_nr), |
1141 | selftest_path(selftest_nr, ovtype), | 1155 | unittest_path(unittest_nr, ovtype), |
1142 | !before ? "enabled" : "disabled"); | 1156 | !before ? "enabled" : "disabled"); |
1143 | return -EINVAL; | 1157 | return -EINVAL; |
1144 | } | 1158 | } |
1145 | 1159 | ||
1146 | ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, NULL); | 1160 | ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, NULL); |
1147 | if (ret != 0) { | 1161 | if (ret != 0) { |
1148 | /* of_selftest_apply_overlay already called selftest() */ | 1162 | /* of_unittest_apply_overlay already called unittest() */ |
1149 | return ret; | 1163 | return ret; |
1150 | } | 1164 | } |
1151 | 1165 | ||
1152 | /* selftest device must be to set to after state */ | 1166 | /* unittest device must be to set to after state */ |
1153 | if (of_selftest_device_exists(selftest_nr, ovtype) != after) { | 1167 | if (of_unittest_device_exists(unittest_nr, ovtype) != after) { |
1154 | selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", | 1168 | unittest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", |
1155 | overlay_path(overlay_nr), | 1169 | overlay_path(overlay_nr), |
1156 | selftest_path(selftest_nr, ovtype), | 1170 | unittest_path(unittest_nr, ovtype), |
1157 | !after ? "enabled" : "disabled"); | 1171 | !after ? "enabled" : "disabled"); |
1158 | return -EINVAL; | 1172 | return -EINVAL; |
1159 | } | 1173 | } |
@@ -1162,50 +1176,50 @@ static int of_selftest_apply_overlay_check(int overlay_nr, int selftest_nr, | |||
1162 | } | 1176 | } |
1163 | 1177 | ||
1164 | /* apply an overlay and then revert it while checking before, after states */ | 1178 | /* apply an overlay and then revert it while checking before, after states */ |
1165 | static int of_selftest_apply_revert_overlay_check(int overlay_nr, | 1179 | static int of_unittest_apply_revert_overlay_check(int overlay_nr, |
1166 | int selftest_nr, int before, int after, | 1180 | int unittest_nr, int before, int after, |
1167 | enum overlay_type ovtype) | 1181 | enum overlay_type ovtype) |
1168 | { | 1182 | { |
1169 | int ret, ov_id; | 1183 | int ret, ov_id; |
1170 | 1184 | ||
1171 | /* selftest device must be in before state */ | 1185 | /* unittest device must be in before state */ |
1172 | if (of_selftest_device_exists(selftest_nr, ovtype) != before) { | 1186 | if (of_unittest_device_exists(unittest_nr, ovtype) != before) { |
1173 | selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", | 1187 | unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", |
1174 | overlay_path(overlay_nr), | 1188 | overlay_path(overlay_nr), |
1175 | selftest_path(selftest_nr, ovtype), | 1189 | unittest_path(unittest_nr, ovtype), |
1176 | !before ? "enabled" : "disabled"); | 1190 | !before ? "enabled" : "disabled"); |
1177 | return -EINVAL; | 1191 | return -EINVAL; |
1178 | } | 1192 | } |
1179 | 1193 | ||
1180 | /* apply the overlay */ | 1194 | /* apply the overlay */ |
1181 | ret = of_selftest_apply_overlay(overlay_nr, selftest_nr, &ov_id); | 1195 | ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, &ov_id); |
1182 | if (ret != 0) { | 1196 | if (ret != 0) { |
1183 | /* of_selftest_apply_overlay already called selftest() */ | 1197 | /* of_unittest_apply_overlay already called unittest() */ |
1184 | return ret; | 1198 | return ret; |
1185 | } | 1199 | } |
1186 | 1200 | ||
1187 | /* selftest device must be in after state */ | 1201 | /* unittest device must be in after state */ |
1188 | if (of_selftest_device_exists(selftest_nr, ovtype) != after) { | 1202 | if (of_unittest_device_exists(unittest_nr, ovtype) != after) { |
1189 | selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", | 1203 | unittest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", |
1190 | overlay_path(overlay_nr), | 1204 | overlay_path(overlay_nr), |
1191 | selftest_path(selftest_nr, ovtype), | 1205 | unittest_path(unittest_nr, ovtype), |
1192 | !after ? "enabled" : "disabled"); | 1206 | !after ? "enabled" : "disabled"); |
1193 | return -EINVAL; | 1207 | return -EINVAL; |
1194 | } | 1208 | } |
1195 | 1209 | ||
1196 | ret = of_overlay_destroy(ov_id); | 1210 | ret = of_overlay_destroy(ov_id); |
1197 | if (ret != 0) { | 1211 | if (ret != 0) { |
1198 | selftest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n", | 1212 | unittest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n", |
1199 | overlay_path(overlay_nr), | 1213 | overlay_path(overlay_nr), |
1200 | selftest_path(selftest_nr, ovtype)); | 1214 | unittest_path(unittest_nr, ovtype)); |
1201 | return ret; | 1215 | return ret; |
1202 | } | 1216 | } |
1203 | 1217 | ||
1204 | /* selftest device must be again in before state */ | 1218 | /* unittest device must be again in before state */ |
1205 | if (of_selftest_device_exists(selftest_nr, PDEV_OVERLAY) != before) { | 1219 | if (of_unittest_device_exists(unittest_nr, PDEV_OVERLAY) != before) { |
1206 | selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", | 1220 | unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", |
1207 | overlay_path(overlay_nr), | 1221 | overlay_path(overlay_nr), |
1208 | selftest_path(selftest_nr, ovtype), | 1222 | unittest_path(unittest_nr, ovtype), |
1209 | !before ? "enabled" : "disabled"); | 1223 | !before ? "enabled" : "disabled"); |
1210 | return -EINVAL; | 1224 | return -EINVAL; |
1211 | } | 1225 | } |
@@ -1214,98 +1228,98 @@ static int of_selftest_apply_revert_overlay_check(int overlay_nr, | |||
1214 | } | 1228 | } |
1215 | 1229 | ||
1216 | /* test activation of device */ | 1230 | /* test activation of device */ |
1217 | static void of_selftest_overlay_0(void) | 1231 | static void of_unittest_overlay_0(void) |
1218 | { | 1232 | { |
1219 | int ret; | 1233 | int ret; |
1220 | 1234 | ||
1221 | /* device should enable */ | 1235 | /* device should enable */ |
1222 | ret = of_selftest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY); | 1236 | ret = of_unittest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY); |
1223 | if (ret != 0) | 1237 | if (ret != 0) |
1224 | return; | 1238 | return; |
1225 | 1239 | ||
1226 | selftest(1, "overlay test %d passed\n", 0); | 1240 | unittest(1, "overlay test %d passed\n", 0); |
1227 | } | 1241 | } |
1228 | 1242 | ||
1229 | /* test deactivation of device */ | 1243 | /* test deactivation of device */ |
1230 | static void of_selftest_overlay_1(void) | 1244 | static void of_unittest_overlay_1(void) |
1231 | { | 1245 | { |
1232 | int ret; | 1246 | int ret; |
1233 | 1247 | ||
1234 | /* device should disable */ | 1248 | /* device should disable */ |
1235 | ret = of_selftest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY); | 1249 | ret = of_unittest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY); |
1236 | if (ret != 0) | 1250 | if (ret != 0) |
1237 | return; | 1251 | return; |
1238 | 1252 | ||
1239 | selftest(1, "overlay test %d passed\n", 1); | 1253 | unittest(1, "overlay test %d passed\n", 1); |
1240 | } | 1254 | } |
1241 | 1255 | ||
1242 | /* test activation of device */ | 1256 | /* test activation of device */ |
1243 | static void of_selftest_overlay_2(void) | 1257 | static void of_unittest_overlay_2(void) |
1244 | { | 1258 | { |
1245 | int ret; | 1259 | int ret; |
1246 | 1260 | ||
1247 | /* device should enable */ | 1261 | /* device should enable */ |
1248 | ret = of_selftest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY); | 1262 | ret = of_unittest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY); |
1249 | if (ret != 0) | 1263 | if (ret != 0) |
1250 | return; | 1264 | return; |
1251 | 1265 | ||
1252 | selftest(1, "overlay test %d passed\n", 2); | 1266 | unittest(1, "overlay test %d passed\n", 2); |
1253 | } | 1267 | } |
1254 | 1268 | ||
1255 | /* test deactivation of device */ | 1269 | /* test deactivation of device */ |
1256 | static void of_selftest_overlay_3(void) | 1270 | static void of_unittest_overlay_3(void) |
1257 | { | 1271 | { |
1258 | int ret; | 1272 | int ret; |
1259 | 1273 | ||
1260 | /* device should disable */ | 1274 | /* device should disable */ |
1261 | ret = of_selftest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY); | 1275 | ret = of_unittest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY); |
1262 | if (ret != 0) | 1276 | if (ret != 0) |
1263 | return; | 1277 | return; |
1264 | 1278 | ||
1265 | selftest(1, "overlay test %d passed\n", 3); | 1279 | unittest(1, "overlay test %d passed\n", 3); |
1266 | } | 1280 | } |
1267 | 1281 | ||
1268 | /* test activation of a full device node */ | 1282 | /* test activation of a full device node */ |
1269 | static void of_selftest_overlay_4(void) | 1283 | static void of_unittest_overlay_4(void) |
1270 | { | 1284 | { |
1271 | int ret; | 1285 | int ret; |
1272 | 1286 | ||
1273 | /* device should disable */ | 1287 | /* device should disable */ |
1274 | ret = of_selftest_apply_overlay_check(4, 4, 0, 1, PDEV_OVERLAY); | 1288 | ret = of_unittest_apply_overlay_check(4, 4, 0, 1, PDEV_OVERLAY); |
1275 | if (ret != 0) | 1289 | if (ret != 0) |
1276 | return; | 1290 | return; |
1277 | 1291 | ||
1278 | selftest(1, "overlay test %d passed\n", 4); | 1292 | unittest(1, "overlay test %d passed\n", 4); |
1279 | } | 1293 | } |
1280 | 1294 | ||
1281 | /* test overlay apply/revert sequence */ | 1295 | /* test overlay apply/revert sequence */ |
1282 | static void of_selftest_overlay_5(void) | 1296 | static void of_unittest_overlay_5(void) |
1283 | { | 1297 | { |
1284 | int ret; | 1298 | int ret; |
1285 | 1299 | ||
1286 | /* device should disable */ | 1300 | /* device should disable */ |
1287 | ret = of_selftest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY); | 1301 | ret = of_unittest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY); |
1288 | if (ret != 0) | 1302 | if (ret != 0) |
1289 | return; | 1303 | return; |
1290 | 1304 | ||
1291 | selftest(1, "overlay test %d passed\n", 5); | 1305 | unittest(1, "overlay test %d passed\n", 5); |
1292 | } | 1306 | } |
1293 | 1307 | ||
1294 | /* test overlay application in sequence */ | 1308 | /* test overlay application in sequence */ |
1295 | static void of_selftest_overlay_6(void) | 1309 | static void of_unittest_overlay_6(void) |
1296 | { | 1310 | { |
1297 | struct device_node *np; | 1311 | struct device_node *np; |
1298 | int ret, i, ov_id[2]; | 1312 | int ret, i, ov_id[2]; |
1299 | int overlay_nr = 6, selftest_nr = 6; | 1313 | int overlay_nr = 6, unittest_nr = 6; |
1300 | int before = 0, after = 1; | 1314 | int before = 0, after = 1; |
1301 | 1315 | ||
1302 | /* selftest device must be in before state */ | 1316 | /* unittest device must be in before state */ |
1303 | for (i = 0; i < 2; i++) { | 1317 | for (i = 0; i < 2; i++) { |
1304 | if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) | 1318 | if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) |
1305 | != before) { | 1319 | != before) { |
1306 | selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", | 1320 | unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", |
1307 | overlay_path(overlay_nr + i), | 1321 | overlay_path(overlay_nr + i), |
1308 | selftest_path(selftest_nr + i, | 1322 | unittest_path(unittest_nr + i, |
1309 | PDEV_OVERLAY), | 1323 | PDEV_OVERLAY), |
1310 | !before ? "enabled" : "disabled"); | 1324 | !before ? "enabled" : "disabled"); |
1311 | return; | 1325 | return; |
@@ -1317,14 +1331,14 @@ static void of_selftest_overlay_6(void) | |||
1317 | 1331 | ||
1318 | np = of_find_node_by_path(overlay_path(overlay_nr + i)); | 1332 | np = of_find_node_by_path(overlay_path(overlay_nr + i)); |
1319 | if (np == NULL) { | 1333 | if (np == NULL) { |
1320 | selftest(0, "could not find overlay node @\"%s\"\n", | 1334 | unittest(0, "could not find overlay node @\"%s\"\n", |
1321 | overlay_path(overlay_nr + i)); | 1335 | overlay_path(overlay_nr + i)); |
1322 | return; | 1336 | return; |
1323 | } | 1337 | } |
1324 | 1338 | ||
1325 | ret = of_overlay_create(np); | 1339 | ret = of_overlay_create(np); |
1326 | if (ret < 0) { | 1340 | if (ret < 0) { |
1327 | selftest(0, "could not create overlay from \"%s\"\n", | 1341 | unittest(0, "could not create overlay from \"%s\"\n", |
1328 | overlay_path(overlay_nr + i)); | 1342 | overlay_path(overlay_nr + i)); |
1329 | return; | 1343 | return; |
1330 | } | 1344 | } |
@@ -1332,12 +1346,12 @@ static void of_selftest_overlay_6(void) | |||
1332 | } | 1346 | } |
1333 | 1347 | ||
1334 | for (i = 0; i < 2; i++) { | 1348 | for (i = 0; i < 2; i++) { |
1335 | /* selftest device must be in after state */ | 1349 | /* unittest device must be in after state */ |
1336 | if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) | 1350 | if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) |
1337 | != after) { | 1351 | != after) { |
1338 | selftest(0, "overlay @\"%s\" failed @\"%s\" %s\n", | 1352 | unittest(0, "overlay @\"%s\" failed @\"%s\" %s\n", |
1339 | overlay_path(overlay_nr + i), | 1353 | overlay_path(overlay_nr + i), |
1340 | selftest_path(selftest_nr + i, | 1354 | unittest_path(unittest_nr + i, |
1341 | PDEV_OVERLAY), | 1355 | PDEV_OVERLAY), |
1342 | !after ? "enabled" : "disabled"); | 1356 | !after ? "enabled" : "disabled"); |
1343 | return; | 1357 | return; |
@@ -1347,36 +1361,36 @@ static void of_selftest_overlay_6(void) | |||
1347 | for (i = 1; i >= 0; i--) { | 1361 | for (i = 1; i >= 0; i--) { |
1348 | ret = of_overlay_destroy(ov_id[i]); | 1362 | ret = of_overlay_destroy(ov_id[i]); |
1349 | if (ret != 0) { | 1363 | if (ret != 0) { |
1350 | selftest(0, "overlay @\"%s\" failed destroy @\"%s\"\n", | 1364 | unittest(0, "overlay @\"%s\" failed destroy @\"%s\"\n", |
1351 | overlay_path(overlay_nr + i), | 1365 | overlay_path(overlay_nr + i), |
1352 | selftest_path(selftest_nr + i, | 1366 | unittest_path(unittest_nr + i, |
1353 | PDEV_OVERLAY)); | 1367 | PDEV_OVERLAY)); |
1354 | return; | 1368 | return; |
1355 | } | 1369 | } |
1356 | } | 1370 | } |
1357 | 1371 | ||
1358 | for (i = 0; i < 2; i++) { | 1372 | for (i = 0; i < 2; i++) { |
1359 | /* selftest device must be again in before state */ | 1373 | /* unittest device must be again in before state */ |
1360 | if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) | 1374 | if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) |
1361 | != before) { | 1375 | != before) { |
1362 | selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", | 1376 | unittest(0, "overlay @\"%s\" with device @\"%s\" %s\n", |
1363 | overlay_path(overlay_nr + i), | 1377 | overlay_path(overlay_nr + i), |
1364 | selftest_path(selftest_nr + i, | 1378 | unittest_path(unittest_nr + i, |
1365 | PDEV_OVERLAY), | 1379 | PDEV_OVERLAY), |
1366 | !before ? "enabled" : "disabled"); | 1380 | !before ? "enabled" : "disabled"); |
1367 | return; | 1381 | return; |
1368 | } | 1382 | } |
1369 | } | 1383 | } |
1370 | 1384 | ||
1371 | selftest(1, "overlay test %d passed\n", 6); | 1385 | unittest(1, "overlay test %d passed\n", 6); |
1372 | } | 1386 | } |
1373 | 1387 | ||
1374 | /* test overlay application in sequence */ | 1388 | /* test overlay application in sequence */ |
1375 | static void of_selftest_overlay_8(void) | 1389 | static void of_unittest_overlay_8(void) |
1376 | { | 1390 | { |
1377 | struct device_node *np; | 1391 | struct device_node *np; |
1378 | int ret, i, ov_id[2]; | 1392 | int ret, i, ov_id[2]; |
1379 | int overlay_nr = 8, selftest_nr = 8; | 1393 | int overlay_nr = 8, unittest_nr = 8; |
1380 | 1394 | ||
1381 | /* we don't care about device state in this test */ | 1395 | /* we don't care about device state in this test */ |
1382 | 1396 | ||
@@ -1385,14 +1399,14 @@ static void of_selftest_overlay_8(void) | |||
1385 | 1399 | ||
1386 | np = of_find_node_by_path(overlay_path(overlay_nr + i)); | 1400 | np = of_find_node_by_path(overlay_path(overlay_nr + i)); |
1387 | if (np == NULL) { | 1401 | if (np == NULL) { |
1388 | selftest(0, "could not find overlay node @\"%s\"\n", | 1402 | unittest(0, "could not find overlay node @\"%s\"\n", |
1389 | overlay_path(overlay_nr + i)); | 1403 | overlay_path(overlay_nr + i)); |
1390 | return; | 1404 | return; |
1391 | } | 1405 | } |
1392 | 1406 | ||
1393 | ret = of_overlay_create(np); | 1407 | ret = of_overlay_create(np); |
1394 | if (ret < 0) { | 1408 | if (ret < 0) { |
1395 | selftest(0, "could not create overlay from \"%s\"\n", | 1409 | unittest(0, "could not create overlay from \"%s\"\n", |
1396 | overlay_path(overlay_nr + i)); | 1410 | overlay_path(overlay_nr + i)); |
1397 | return; | 1411 | return; |
1398 | } | 1412 | } |
@@ -1402,9 +1416,9 @@ static void of_selftest_overlay_8(void) | |||
1402 | /* now try to remove first overlay (it should fail) */ | 1416 | /* now try to remove first overlay (it should fail) */ |
1403 | ret = of_overlay_destroy(ov_id[0]); | 1417 | ret = of_overlay_destroy(ov_id[0]); |
1404 | if (ret == 0) { | 1418 | if (ret == 0) { |
1405 | selftest(0, "overlay @\"%s\" was destroyed @\"%s\"\n", | 1419 | unittest(0, "overlay @\"%s\" was destroyed @\"%s\"\n", |
1406 | overlay_path(overlay_nr + 0), | 1420 | overlay_path(overlay_nr + 0), |
1407 | selftest_path(selftest_nr, | 1421 | unittest_path(unittest_nr, |
1408 | PDEV_OVERLAY)); | 1422 | PDEV_OVERLAY)); |
1409 | return; | 1423 | return; |
1410 | } | 1424 | } |
@@ -1413,85 +1427,85 @@ static void of_selftest_overlay_8(void) | |||
1413 | for (i = 1; i >= 0; i--) { | 1427 | for (i = 1; i >= 0; i--) { |
1414 | ret = of_overlay_destroy(ov_id[i]); | 1428 | ret = of_overlay_destroy(ov_id[i]); |
1415 | if (ret != 0) { | 1429 | if (ret != 0) { |
1416 | selftest(0, "overlay @\"%s\" not destroyed @\"%s\"\n", | 1430 | unittest(0, "overlay @\"%s\" not destroyed @\"%s\"\n", |
1417 | overlay_path(overlay_nr + i), | 1431 | overlay_path(overlay_nr + i), |
1418 | selftest_path(selftest_nr, | 1432 | unittest_path(unittest_nr, |
1419 | PDEV_OVERLAY)); | 1433 | PDEV_OVERLAY)); |
1420 | return; | 1434 | return; |
1421 | } | 1435 | } |
1422 | } | 1436 | } |
1423 | 1437 | ||
1424 | selftest(1, "overlay test %d passed\n", 8); | 1438 | unittest(1, "overlay test %d passed\n", 8); |
1425 | } | 1439 | } |
1426 | 1440 | ||
1427 | /* test insertion of a bus with parent devices */ | 1441 | /* test insertion of a bus with parent devices */ |
1428 | static void of_selftest_overlay_10(void) | 1442 | static void of_unittest_overlay_10(void) |
1429 | { | 1443 | { |
1430 | int ret; | 1444 | int ret; |
1431 | char *child_path; | 1445 | char *child_path; |
1432 | 1446 | ||
1433 | /* device should disable */ | 1447 | /* device should disable */ |
1434 | ret = of_selftest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY); | 1448 | ret = of_unittest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY); |
1435 | if (selftest(ret == 0, | 1449 | if (unittest(ret == 0, |
1436 | "overlay test %d failed; overlay application\n", 10)) | 1450 | "overlay test %d failed; overlay application\n", 10)) |
1437 | return; | 1451 | return; |
1438 | 1452 | ||
1439 | child_path = kasprintf(GFP_KERNEL, "%s/test-selftest101", | 1453 | child_path = kasprintf(GFP_KERNEL, "%s/test-unittest101", |
1440 | selftest_path(10, PDEV_OVERLAY)); | 1454 | unittest_path(10, PDEV_OVERLAY)); |
1441 | if (selftest(child_path, "overlay test %d failed; kasprintf\n", 10)) | 1455 | if (unittest(child_path, "overlay test %d failed; kasprintf\n", 10)) |
1442 | return; | 1456 | return; |
1443 | 1457 | ||
1444 | ret = of_path_device_type_exists(child_path, PDEV_OVERLAY); | 1458 | ret = of_path_device_type_exists(child_path, PDEV_OVERLAY); |
1445 | kfree(child_path); | 1459 | kfree(child_path); |
1446 | if (selftest(ret, "overlay test %d failed; no child device\n", 10)) | 1460 | if (unittest(ret, "overlay test %d failed; no child device\n", 10)) |
1447 | return; | 1461 | return; |
1448 | } | 1462 | } |
1449 | 1463 | ||
1450 | /* test insertion of a bus with parent devices (and revert) */ | 1464 | /* test insertion of a bus with parent devices (and revert) */ |
1451 | static void of_selftest_overlay_11(void) | 1465 | static void of_unittest_overlay_11(void) |
1452 | { | 1466 | { |
1453 | int ret; | 1467 | int ret; |
1454 | 1468 | ||
1455 | /* device should disable */ | 1469 | /* device should disable */ |
1456 | ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1, | 1470 | ret = of_unittest_apply_revert_overlay_check(11, 11, 0, 1, |
1457 | PDEV_OVERLAY); | 1471 | PDEV_OVERLAY); |
1458 | if (selftest(ret == 0, | 1472 | if (unittest(ret == 0, |
1459 | "overlay test %d failed; overlay application\n", 11)) | 1473 | "overlay test %d failed; overlay application\n", 11)) |
1460 | return; | 1474 | return; |
1461 | } | 1475 | } |
1462 | 1476 | ||
1463 | #if IS_BUILTIN(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) | 1477 | #if IS_BUILTIN(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) |
1464 | 1478 | ||
1465 | struct selftest_i2c_bus_data { | 1479 | struct unittest_i2c_bus_data { |
1466 | struct platform_device *pdev; | 1480 | struct platform_device *pdev; |
1467 | struct i2c_adapter adap; | 1481 | struct i2c_adapter adap; |
1468 | }; | 1482 | }; |
1469 | 1483 | ||
1470 | static int selftest_i2c_master_xfer(struct i2c_adapter *adap, | 1484 | static int unittest_i2c_master_xfer(struct i2c_adapter *adap, |
1471 | struct i2c_msg *msgs, int num) | 1485 | struct i2c_msg *msgs, int num) |
1472 | { | 1486 | { |
1473 | struct selftest_i2c_bus_data *std = i2c_get_adapdata(adap); | 1487 | struct unittest_i2c_bus_data *std = i2c_get_adapdata(adap); |
1474 | 1488 | ||
1475 | (void)std; | 1489 | (void)std; |
1476 | 1490 | ||
1477 | return num; | 1491 | return num; |
1478 | } | 1492 | } |
1479 | 1493 | ||
1480 | static u32 selftest_i2c_functionality(struct i2c_adapter *adap) | 1494 | static u32 unittest_i2c_functionality(struct i2c_adapter *adap) |
1481 | { | 1495 | { |
1482 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | 1496 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
1483 | } | 1497 | } |
1484 | 1498 | ||
1485 | static const struct i2c_algorithm selftest_i2c_algo = { | 1499 | static const struct i2c_algorithm unittest_i2c_algo = { |
1486 | .master_xfer = selftest_i2c_master_xfer, | 1500 | .master_xfer = unittest_i2c_master_xfer, |
1487 | .functionality = selftest_i2c_functionality, | 1501 | .functionality = unittest_i2c_functionality, |
1488 | }; | 1502 | }; |
1489 | 1503 | ||
1490 | static int selftest_i2c_bus_probe(struct platform_device *pdev) | 1504 | static int unittest_i2c_bus_probe(struct platform_device *pdev) |
1491 | { | 1505 | { |
1492 | struct device *dev = &pdev->dev; | 1506 | struct device *dev = &pdev->dev; |
1493 | struct device_node *np = dev->of_node; | 1507 | struct device_node *np = dev->of_node; |
1494 | struct selftest_i2c_bus_data *std; | 1508 | struct unittest_i2c_bus_data *std; |
1495 | struct i2c_adapter *adap; | 1509 | struct i2c_adapter *adap; |
1496 | int ret; | 1510 | int ret; |
1497 | 1511 | ||
@@ -1505,7 +1519,7 @@ static int selftest_i2c_bus_probe(struct platform_device *pdev) | |||
1505 | 1519 | ||
1506 | std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); | 1520 | std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); |
1507 | if (!std) { | 1521 | if (!std) { |
1508 | dev_err(dev, "Failed to allocate selftest i2c data\n"); | 1522 | dev_err(dev, "Failed to allocate unittest i2c data\n"); |
1509 | return -ENOMEM; | 1523 | return -ENOMEM; |
1510 | } | 1524 | } |
1511 | 1525 | ||
@@ -1518,7 +1532,7 @@ static int selftest_i2c_bus_probe(struct platform_device *pdev) | |||
1518 | adap->nr = -1; | 1532 | adap->nr = -1; |
1519 | strlcpy(adap->name, pdev->name, sizeof(adap->name)); | 1533 | strlcpy(adap->name, pdev->name, sizeof(adap->name)); |
1520 | adap->class = I2C_CLASS_DEPRECATED; | 1534 | adap->class = I2C_CLASS_DEPRECATED; |
1521 | adap->algo = &selftest_i2c_algo; | 1535 | adap->algo = &unittest_i2c_algo; |
1522 | adap->dev.parent = dev; | 1536 | adap->dev.parent = dev; |
1523 | adap->dev.of_node = dev->of_node; | 1537 | adap->dev.of_node = dev->of_node; |
1524 | adap->timeout = 5 * HZ; | 1538 | adap->timeout = 5 * HZ; |
@@ -1533,11 +1547,11 @@ static int selftest_i2c_bus_probe(struct platform_device *pdev) | |||
1533 | return 0; | 1547 | return 0; |
1534 | } | 1548 | } |
1535 | 1549 | ||
1536 | static int selftest_i2c_bus_remove(struct platform_device *pdev) | 1550 | static int unittest_i2c_bus_remove(struct platform_device *pdev) |
1537 | { | 1551 | { |
1538 | struct device *dev = &pdev->dev; | 1552 | struct device *dev = &pdev->dev; |
1539 | struct device_node *np = dev->of_node; | 1553 | struct device_node *np = dev->of_node; |
1540 | struct selftest_i2c_bus_data *std = platform_get_drvdata(pdev); | 1554 | struct unittest_i2c_bus_data *std = platform_get_drvdata(pdev); |
1541 | 1555 | ||
1542 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1556 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); |
1543 | i2c_del_adapter(&std->adap); | 1557 | i2c_del_adapter(&std->adap); |
@@ -1545,21 +1559,21 @@ static int selftest_i2c_bus_remove(struct platform_device *pdev) | |||
1545 | return 0; | 1559 | return 0; |
1546 | } | 1560 | } |
1547 | 1561 | ||
1548 | static struct of_device_id selftest_i2c_bus_match[] = { | 1562 | static const struct of_device_id unittest_i2c_bus_match[] = { |
1549 | { .compatible = "selftest-i2c-bus", }, | 1563 | { .compatible = "unittest-i2c-bus", }, |
1550 | {}, | 1564 | {}, |
1551 | }; | 1565 | }; |
1552 | 1566 | ||
1553 | static struct platform_driver selftest_i2c_bus_driver = { | 1567 | static struct platform_driver unittest_i2c_bus_driver = { |
1554 | .probe = selftest_i2c_bus_probe, | 1568 | .probe = unittest_i2c_bus_probe, |
1555 | .remove = selftest_i2c_bus_remove, | 1569 | .remove = unittest_i2c_bus_remove, |
1556 | .driver = { | 1570 | .driver = { |
1557 | .name = "selftest-i2c-bus", | 1571 | .name = "unittest-i2c-bus", |
1558 | .of_match_table = of_match_ptr(selftest_i2c_bus_match), | 1572 | .of_match_table = of_match_ptr(unittest_i2c_bus_match), |
1559 | }, | 1573 | }, |
1560 | }; | 1574 | }; |
1561 | 1575 | ||
1562 | static int selftest_i2c_dev_probe(struct i2c_client *client, | 1576 | static int unittest_i2c_dev_probe(struct i2c_client *client, |
1563 | const struct i2c_device_id *id) | 1577 | const struct i2c_device_id *id) |
1564 | { | 1578 | { |
1565 | struct device *dev = &client->dev; | 1579 | struct device *dev = &client->dev; |
@@ -1575,7 +1589,7 @@ static int selftest_i2c_dev_probe(struct i2c_client *client, | |||
1575 | return 0; | 1589 | return 0; |
1576 | }; | 1590 | }; |
1577 | 1591 | ||
1578 | static int selftest_i2c_dev_remove(struct i2c_client *client) | 1592 | static int unittest_i2c_dev_remove(struct i2c_client *client) |
1579 | { | 1593 | { |
1580 | struct device *dev = &client->dev; | 1594 | struct device *dev = &client->dev; |
1581 | struct device_node *np = client->dev.of_node; | 1595 | struct device_node *np = client->dev.of_node; |
@@ -1584,42 +1598,42 @@ static int selftest_i2c_dev_remove(struct i2c_client *client) | |||
1584 | return 0; | 1598 | return 0; |
1585 | } | 1599 | } |
1586 | 1600 | ||
1587 | static const struct i2c_device_id selftest_i2c_dev_id[] = { | 1601 | static const struct i2c_device_id unittest_i2c_dev_id[] = { |
1588 | { .name = "selftest-i2c-dev" }, | 1602 | { .name = "unittest-i2c-dev" }, |
1589 | { } | 1603 | { } |
1590 | }; | 1604 | }; |
1591 | 1605 | ||
1592 | static struct i2c_driver selftest_i2c_dev_driver = { | 1606 | static struct i2c_driver unittest_i2c_dev_driver = { |
1593 | .driver = { | 1607 | .driver = { |
1594 | .name = "selftest-i2c-dev", | 1608 | .name = "unittest-i2c-dev", |
1595 | .owner = THIS_MODULE, | 1609 | .owner = THIS_MODULE, |
1596 | }, | 1610 | }, |
1597 | .probe = selftest_i2c_dev_probe, | 1611 | .probe = unittest_i2c_dev_probe, |
1598 | .remove = selftest_i2c_dev_remove, | 1612 | .remove = unittest_i2c_dev_remove, |
1599 | .id_table = selftest_i2c_dev_id, | 1613 | .id_table = unittest_i2c_dev_id, |
1600 | }; | 1614 | }; |
1601 | 1615 | ||
1602 | #if IS_BUILTIN(CONFIG_I2C_MUX) | 1616 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1603 | 1617 | ||
1604 | struct selftest_i2c_mux_data { | 1618 | struct unittest_i2c_mux_data { |
1605 | int nchans; | 1619 | int nchans; |
1606 | struct i2c_adapter *adap[]; | 1620 | struct i2c_adapter *adap[]; |
1607 | }; | 1621 | }; |
1608 | 1622 | ||
1609 | static int selftest_i2c_mux_select_chan(struct i2c_adapter *adap, | 1623 | static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap, |
1610 | void *client, u32 chan) | 1624 | void *client, u32 chan) |
1611 | { | 1625 | { |
1612 | return 0; | 1626 | return 0; |
1613 | } | 1627 | } |
1614 | 1628 | ||
1615 | static int selftest_i2c_mux_probe(struct i2c_client *client, | 1629 | static int unittest_i2c_mux_probe(struct i2c_client *client, |
1616 | const struct i2c_device_id *id) | 1630 | const struct i2c_device_id *id) |
1617 | { | 1631 | { |
1618 | int ret, i, nchans, size; | 1632 | int ret, i, nchans, size; |
1619 | struct device *dev = &client->dev; | 1633 | struct device *dev = &client->dev; |
1620 | struct i2c_adapter *adap = to_i2c_adapter(dev->parent); | 1634 | struct i2c_adapter *adap = to_i2c_adapter(dev->parent); |
1621 | struct device_node *np = client->dev.of_node, *child; | 1635 | struct device_node *np = client->dev.of_node, *child; |
1622 | struct selftest_i2c_mux_data *stm; | 1636 | struct unittest_i2c_mux_data *stm; |
1623 | u32 reg, max_reg; | 1637 | u32 reg, max_reg; |
1624 | 1638 | ||
1625 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1639 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); |
@@ -1643,7 +1657,7 @@ static int selftest_i2c_mux_probe(struct i2c_client *client, | |||
1643 | return -EINVAL; | 1657 | return -EINVAL; |
1644 | } | 1658 | } |
1645 | 1659 | ||
1646 | size = offsetof(struct selftest_i2c_mux_data, adap[nchans]); | 1660 | size = offsetof(struct unittest_i2c_mux_data, adap[nchans]); |
1647 | stm = devm_kzalloc(dev, size, GFP_KERNEL); | 1661 | stm = devm_kzalloc(dev, size, GFP_KERNEL); |
1648 | if (!stm) { | 1662 | if (!stm) { |
1649 | dev_err(dev, "Out of memory\n"); | 1663 | dev_err(dev, "Out of memory\n"); |
@@ -1652,7 +1666,7 @@ static int selftest_i2c_mux_probe(struct i2c_client *client, | |||
1652 | stm->nchans = nchans; | 1666 | stm->nchans = nchans; |
1653 | for (i = 0; i < nchans; i++) { | 1667 | for (i = 0; i < nchans; i++) { |
1654 | stm->adap[i] = i2c_add_mux_adapter(adap, dev, client, | 1668 | stm->adap[i] = i2c_add_mux_adapter(adap, dev, client, |
1655 | 0, i, 0, selftest_i2c_mux_select_chan, NULL); | 1669 | 0, i, 0, unittest_i2c_mux_select_chan, NULL); |
1656 | if (!stm->adap[i]) { | 1670 | if (!stm->adap[i]) { |
1657 | dev_err(dev, "Failed to register mux #%d\n", i); | 1671 | dev_err(dev, "Failed to register mux #%d\n", i); |
1658 | for (i--; i >= 0; i--) | 1672 | for (i--; i >= 0; i--) |
@@ -1666,11 +1680,11 @@ static int selftest_i2c_mux_probe(struct i2c_client *client, | |||
1666 | return 0; | 1680 | return 0; |
1667 | }; | 1681 | }; |
1668 | 1682 | ||
1669 | static int selftest_i2c_mux_remove(struct i2c_client *client) | 1683 | static int unittest_i2c_mux_remove(struct i2c_client *client) |
1670 | { | 1684 | { |
1671 | struct device *dev = &client->dev; | 1685 | struct device *dev = &client->dev; |
1672 | struct device_node *np = client->dev.of_node; | 1686 | struct device_node *np = client->dev.of_node; |
1673 | struct selftest_i2c_mux_data *stm = i2c_get_clientdata(client); | 1687 | struct unittest_i2c_mux_data *stm = i2c_get_clientdata(client); |
1674 | int i; | 1688 | int i; |
1675 | 1689 | ||
1676 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1690 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); |
@@ -1679,166 +1693,166 @@ static int selftest_i2c_mux_remove(struct i2c_client *client) | |||
1679 | return 0; | 1693 | return 0; |
1680 | } | 1694 | } |
1681 | 1695 | ||
1682 | static const struct i2c_device_id selftest_i2c_mux_id[] = { | 1696 | static const struct i2c_device_id unittest_i2c_mux_id[] = { |
1683 | { .name = "selftest-i2c-mux" }, | 1697 | { .name = "unittest-i2c-mux" }, |
1684 | { } | 1698 | { } |
1685 | }; | 1699 | }; |
1686 | 1700 | ||
1687 | static struct i2c_driver selftest_i2c_mux_driver = { | 1701 | static struct i2c_driver unittest_i2c_mux_driver = { |
1688 | .driver = { | 1702 | .driver = { |
1689 | .name = "selftest-i2c-mux", | 1703 | .name = "unittest-i2c-mux", |
1690 | .owner = THIS_MODULE, | 1704 | .owner = THIS_MODULE, |
1691 | }, | 1705 | }, |
1692 | .probe = selftest_i2c_mux_probe, | 1706 | .probe = unittest_i2c_mux_probe, |
1693 | .remove = selftest_i2c_mux_remove, | 1707 | .remove = unittest_i2c_mux_remove, |
1694 | .id_table = selftest_i2c_mux_id, | 1708 | .id_table = unittest_i2c_mux_id, |
1695 | }; | 1709 | }; |
1696 | 1710 | ||
1697 | #endif | 1711 | #endif |
1698 | 1712 | ||
1699 | static int of_selftest_overlay_i2c_init(void) | 1713 | static int of_unittest_overlay_i2c_init(void) |
1700 | { | 1714 | { |
1701 | int ret; | 1715 | int ret; |
1702 | 1716 | ||
1703 | ret = i2c_add_driver(&selftest_i2c_dev_driver); | 1717 | ret = i2c_add_driver(&unittest_i2c_dev_driver); |
1704 | if (selftest(ret == 0, | 1718 | if (unittest(ret == 0, |
1705 | "could not register selftest i2c device driver\n")) | 1719 | "could not register unittest i2c device driver\n")) |
1706 | return ret; | 1720 | return ret; |
1707 | 1721 | ||
1708 | ret = platform_driver_register(&selftest_i2c_bus_driver); | 1722 | ret = platform_driver_register(&unittest_i2c_bus_driver); |
1709 | if (selftest(ret == 0, | 1723 | if (unittest(ret == 0, |
1710 | "could not register selftest i2c bus driver\n")) | 1724 | "could not register unittest i2c bus driver\n")) |
1711 | return ret; | 1725 | return ret; |
1712 | 1726 | ||
1713 | #if IS_BUILTIN(CONFIG_I2C_MUX) | 1727 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1714 | ret = i2c_add_driver(&selftest_i2c_mux_driver); | 1728 | ret = i2c_add_driver(&unittest_i2c_mux_driver); |
1715 | if (selftest(ret == 0, | 1729 | if (unittest(ret == 0, |
1716 | "could not register selftest i2c mux driver\n")) | 1730 | "could not register unittest i2c mux driver\n")) |
1717 | return ret; | 1731 | return ret; |
1718 | #endif | 1732 | #endif |
1719 | 1733 | ||
1720 | return 0; | 1734 | return 0; |
1721 | } | 1735 | } |
1722 | 1736 | ||
1723 | static void of_selftest_overlay_i2c_cleanup(void) | 1737 | static void of_unittest_overlay_i2c_cleanup(void) |
1724 | { | 1738 | { |
1725 | #if IS_BUILTIN(CONFIG_I2C_MUX) | 1739 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1726 | i2c_del_driver(&selftest_i2c_mux_driver); | 1740 | i2c_del_driver(&unittest_i2c_mux_driver); |
1727 | #endif | 1741 | #endif |
1728 | platform_driver_unregister(&selftest_i2c_bus_driver); | 1742 | platform_driver_unregister(&unittest_i2c_bus_driver); |
1729 | i2c_del_driver(&selftest_i2c_dev_driver); | 1743 | i2c_del_driver(&unittest_i2c_dev_driver); |
1730 | } | 1744 | } |
1731 | 1745 | ||
1732 | static void of_selftest_overlay_i2c_12(void) | 1746 | static void of_unittest_overlay_i2c_12(void) |
1733 | { | 1747 | { |
1734 | int ret; | 1748 | int ret; |
1735 | 1749 | ||
1736 | /* device should enable */ | 1750 | /* device should enable */ |
1737 | ret = of_selftest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY); | 1751 | ret = of_unittest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY); |
1738 | if (ret != 0) | 1752 | if (ret != 0) |
1739 | return; | 1753 | return; |
1740 | 1754 | ||
1741 | selftest(1, "overlay test %d passed\n", 12); | 1755 | unittest(1, "overlay test %d passed\n", 12); |
1742 | } | 1756 | } |
1743 | 1757 | ||
1744 | /* test deactivation of device */ | 1758 | /* test deactivation of device */ |
1745 | static void of_selftest_overlay_i2c_13(void) | 1759 | static void of_unittest_overlay_i2c_13(void) |
1746 | { | 1760 | { |
1747 | int ret; | 1761 | int ret; |
1748 | 1762 | ||
1749 | /* device should disable */ | 1763 | /* device should disable */ |
1750 | ret = of_selftest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY); | 1764 | ret = of_unittest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY); |
1751 | if (ret != 0) | 1765 | if (ret != 0) |
1752 | return; | 1766 | return; |
1753 | 1767 | ||
1754 | selftest(1, "overlay test %d passed\n", 13); | 1768 | unittest(1, "overlay test %d passed\n", 13); |
1755 | } | 1769 | } |
1756 | 1770 | ||
1757 | /* just check for i2c mux existence */ | 1771 | /* just check for i2c mux existence */ |
1758 | static void of_selftest_overlay_i2c_14(void) | 1772 | static void of_unittest_overlay_i2c_14(void) |
1759 | { | 1773 | { |
1760 | } | 1774 | } |
1761 | 1775 | ||
1762 | static void of_selftest_overlay_i2c_15(void) | 1776 | static void of_unittest_overlay_i2c_15(void) |
1763 | { | 1777 | { |
1764 | int ret; | 1778 | int ret; |
1765 | 1779 | ||
1766 | /* device should enable */ | 1780 | /* device should enable */ |
1767 | ret = of_selftest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); | 1781 | ret = of_unittest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); |
1768 | if (ret != 0) | 1782 | if (ret != 0) |
1769 | return; | 1783 | return; |
1770 | 1784 | ||
1771 | selftest(1, "overlay test %d passed\n", 15); | 1785 | unittest(1, "overlay test %d passed\n", 15); |
1772 | } | 1786 | } |
1773 | 1787 | ||
1774 | #else | 1788 | #else |
1775 | 1789 | ||
1776 | static inline void of_selftest_overlay_i2c_14(void) { } | 1790 | static inline void of_unittest_overlay_i2c_14(void) { } |
1777 | static inline void of_selftest_overlay_i2c_15(void) { } | 1791 | static inline void of_unittest_overlay_i2c_15(void) { } |
1778 | 1792 | ||
1779 | #endif | 1793 | #endif |
1780 | 1794 | ||
1781 | static void __init of_selftest_overlay(void) | 1795 | static void __init of_unittest_overlay(void) |
1782 | { | 1796 | { |
1783 | struct device_node *bus_np = NULL; | 1797 | struct device_node *bus_np = NULL; |
1784 | int ret; | 1798 | int ret; |
1785 | 1799 | ||
1786 | ret = platform_driver_register(&selftest_driver); | 1800 | ret = platform_driver_register(&unittest_driver); |
1787 | if (ret != 0) { | 1801 | if (ret != 0) { |
1788 | selftest(0, "could not register selftest driver\n"); | 1802 | unittest(0, "could not register unittest driver\n"); |
1789 | goto out; | 1803 | goto out; |
1790 | } | 1804 | } |
1791 | 1805 | ||
1792 | bus_np = of_find_node_by_path(bus_path); | 1806 | bus_np = of_find_node_by_path(bus_path); |
1793 | if (bus_np == NULL) { | 1807 | if (bus_np == NULL) { |
1794 | selftest(0, "could not find bus_path \"%s\"\n", bus_path); | 1808 | unittest(0, "could not find bus_path \"%s\"\n", bus_path); |
1795 | goto out; | 1809 | goto out; |
1796 | } | 1810 | } |
1797 | 1811 | ||
1798 | ret = of_platform_populate(bus_np, of_default_bus_match_table, | 1812 | ret = of_platform_populate(bus_np, of_default_bus_match_table, |
1799 | NULL, NULL); | 1813 | NULL, NULL); |
1800 | if (ret != 0) { | 1814 | if (ret != 0) { |
1801 | selftest(0, "could not populate bus @ \"%s\"\n", bus_path); | 1815 | unittest(0, "could not populate bus @ \"%s\"\n", bus_path); |
1802 | goto out; | 1816 | goto out; |
1803 | } | 1817 | } |
1804 | 1818 | ||
1805 | if (!of_selftest_device_exists(100, PDEV_OVERLAY)) { | 1819 | if (!of_unittest_device_exists(100, PDEV_OVERLAY)) { |
1806 | selftest(0, "could not find selftest0 @ \"%s\"\n", | 1820 | unittest(0, "could not find unittest0 @ \"%s\"\n", |
1807 | selftest_path(100, PDEV_OVERLAY)); | 1821 | unittest_path(100, PDEV_OVERLAY)); |
1808 | goto out; | 1822 | goto out; |
1809 | } | 1823 | } |
1810 | 1824 | ||
1811 | if (of_selftest_device_exists(101, PDEV_OVERLAY)) { | 1825 | if (of_unittest_device_exists(101, PDEV_OVERLAY)) { |
1812 | selftest(0, "selftest1 @ \"%s\" should not exist\n", | 1826 | unittest(0, "unittest1 @ \"%s\" should not exist\n", |
1813 | selftest_path(101, PDEV_OVERLAY)); | 1827 | unittest_path(101, PDEV_OVERLAY)); |
1814 | goto out; | 1828 | goto out; |
1815 | } | 1829 | } |
1816 | 1830 | ||
1817 | selftest(1, "basic infrastructure of overlays passed"); | 1831 | unittest(1, "basic infrastructure of overlays passed"); |
1818 | 1832 | ||
1819 | /* tests in sequence */ | 1833 | /* tests in sequence */ |
1820 | of_selftest_overlay_0(); | 1834 | of_unittest_overlay_0(); |
1821 | of_selftest_overlay_1(); | 1835 | of_unittest_overlay_1(); |
1822 | of_selftest_overlay_2(); | 1836 | of_unittest_overlay_2(); |
1823 | of_selftest_overlay_3(); | 1837 | of_unittest_overlay_3(); |
1824 | of_selftest_overlay_4(); | 1838 | of_unittest_overlay_4(); |
1825 | of_selftest_overlay_5(); | 1839 | of_unittest_overlay_5(); |
1826 | of_selftest_overlay_6(); | 1840 | of_unittest_overlay_6(); |
1827 | of_selftest_overlay_8(); | 1841 | of_unittest_overlay_8(); |
1828 | 1842 | ||
1829 | of_selftest_overlay_10(); | 1843 | of_unittest_overlay_10(); |
1830 | of_selftest_overlay_11(); | 1844 | of_unittest_overlay_11(); |
1831 | 1845 | ||
1832 | #if IS_BUILTIN(CONFIG_I2C) | 1846 | #if IS_BUILTIN(CONFIG_I2C) |
1833 | if (selftest(of_selftest_overlay_i2c_init() == 0, "i2c init failed\n")) | 1847 | if (unittest(of_unittest_overlay_i2c_init() == 0, "i2c init failed\n")) |
1834 | goto out; | 1848 | goto out; |
1835 | 1849 | ||
1836 | of_selftest_overlay_i2c_12(); | 1850 | of_unittest_overlay_i2c_12(); |
1837 | of_selftest_overlay_i2c_13(); | 1851 | of_unittest_overlay_i2c_13(); |
1838 | of_selftest_overlay_i2c_14(); | 1852 | of_unittest_overlay_i2c_14(); |
1839 | of_selftest_overlay_i2c_15(); | 1853 | of_unittest_overlay_i2c_15(); |
1840 | 1854 | ||
1841 | of_selftest_overlay_i2c_cleanup(); | 1855 | of_unittest_overlay_i2c_cleanup(); |
1842 | #endif | 1856 | #endif |
1843 | 1857 | ||
1844 | out: | 1858 | out: |
@@ -1846,16 +1860,16 @@ out: | |||
1846 | } | 1860 | } |
1847 | 1861 | ||
1848 | #else | 1862 | #else |
1849 | static inline void __init of_selftest_overlay(void) { } | 1863 | static inline void __init of_unittest_overlay(void) { } |
1850 | #endif | 1864 | #endif |
1851 | 1865 | ||
1852 | static int __init of_selftest(void) | 1866 | static int __init of_unittest(void) |
1853 | { | 1867 | { |
1854 | struct device_node *np; | 1868 | struct device_node *np; |
1855 | int res; | 1869 | int res; |
1856 | 1870 | ||
1857 | /* adding data for selftest */ | 1871 | /* adding data for unittest */ |
1858 | res = selftest_data_add(); | 1872 | res = unittest_data_add(); |
1859 | if (res) | 1873 | if (res) |
1860 | return res; | 1874 | return res; |
1861 | if (!of_aliases) | 1875 | if (!of_aliases) |
@@ -1868,27 +1882,27 @@ static int __init of_selftest(void) | |||
1868 | } | 1882 | } |
1869 | of_node_put(np); | 1883 | of_node_put(np); |
1870 | 1884 | ||
1871 | pr_info("start of selftest - you will see error messages\n"); | 1885 | pr_info("start of unittest - you will see error messages\n"); |
1872 | of_selftest_check_tree_linkage(); | 1886 | of_unittest_check_tree_linkage(); |
1873 | of_selftest_check_phandles(); | 1887 | of_unittest_check_phandles(); |
1874 | of_selftest_find_node_by_name(); | 1888 | of_unittest_find_node_by_name(); |
1875 | of_selftest_dynamic(); | 1889 | of_unittest_dynamic(); |
1876 | of_selftest_parse_phandle_with_args(); | 1890 | of_unittest_parse_phandle_with_args(); |
1877 | of_selftest_property_string(); | 1891 | of_unittest_property_string(); |
1878 | of_selftest_property_copy(); | 1892 | of_unittest_property_copy(); |
1879 | of_selftest_changeset(); | 1893 | of_unittest_changeset(); |
1880 | of_selftest_parse_interrupts(); | 1894 | of_unittest_parse_interrupts(); |
1881 | of_selftest_parse_interrupts_extended(); | 1895 | of_unittest_parse_interrupts_extended(); |
1882 | of_selftest_match_node(); | 1896 | of_unittest_match_node(); |
1883 | of_selftest_platform_populate(); | 1897 | of_unittest_platform_populate(); |
1884 | of_selftest_overlay(); | 1898 | of_unittest_overlay(); |
1885 | 1899 | ||
1886 | /* Double check linkage after removing testcase data */ | 1900 | /* Double check linkage after removing testcase data */ |
1887 | of_selftest_check_tree_linkage(); | 1901 | of_unittest_check_tree_linkage(); |
1888 | 1902 | ||
1889 | pr_info("end of selftest - %i passed, %i failed\n", | 1903 | pr_info("end of unittest - %i passed, %i failed\n", |
1890 | selftest_results.passed, selftest_results.failed); | 1904 | unittest_results.passed, unittest_results.failed); |
1891 | 1905 | ||
1892 | return 0; | 1906 | return 0; |
1893 | } | 1907 | } |
1894 | late_initcall(of_selftest); | 1908 | 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 | ||