Skip to content

Commit

Permalink
Merge branch 'pnpacpi-invalid-device-id' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed Oct 25, 2010
2 parents 22156ea + 420a0f6 commit b10b977
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions drivers/pnp/pnpacpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../base.h"
#include "pnpacpi.h"

static int num = 0;
static int num;

/* We need only to blacklist devices that have already an acpi driver that
* can't use pnp layer. We don't need to blacklist device that are directly
Expand Down Expand Up @@ -180,23 +180,42 @@ struct pnp_protocol pnpacpi_protocol = {
};
EXPORT_SYMBOL(pnpacpi_protocol);

static char *pnpacpi_get_id(struct acpi_device *device)
{
struct acpi_hardware_id *id;

list_for_each_entry(id, &device->pnp.ids, list) {
if (ispnpidacpi(id->id))
return id->id;
}

return NULL;
}

static int __init pnpacpi_add_device(struct acpi_device *device)
{
acpi_handle temp = NULL;
acpi_status status;
struct pnp_dev *dev;
char *pnpid;
struct acpi_hardware_id *id;

/*
* If a PnPacpi device is not present , the device
* driver should not be loaded.
*/
status = acpi_get_handle(device->handle, "_CRS", &temp);
if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
is_exclusive_device(device) || (!device->status.present))
if (ACPI_FAILURE(status))
return 0;

pnpid = pnpacpi_get_id(device);
if (!pnpid)
return 0;

if (is_exclusive_device(device) || !device->status.present)
return 0;

dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
if (!dev)
return -ENOMEM;

Expand Down Expand Up @@ -227,7 +246,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
pnpacpi_parse_resource_option_data(dev);

list_for_each_entry(id, &device->pnp.ids, list) {
if (!strcmp(id->id, acpi_device_hid(device)))
if (!strcmp(id->id, pnpid))
continue;
if (!ispnpidacpi(id->id))
continue;
Expand Down

0 comments on commit b10b977

Please sign in to comment.