aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/macio_asic.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-07-07 06:08:27 -0400
committerDave Airlie <airlied@linux.ie>2005-07-07 06:08:27 -0400
commit717cb906bd43a9ac00631d600adda5c6546843a6 (patch)
treef41b250e9e0fa1e664f002fa9c4608d94527f2f2 /drivers/macintosh/macio_asic.c
parent22f579c621e2f264e6d093b07d75f99bc97d5df2 (diff)
parentc101f3136cc98a003d0d16be6fab7d0d950581a6 (diff)
Merge ../linux-2.6/
Diffstat (limited to 'drivers/macintosh/macio_asic.c')
-rw-r--r--drivers/macintosh/macio_asic.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d0bda7e3e6aa..1ee003346923 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -33,7 +33,7 @@ static int macio_bus_match(struct device *dev, struct device_driver *drv)
33{ 33{
34 struct macio_dev * macio_dev = to_macio_device(dev); 34 struct macio_dev * macio_dev = to_macio_device(dev);
35 struct macio_driver * macio_drv = to_macio_driver(drv); 35 struct macio_driver * macio_drv = to_macio_driver(drv);
36 const struct of_match * matches = macio_drv->match_table; 36 const struct of_device_id * matches = macio_drv->match_table;
37 37
38 if (!matches) 38 if (!matches)
39 return 0; 39 return 0;
@@ -66,7 +66,7 @@ static int macio_device_probe(struct device *dev)
66 int error = -ENODEV; 66 int error = -ENODEV;
67 struct macio_driver *drv; 67 struct macio_driver *drv;
68 struct macio_dev *macio_dev; 68 struct macio_dev *macio_dev;
69 const struct of_match *match; 69 const struct of_device_id *match;
70 70
71 drv = to_macio_driver(dev->driver); 71 drv = to_macio_driver(dev->driver);
72 macio_dev = to_macio_device(dev); 72 macio_dev = to_macio_device(dev);
@@ -126,11 +126,85 @@ static int macio_device_resume(struct device * dev)
126 return 0; 126 return 0;
127} 127}
128 128
129static int macio_hotplug (struct device *dev, char **envp, int num_envp,
130 char *buffer, int buffer_size)
131{
132 struct macio_dev * macio_dev;
133 struct of_device * of;
134 char *scratch, *compat;
135 int i = 0;
136 int length = 0;
137 int cplen, seen = 0;
138
139 if (!dev)
140 return -ENODEV;
141
142 macio_dev = to_macio_device(dev);
143 if (!macio_dev)
144 return -ENODEV;
145
146 of = &macio_dev->ofdev;
147 scratch = buffer;
148
149 /* stuff we want to pass to /sbin/hotplug */
150 envp[i++] = scratch;
151 length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
152 of->node->name);
153 if ((buffer_size - length <= 0) || (i >= num_envp))
154 return -ENOMEM;
155 ++length;
156 scratch += length;
157
158 envp[i++] = scratch;
159 length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
160 of->node->type);
161 if ((buffer_size - length <= 0) || (i >= num_envp))
162 return -ENOMEM;
163 ++length;
164 scratch += length;
165
166 /* Since the compatible field can contain pretty much anything
167 * it's not really legal to split it out with commas. We split it
168 * up using a number of environment variables instead. */
169
170 compat = (char *) get_property(of->node, "compatible", &cplen);
171 while (compat && cplen > 0) {
172 int l;
173 envp[i++] = scratch;
174 length += scnprintf (scratch, buffer_size - length,
175 "OF_COMPATIBLE_%d=%s", seen, compat);
176 if ((buffer_size - length <= 0) || (i >= num_envp))
177 return -ENOMEM;
178 length++;
179 scratch += length;
180 l = strlen (compat) + 1;
181 compat += l;
182 cplen -= l;
183 seen++;
184 }
185
186 envp[i++] = scratch;
187 length += scnprintf (scratch, buffer_size - length,
188 "OF_COMPATIBLE_N=%d", seen);
189 if ((buffer_size - length <= 0) || (i >= num_envp))
190 return -ENOMEM;
191 ++length;
192 scratch += length;
193
194 envp[i] = NULL;
195
196 return 0;
197}
198
199extern struct device_attribute macio_dev_attrs[];
200
129struct bus_type macio_bus_type = { 201struct bus_type macio_bus_type = {
130 .name = "macio", 202 .name = "macio",
131 .match = macio_bus_match, 203 .match = macio_bus_match,
204 .hotplug = macio_hotplug,
132 .suspend = macio_device_suspend, 205 .suspend = macio_device_suspend,
133 .resume = macio_device_resume, 206 .resume = macio_device_resume,
207 .dev_attrs = macio_dev_attrs,
134}; 208};
135 209
136static int __init macio_bus_driver_init(void) 210static int __init macio_bus_driver_init(void)