of: Merge of_platform_bus_type with platform_bus_type
[linux-2.6-block.git] / arch / microblaze / kernel / of_platform.c
CommitLineData
12e84142
MS
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 * and Arnd Bergmann, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#undef DEBUG
14
15#include <linux/string.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/mod_devicetable.h>
12e84142
MS
20#include <linux/pci.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
23#include <linux/of_platform.h>
24
25#include <linux/errno.h>
26#include <linux/topology.h>
27#include <asm/atomic.h>
28
5fd200f3
GL
29/*
30 * The list of OF IDs below is used for matching bus types in the
31 * system whose devices are to be exposed as of_platform_devices.
12e84142 32 *
5fd200f3
GL
33 * This is the default list valid for most platforms. This file provides
34 * functions who can take an explicit list if necessary though
35 *
36 * The search is always performed recursively looking for children of
37 * the provided device_node and recursively if such a children matches
38 * a bus type in the list
12e84142
MS
39 */
40
5fd200f3
GL
41const struct of_device_id of_default_bus_ids[] = {
42 { .type = "soc", },
43 { .compatible = "soc", },
44 { .type = "plb5", },
45 { .type = "plb4", },
46 { .type = "opb", },
47 { .type = "simple", },
48 {},
49};
12e84142
MS
50
51static int of_dev_node_match(struct device *dev, void *data)
52{
61c7a080 53 return to_of_device(dev)->dev.of_node == data;
12e84142
MS
54}
55
56struct of_device *of_find_device_by_node(struct device_node *np)
57{
58 struct device *dev;
59
60 dev = bus_find_device(&of_platform_bus_type,
61 NULL, np, of_dev_node_match);
62 if (dev)
63 return to_of_device(dev);
64 return NULL;
65}
66EXPORT_SYMBOL(of_find_device_by_node);