diff options
Diffstat (limited to 'drivers/macintosh/macio_asic.c')
-rw-r--r-- | drivers/macintosh/macio_asic.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 7fa369cfcceb..1ee003346923 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
@@ -126,11 +126,82 @@ static int macio_device_resume(struct device * dev) | |||
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | static 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 | |||
129 | extern struct device_attribute macio_dev_attrs[]; | 199 | extern struct device_attribute macio_dev_attrs[]; |
130 | 200 | ||
131 | struct bus_type macio_bus_type = { | 201 | struct bus_type macio_bus_type = { |
132 | .name = "macio", | 202 | .name = "macio", |
133 | .match = macio_bus_match, | 203 | .match = macio_bus_match, |
204 | .hotplug = macio_hotplug, | ||
134 | .suspend = macio_device_suspend, | 205 | .suspend = macio_device_suspend, |
135 | .resume = macio_device_resume, | 206 | .resume = macio_device_resume, |
136 | .dev_attrs = macio_dev_attrs, | 207 | .dev_attrs = macio_dev_attrs, |