Commit b10b977b792bb28c03267e00562c8254dca50f36

Authored by Len Brown

Merge branch 'pnpacpi-invalid-device-id' into release

Showing 1 changed file Side-by-side Diff

drivers/pnp/pnpacpi/core.c
... ... @@ -28,7 +28,7 @@
28 28 #include "../base.h"
29 29 #include "pnpacpi.h"
30 30  
31   -static int num = 0;
  31 +static int num;
32 32  
33 33 /* We need only to blacklist devices that have already an acpi driver that
34 34 * can't use pnp layer. We don't need to blacklist device that are directly
35 35  
... ... @@ -180,11 +180,24 @@
180 180 };
181 181 EXPORT_SYMBOL(pnpacpi_protocol);
182 182  
  183 +static char *pnpacpi_get_id(struct acpi_device *device)
  184 +{
  185 + struct acpi_hardware_id *id;
  186 +
  187 + list_for_each_entry(id, &device->pnp.ids, list) {
  188 + if (ispnpidacpi(id->id))
  189 + return id->id;
  190 + }
  191 +
  192 + return NULL;
  193 +}
  194 +
183 195 static int __init pnpacpi_add_device(struct acpi_device *device)
184 196 {
185 197 acpi_handle temp = NULL;
186 198 acpi_status status;
187 199 struct pnp_dev *dev;
  200 + char *pnpid;
188 201 struct acpi_hardware_id *id;
189 202  
190 203 /*
191 204  
... ... @@ -192,11 +205,17 @@
192 205 * driver should not be loaded.
193 206 */
194 207 status = acpi_get_handle(device->handle, "_CRS", &temp);
195   - if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
196   - is_exclusive_device(device) || (!device->status.present))
  208 + if (ACPI_FAILURE(status))
197 209 return 0;
198 210  
199   - dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
  211 + pnpid = pnpacpi_get_id(device);
  212 + if (!pnpid)
  213 + return 0;
  214 +
  215 + if (is_exclusive_device(device) || !device->status.present)
  216 + return 0;
  217 +
  218 + dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
200 219 if (!dev)
201 220 return -ENOMEM;
202 221  
... ... @@ -227,7 +246,7 @@
227 246 pnpacpi_parse_resource_option_data(dev);
228 247  
229 248 list_for_each_entry(id, &device->pnp.ids, list) {
230   - if (!strcmp(id->id, acpi_device_hid(device)))
  249 + if (!strcmp(id->id, pnpid))
231 250 continue;
232 251 if (!ispnpidacpi(id->id))
233 252 continue;