]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/board/board.c
staging: board: disable as it breaks the build
[karo-tx-linux.git] / drivers / staging / board / board.c
1 #include <linux/init.h>
2 #include <linux/device.h>
3 #include <linux/kernel.h>
4 #include <linux/of.h>
5 #include <linux/of_address.h>
6 #include "board.h"
7
8 static bool find_by_address(u64 base_address)
9 {
10         struct device_node *dn = of_find_all_nodes(NULL);
11         struct resource res;
12
13         while (dn) {
14                 if (of_can_translate_address(dn)
15                     && !of_address_to_resource(dn, 0, &res)) {
16                         if (res.start == base_address) {
17                                 of_node_put(dn);
18                                 return true;
19                         }
20                 }
21                 dn = of_find_all_nodes(dn);
22         }
23
24         return false;
25 }
26
27 bool __init board_staging_dt_node_available(const struct resource *resource,
28                                             unsigned int num_resources)
29 {
30         unsigned int i;
31
32         for (i = 0; i < num_resources; i++) {
33                 const struct resource *r = resource + i;
34
35                 if (resource_type(r) == IORESOURCE_MEM)
36                         if (find_by_address(r->start))
37                                 return true; /* DT node available */
38         }
39
40         return false; /* Nothing found */
41 }