Skip to content

Commit

Permalink
Merge branches 'acpi-utils', 'acpi-platform', 'acpi-video' and 'acpi-…
Browse files Browse the repository at this point in the history
…doc'

* acpi-utils:
  iommu/amd: Switch to use acpi_dev_hid_uid_match()
  mmc: sdhci-acpi: Switch to use acpi_dev_hid_uid_match()
  ACPI / LPSS: Switch to use acpi_dev_hid_uid_match()
  ACPI / utils: Introduce acpi_dev_hid_uid_match() helper
  ACPI / utils: Move acpi_dev_get_first_match_dev() under CONFIG_ACPI
  ACPI / utils: Describe function parameters in kernel-doc

* acpi-platform:
  ACPI: platform: Unregister stale platform devices
  ACPI: Always build evged in

* acpi-video:
  ACPI: video: update doc for acpi_video_bus_DOS()

* acpi-doc:
  ACPI: Documentation: Minor spelling fix in namespace.rst
  • Loading branch information
Rafael J. Wysocki committed Nov 26, 2019
5 parents 1fca7e0 + ae5e6c6 + cb0701a + b5b42b2 + 2e12720 commit 995e2ef
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Documentation/firmware-guide/acpi/namespace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Description Tables contain information used for the creation of the
struct acpi_device objects represented by the given row (xSDT means DSDT
or SSDT).

The forth column of the above table indicates the 'bus_id' generation
The fourth column of the above table indicates the 'bus_id' generation
rule of the struct acpi_device object:

_HID:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ acpi-y += acpi_pnp.o
acpi-$(CONFIG_ARM_AMBA) += acpi_amba.o
acpi-y += power.o
acpi-y += event.o
acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o
acpi-y += evged.o
acpi-y += sysfs.o
acpi-y += property.o
acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
Expand Down
21 changes: 3 additions & 18 deletions drivers/acpi/acpi_lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,31 +499,16 @@ static const struct lpss_device_links lpss_device_links[] = {
{"80860F41", "7", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME},
};

static bool hid_uid_match(struct acpi_device *adev,
const char *hid2, const char *uid2)
{
const char *hid1 = acpi_device_hid(adev);
const char *uid1 = acpi_device_uid(adev);

if (strcmp(hid1, hid2))
return false;

if (!uid2)
return true;

return uid1 && !strcmp(uid1, uid2);
}

static bool acpi_lpss_is_supplier(struct acpi_device *adev,
const struct lpss_device_links *link)
{
return hid_uid_match(adev, link->supplier_hid, link->supplier_uid);
return acpi_dev_hid_uid_match(adev, link->supplier_hid, link->supplier_uid);
}

static bool acpi_lpss_is_consumer(struct acpi_device *adev,
const struct lpss_device_links *link)
{
return hid_uid_match(adev, link->consumer_hid, link->consumer_uid);
return acpi_dev_hid_uid_match(adev, link->consumer_hid, link->consumer_uid);
}

struct hid_uid {
Expand All @@ -539,7 +524,7 @@ static int match_hid_uid(struct device *dev, const void *data)
if (!adev)
return 0;

return hid_uid_match(adev, id->hid, id->uid);
return acpi_dev_hid_uid_match(adev, id->hid, id->uid);
}

static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
Expand Down
43 changes: 43 additions & 0 deletions drivers/acpi/acpi_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,44 @@ static const struct acpi_device_id forbidden_id_list[] = {
{"", 0},
};

static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
{
struct device *dev;

dev = bus_find_device_by_acpi_dev(&platform_bus_type, adev);
return dev ? to_platform_device(dev) : NULL;
}

static int acpi_platform_device_remove_notify(struct notifier_block *nb,
unsigned long value, void *arg)
{
struct acpi_device *adev = arg;
struct platform_device *pdev;

switch (value) {
case ACPI_RECONFIG_DEVICE_ADD:
/* Nothing to do here */
break;
case ACPI_RECONFIG_DEVICE_REMOVE:
if (!acpi_device_enumerated(adev))
break;

pdev = acpi_platform_device_find_by_companion(adev);
if (!pdev)
break;

platform_device_unregister(pdev);
put_device(&pdev->dev);
break;
}

return NOTIFY_OK;
}

static struct notifier_block acpi_platform_notifier = {
.notifier_call = acpi_platform_device_remove_notify,
};

static void acpi_platform_fill_resource(struct acpi_device *adev,
const struct resource *src, struct resource *dest)
{
Expand Down Expand Up @@ -130,3 +168,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
return pdev;
}
EXPORT_SYMBOL_GPL(acpi_create_platform_device);

void __init acpi_platform_init(void)
{
acpi_reconfig_notifier_register(&acpi_platform_notifier);
}
8 changes: 6 additions & 2 deletions drivers/acpi/acpi_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,13 @@ acpi_video_device_EDID(struct acpi_video_device *device,
* event notify code.
* lcd_flag :
* 0. The system BIOS should automatically control the brightness level
* of the LCD when the power changes from AC to DC
* of the LCD when:
* - the power changes from AC to DC (ACPI appendix B)
* - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
* 1. The system BIOS should NOT automatically control the brightness
* level of the LCD when the power changes from AC to DC.
* level of the LCD when:
* - the power changes from AC to DC (ACPI appendix B)
* - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
* Return Value:
* -EINVAL wrong arg.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ int __init acpi_scan_init(void)
acpi_pci_root_init();
acpi_pci_link_init();
acpi_processor_init();
acpi_platform_init();
acpi_lpss_init();
acpi_apd_init();
acpi_cmos_rtc_init();
Expand Down
32 changes: 32 additions & 0 deletions drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ EXPORT_SYMBOL(acpi_evaluate_ost);

/**
* acpi_handle_path: Return the object path of handle
* @handle: ACPI device handle
*
* Caller must free the returned buffer
*/
Expand All @@ -473,6 +474,9 @@ static char *acpi_handle_path(acpi_handle handle)

/**
* acpi_handle_printk: Print message with ACPI prefix and object path
* @level: log level
* @handle: ACPI device handle
* @fmt: format string
*
* This function is called through acpi_handle_<level> macros and prints
* a message with ACPI prefix and object path. This function acquires
Expand Down Expand Up @@ -501,6 +505,9 @@ EXPORT_SYMBOL(acpi_handle_printk);
#if defined(CONFIG_DYNAMIC_DEBUG)
/**
* __acpi_handle_debug: pr_debug with ACPI prefix and object path
* @descriptor: Dynamic Debug descriptor
* @handle: ACPI device handle
* @fmt: format string
*
* This function is called through acpi_handle_debug macro and debug
* prints a message with ACPI prefix and object path. This function
Expand Down Expand Up @@ -694,6 +701,31 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
}
EXPORT_SYMBOL(acpi_check_dsm);

/**
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
* @adev: ACPI device to match.
* @hid2: Hardware ID of the device.
* @uid2: Unique ID of the device, pass NULL to not check _UID.
*
* Matches HID and UID in @adev with given @hid2 and @uid2.
* Returns true if matches.
*/
bool acpi_dev_hid_uid_match(struct acpi_device *adev,
const char *hid2, const char *uid2)
{
const char *hid1 = acpi_device_hid(adev);
const char *uid1 = acpi_device_uid(adev);

if (strcmp(hid1, hid2))
return false;

if (!uid2)
return true;

return uid1 && !strcmp(uid1, uid2);
}
EXPORT_SYMBOL(acpi_dev_hid_uid_match);

/**
* acpi_dev_found - Detect presence of a given ACPI device in the namespace.
* @hid: Hardware ID of the device.
Expand Down
30 changes: 5 additions & 25 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,6 @@ static struct lock_class_key reserved_rbtree_key;
*
****************************************************************************/

static inline int match_hid_uid(struct device *dev,
struct acpihid_map_entry *entry)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
const char *hid, *uid;

if (!adev)
return -ENODEV;

hid = acpi_device_hid(adev);
uid = acpi_device_uid(adev);

if (!hid || !(*hid))
return -ENODEV;

if (!uid || !(*uid))
return strcmp(hid, entry->hid);

if (!(*entry->uid))
return strcmp(hid, entry->hid);

return (strcmp(hid, entry->hid) || strcmp(uid, entry->uid));
}

static inline u16 get_pci_device_id(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
Expand All @@ -158,10 +134,14 @@ static inline u16 get_pci_device_id(struct device *dev)
static inline int get_acpihid_device_id(struct device *dev,
struct acpihid_map_entry **entry)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
struct acpihid_map_entry *p;

if (!adev)
return -ENODEV;

list_for_each_entry(p, &acpihid_map, list) {
if (!match_hid_uid(dev, p)) {
if (acpi_dev_hid_uid_match(adev, p->hid, p->uid)) {
if (entry)
*entry = p;
return p->devid;
Expand Down
Loading

0 comments on commit 995e2ef

Please sign in to comment.