Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336615
b: refs/heads/master
c: cf761af
h: refs/heads/master
i:
  336613: c292dae
  336611: 6baa1e6
  336607: d24d8b2
v: v3
  • Loading branch information
Mika Westerberg authored and Rafael J. Wysocki committed Nov 14, 2012
1 parent 8f20ab2 commit 65ed381
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 06f64c8f239a47b359c60301914c783b56b32c13
refs/heads/master: cf761af9ee0f2c172710ad2b7ca029016b5d4c45
40 changes: 35 additions & 5 deletions trunk/drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
ACPI Bus operations
-------------------------------------------------------------------------- */

int acpi_match_device_ids(struct acpi_device *device,
const struct acpi_device_id *ids)
static const struct acpi_device_id *__acpi_match_device(
struct acpi_device *device, const struct acpi_device_id *ids)
{
const struct acpi_device_id *id;
struct acpi_hardware_id *hwid;
Expand All @@ -351,14 +351,44 @@ int acpi_match_device_ids(struct acpi_device *device,
* driver for it.
*/
if (!device->status.present)
return -ENODEV;
return NULL;

for (id = ids; id->id[0]; id++)
list_for_each_entry(hwid, &device->pnp.ids, list)
if (!strcmp((char *) id->id, hwid->id))
return 0;
return id;

return NULL;
}

return -ENOENT;
/**
* acpi_match_device - Match a struct device against a given list of ACPI IDs
* @ids: Array of struct acpi_device_id object to match against.
* @dev: The device structure to match.
*
* Check if @dev has a valid ACPI handle and if there is a struct acpi_device
* object for that handle and use that object to match against a given list of
* device IDs.
*
* Return a pointer to the first matching ID on success or %NULL on failure.
*/
const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
const struct device *dev)
{
struct acpi_device *adev;

if (!ids || !dev->acpi_handle
|| ACPI_FAILURE(acpi_bus_get_device(dev->acpi_handle, &adev)))
return NULL;

return __acpi_match_device(adev, ids);
}
EXPORT_SYMBOL_GPL(acpi_match_device);

int acpi_match_device_ids(struct acpi_device *device,
const struct acpi_device_id *ids)
{
return __acpi_match_device(device, ids) ? 0 : -ENOENT;
}
EXPORT_SYMBOL(acpi_match_device_ids);

Expand Down
28 changes: 28 additions & 0 deletions trunk/include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define _LINUX_ACPI_H

#include <linux/ioport.h> /* for struct resource */
#include <linux/device.h>

#ifdef CONFIG_ACPI

Expand Down Expand Up @@ -364,6 +365,17 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
void *data);

const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
const struct device *dev);

static inline bool acpi_driver_match_device(struct device *dev,
const struct device_driver *drv)
{
return !!acpi_match_device(drv->acpi_match_table, dev);
}

#define ACPI_PTR(_ptr) (_ptr)

#else /* !CONFIG_ACPI */

#define acpi_disabled 1
Expand Down Expand Up @@ -418,6 +430,22 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
return 0;
}

struct acpi_device_id;

static inline const struct acpi_device_id *acpi_match_device(
const struct acpi_device_id *ids, const struct device *dev)
{
return NULL;
}

static inline bool acpi_driver_match_device(struct device *dev,
const struct device_driver *drv)
{
return false;
}

#define ACPI_PTR(_ptr) (NULL)

#endif /* !CONFIG_ACPI */

#ifdef CONFIG_ACPI
Expand Down

0 comments on commit 65ed381

Please sign in to comment.