diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-06-08 09:48:12 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-05 18:14:28 -0400 |
commit | dd27dcda37f0b1a3b674760fb411abc5c8fe309c (patch) | |
tree | f6b582fabc8b4f723f8209102665442fcba53364 /arch/powerpc | |
parent | d3571c3acfabb6f3a93b517b75d9b30eb7e8692e (diff) |
of/device: merge of_device_uevent
Merge common code between powerpc and microblaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Michal Simek <monstr@monstr.eu>
CC: Wolfram Sang <w.sang@pengutronix.de>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: microblaze-uclinux@itee.uq.edu.au
CC: linuxppc-dev@ozlabs.org
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/of_device.h | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/of_device.c | 49 |
2 files changed, 0 insertions, 52 deletions
diff --git a/arch/powerpc/include/asm/of_device.h b/arch/powerpc/include/asm/of_device.h index cb36632f953..5d5103cac64 100644 --- a/arch/powerpc/include/asm/of_device.h +++ b/arch/powerpc/include/asm/of_device.h | |||
@@ -9,8 +9,5 @@ extern struct of_device *of_device_alloc(struct device_node *np, | |||
9 | const char *bus_id, | 9 | const char *bus_id, |
10 | struct device *parent); | 10 | struct device *parent); |
11 | 11 | ||
12 | extern int of_device_uevent(struct device *dev, | ||
13 | struct kobj_uevent_env *env); | ||
14 | |||
15 | #endif /* __KERNEL__ */ | 12 | #endif /* __KERNEL__ */ |
16 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ | 13 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ |
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c index df78e0236a0..db91a9dbafb 100644 --- a/arch/powerpc/kernel/of_device.c +++ b/arch/powerpc/kernel/of_device.c | |||
@@ -82,52 +82,3 @@ struct of_device *of_device_alloc(struct device_node *np, | |||
82 | return dev; | 82 | return dev; |
83 | } | 83 | } |
84 | EXPORT_SYMBOL(of_device_alloc); | 84 | EXPORT_SYMBOL(of_device_alloc); |
85 | |||
86 | int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
87 | { | ||
88 | struct of_device *ofdev; | ||
89 | const char *compat; | ||
90 | int seen = 0, cplen, sl; | ||
91 | |||
92 | if (!dev) | ||
93 | return -ENODEV; | ||
94 | |||
95 | ofdev = to_of_device(dev); | ||
96 | |||
97 | if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name)) | ||
98 | return -ENOMEM; | ||
99 | |||
100 | if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type)) | ||
101 | return -ENOMEM; | ||
102 | |||
103 | /* Since the compatible field can contain pretty much anything | ||
104 | * it's not really legal to split it out with commas. We split it | ||
105 | * up using a number of environment variables instead. */ | ||
106 | |||
107 | compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen); | ||
108 | while (compat && *compat && cplen > 0) { | ||
109 | if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat)) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | sl = strlen (compat) + 1; | ||
113 | compat += sl; | ||
114 | cplen -= sl; | ||
115 | seen++; | ||
116 | } | ||
117 | |||
118 | if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen)) | ||
119 | return -ENOMEM; | ||
120 | |||
121 | /* modalias is trickier, we add it in 2 steps */ | ||
122 | if (add_uevent_var(env, "MODALIAS=")) | ||
123 | return -ENOMEM; | ||
124 | sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1], | ||
125 | sizeof(env->buf) - env->buflen); | ||
126 | if (sl >= (sizeof(env->buf) - env->buflen)) | ||
127 | return -ENOMEM; | ||
128 | env->buflen += sl; | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | EXPORT_SYMBOL(of_device_uevent); | ||
133 | EXPORT_SYMBOL(of_device_get_modalias); | ||