aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/of_device.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2008-05-15 21:57:45 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-16 09:22:28 -0400
commit09e67ca2c523544e6b38aa570a5f62a0cf20b87b (patch)
tree134d2ba98b567586dd34ffa7d7f8cfd8fe0de149 /arch/powerpc/kernel/of_device.c
parent7bc228b1ef71f395aeb89bdf81bf95556b08b374 (diff)
[POWERPC] Move of_device_get_modalias to drivers/of
Commit 140b932f8cb6cced10b96860651a198b1b89cbb9 ("Create modalias file in sysfs for of_platform bus") needs this to avoid breaking the sparc builds. Just move the code and add whitespace around some binary operators. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/of_device.c')
-rw-r--r--arch/powerpc/kernel/of_device.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 5748ddb47d9f..e9be908f199b 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -89,54 +89,6 @@ struct of_device *of_device_alloc(struct device_node *np,
89} 89}
90EXPORT_SYMBOL(of_device_alloc); 90EXPORT_SYMBOL(of_device_alloc);
91 91
92ssize_t of_device_get_modalias(struct of_device *ofdev,
93 char *str, ssize_t len)
94{
95 const char *compat;
96 int cplen, i;
97 ssize_t tsize, csize, repend;
98
99 /* Name & Type */
100 csize = snprintf(str, len, "of:N%sT%s",
101 ofdev->node->name, ofdev->node->type);
102
103 /* Get compatible property if any */
104 compat = of_get_property(ofdev->node, "compatible", &cplen);
105 if (!compat)
106 return csize;
107
108 /* Find true end (we tolerate multiple \0 at the end */
109 for (i=(cplen-1); i>=0 && !compat[i]; i--)
110 cplen--;
111 if (!cplen)
112 return csize;
113 cplen++;
114
115 /* Check space (need cplen+1 chars including final \0) */
116 tsize = csize + cplen;
117 repend = tsize;
118
119 if (csize>=len) /* @ the limit, all is already filled */
120 return tsize;
121
122 if (tsize>=len) { /* limit compat list */
123 cplen = len-csize-1;
124 repend = len;
125 }
126
127 /* Copy and do char replacement */
128 memcpy(&str[csize+1], compat, cplen);
129 for (i=csize; i<repend; i++) {
130 char c = str[i];
131 if (c=='\0')
132 str[i] = 'C';
133 else if (c==' ')
134 str[i] = '_';
135 }
136
137 return tsize;
138}
139
140int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) 92int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
141{ 93{
142 struct of_device *ofdev; 94 struct of_device *ofdev;