aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c23
-rw-r--r--drivers/of/device.c13
-rw-r--r--drivers/of/of_private.h36
-rw-r--r--drivers/of/platform.c13
4 files changed, 63 insertions, 22 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 16ee7a08e044..8b9fa83dc77b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -24,33 +24,16 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
26 26
27/** 27#include "of_private.h"
28 * struct alias_prop - Alias property in 'aliases' node
29 * @link: List node to link the structure in aliases_lookup list
30 * @alias: Alias property name
31 * @np: Pointer to device_node that the alias stands for
32 * @id: Index value from end of alias name
33 * @stem: Alias string without the index
34 *
35 * The structure represents one alias property of 'aliases' node as
36 * an entry in aliases_lookup list.
37 */
38struct alias_prop {
39 struct list_head link;
40 const char *alias;
41 struct device_node *np;
42 int id;
43 char stem[0];
44};
45 28
46static LIST_HEAD(aliases_lookup); 29LIST_HEAD(aliases_lookup);
47 30
48struct device_node *of_allnodes; 31struct device_node *of_allnodes;
49EXPORT_SYMBOL(of_allnodes); 32EXPORT_SYMBOL(of_allnodes);
50struct device_node *of_chosen; 33struct device_node *of_chosen;
51struct device_node *of_aliases; 34struct device_node *of_aliases;
52 35
53static DEFINE_MUTEX(of_aliases_mutex); 36DEFINE_MUTEX(of_aliases_mutex);
54 37
55/* use when traversing tree through the allnext, child, sibling, 38/* use when traversing tree through the allnext, child, sibling,
56 * or parent members of struct device_node. 39 * or parent members of struct device_node.
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 4c74e4fc5a51..f685e55e0717 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -8,6 +8,7 @@
8#include <linux/slab.h> 8#include <linux/slab.h>
9 9
10#include <asm/errno.h> 10#include <asm/errno.h>
11#include "of_private.h"
11 12
12/** 13/**
13 * of_match_device - Tell if a struct device matches an of_device_id list 14 * of_match_device - Tell if a struct device matches an of_device_id list
@@ -131,6 +132,7 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
131void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) 132void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
132{ 133{
133 const char *compat; 134 const char *compat;
135 struct alias_prop *app;
134 int seen = 0, cplen, sl; 136 int seen = 0, cplen, sl;
135 137
136 if ((!dev) || (!dev->of_node)) 138 if ((!dev) || (!dev->of_node))
@@ -153,6 +155,17 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
153 seen++; 155 seen++;
154 } 156 }
155 add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen); 157 add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
158
159 seen = 0;
160 mutex_lock(&of_aliases_mutex);
161 list_for_each_entry(app, &aliases_lookup, link) {
162 if (dev->of_node == app->np) {
163 add_uevent_var(env, "OF_ALIAS_%d=%s", seen,
164 app->alias);
165 seen++;
166 }
167 }
168 mutex_unlock(&of_aliases_mutex);
156} 169}
157 170
158int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) 171int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
new file mode 100644
index 000000000000..ff350c8fa7ac
--- /dev/null
+++ b/drivers/of/of_private.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_OF_PRIVATE_H
2#define _LINUX_OF_PRIVATE_H
3/*
4 * Private symbols used by OF support code
5 *
6 * Paul Mackerras August 1996.
7 * Copyright (C) 1996-2005 Paul Mackerras.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15/**
16 * struct alias_prop - Alias property in 'aliases' node
17 * @link: List node to link the structure in aliases_lookup list
18 * @alias: Alias property name
19 * @np: Pointer to device_node that the alias stands for
20 * @id: Index value from end of alias name
21 * @stem: Alias string without the index
22 *
23 * The structure represents one alias property of 'aliases' node as
24 * an entry in aliases_lookup list.
25 */
26struct alias_prop {
27 struct list_head link;
28 const char *alias;
29 struct device_node *np;
30 int id;
31 char stem[0];
32};
33
34extern struct mutex of_aliases_mutex;
35extern struct list_head aliases_lookup;
36#endif /* _LINUX_OF_PRIVATE_H */
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b80891b43816..3c3e3cad3e08 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -203,6 +203,7 @@ struct platform_device *of_platform_device_create_pdata(
203 struct device *parent) 203 struct device *parent)
204{ 204{
205 struct platform_device *dev; 205 struct platform_device *dev;
206 int rc;
206 207
207 if (!of_device_is_available(np)) 208 if (!of_device_is_available(np))
208 return NULL; 209 return NULL;
@@ -214,16 +215,24 @@ struct platform_device *of_platform_device_create_pdata(
214#if defined(CONFIG_MICROBLAZE) 215#if defined(CONFIG_MICROBLAZE)
215 dev->archdata.dma_mask = 0xffffffffUL; 216 dev->archdata.dma_mask = 0xffffffffUL;
216#endif 217#endif
218 dev->name = dev_name(&dev->dev);
217 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 219 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
218 dev->dev.bus = &platform_bus_type;
219 dev->dev.platform_data = platform_data; 220 dev->dev.platform_data = platform_data;
221 dev->dev.id = PLATFORM_DEVID_NONE;
222 /* device_add will assume that this device is on the same node as
223 * the parent. If there is no parent defined, set the node
224 * explicitly */
225 if (!parent)
226 set_dev_node(&dev->dev, of_node_to_nid(np));
220 227
221 /* We do not fill the DMA ops for platform devices by default. 228 /* We do not fill the DMA ops for platform devices by default.
222 * This is currently the responsibility of the platform code 229 * This is currently the responsibility of the platform code
223 * to do such, possibly using a device notifier 230 * to do such, possibly using a device notifier
224 */ 231 */
225 232
226 if (of_device_add(dev) != 0) { 233 rc = platform_device_add(dev);
234 if (rc) {
235 dev_err(&dev->dev, "device registration failed\n");
227 platform_device_put(dev); 236 platform_device_put(dev);
228 return NULL; 237 return NULL;
229 } 238 }