aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/glue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/glue.c')
-rw-r--r--drivers/acpi/glue.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 24649ada08df..5479b9f42513 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -140,6 +140,46 @@ struct device *acpi_get_physical_device(acpi_handle handle)
140 140
141EXPORT_SYMBOL(acpi_get_physical_device); 141EXPORT_SYMBOL(acpi_get_physical_device);
142 142
143/* ToDo: When a PCI bridge is found, return the PCI device behind the bridge
144 * This should work in general, but did not on a Lenovo T61 for the
145 * graphics card. But this must be fixed when the PCI device is
146 * bound and the kernel device struct is attached to the acpi device
147 * Note: A success call will increase reference count by one
148 * Do call put_device(dev) on the returned device then
149 */
150struct device *acpi_get_physical_pci_device(acpi_handle handle)
151{
152 struct device *dev;
153 long long device_id;
154 acpi_status status;
155
156 status =
157 acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
158
159 if (ACPI_FAILURE(status))
160 return NULL;
161
162 /* We need to attempt to determine whether the _ADR refers to a
163 PCI device or not. There's no terribly good way to do this,
164 so the best we can hope for is to assume that there'll never
165 be a device in the host bridge */
166 if (device_id >= 0x10000) {
167 /* It looks like a PCI device. Does it exist? */
168 dev = acpi_get_physical_device(handle);
169 } else {
170 /* It doesn't look like a PCI device. Does its parent
171 exist? */
172 acpi_handle phandle;
173 if (acpi_get_parent(handle, &phandle))
174 return NULL;
175 dev = acpi_get_physical_device(phandle);
176 }
177 if (!dev)
178 return NULL;
179 return dev;
180}
181EXPORT_SYMBOL(acpi_get_physical_pci_device);
182
143static int acpi_bind_one(struct device *dev, acpi_handle handle) 183static int acpi_bind_one(struct device *dev, acpi_handle handle)
144{ 184{
145 struct acpi_device *acpi_dev; 185 struct acpi_device *acpi_dev;
@@ -215,12 +255,12 @@ static int acpi_platform_notify(struct device *dev)
215 } 255 }
216 type = acpi_get_bus_type(dev->bus); 256 type = acpi_get_bus_type(dev->bus);
217 if (!type) { 257 if (!type) {
218 DBG("No ACPI bus support for %s\n", dev->bus_id); 258 DBG("No ACPI bus support for %s\n", dev_name(dev));
219 ret = -EINVAL; 259 ret = -EINVAL;
220 goto end; 260 goto end;
221 } 261 }
222 if ((ret = type->find_device(dev, &handle)) != 0) 262 if ((ret = type->find_device(dev, &handle)) != 0)
223 DBG("Can't get handler for %s\n", dev->bus_id); 263 DBG("Can't get handler for %s\n", dev_name(dev));
224 end: 264 end:
225 if (!ret) 265 if (!ret)
226 acpi_bind_one(dev, handle); 266 acpi_bind_one(dev, handle);
@@ -231,10 +271,10 @@ static int acpi_platform_notify(struct device *dev)
231 271
232 acpi_get_name(dev->archdata.acpi_handle, 272 acpi_get_name(dev->archdata.acpi_handle,
233 ACPI_FULL_PATHNAME, &buffer); 273 ACPI_FULL_PATHNAME, &buffer);
234 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); 274 DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer);
235 kfree(buffer.pointer); 275 kfree(buffer.pointer);
236 } else 276 } else
237 DBG("Device %s -> No ACPI support\n", dev->bus_id); 277 DBG("Device %s -> No ACPI support\n", dev_name(dev));
238#endif 278#endif
239 279
240 return ret; 280 return ret;