Skip to content

Commit 995e2ef

Browse files
committed
Merge branches 'acpi-utils', 'acpi-platform', 'acpi-video' and 'acpi-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
5 parents 1fca7e0 + ae5e6c6 + cb0701a + b5b42b2 + 2e12720 commit 995e2ef

File tree

11 files changed

+121
-83
lines changed

11 files changed

+121
-83
lines changed

Documentation/firmware-guide/acpi/namespace.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Description Tables contain information used for the creation of the
261261
struct acpi_device objects represented by the given row (xSDT means DSDT
262262
or SSDT).
263263

264-
The forth column of the above table indicates the 'bus_id' generation
264+
The fourth column of the above table indicates the 'bus_id' generation
265265
rule of the struct acpi_device object:
266266

267267
_HID:

drivers/acpi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ acpi-y += acpi_pnp.o
4848
acpi-$(CONFIG_ARM_AMBA) += acpi_amba.o
4949
acpi-y += power.o
5050
acpi-y += event.o
51-
acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o
51+
acpi-y += evged.o
5252
acpi-y += sysfs.o
5353
acpi-y += property.o
5454
acpi-$(CONFIG_X86) += acpi_cmos_rtc.o

drivers/acpi/acpi_lpss.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -499,31 +499,16 @@ static const struct lpss_device_links lpss_device_links[] = {
499499
{"80860F41", "7", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME},
500500
};
501501

502-
static bool hid_uid_match(struct acpi_device *adev,
503-
const char *hid2, const char *uid2)
504-
{
505-
const char *hid1 = acpi_device_hid(adev);
506-
const char *uid1 = acpi_device_uid(adev);
507-
508-
if (strcmp(hid1, hid2))
509-
return false;
510-
511-
if (!uid2)
512-
return true;
513-
514-
return uid1 && !strcmp(uid1, uid2);
515-
}
516-
517502
static bool acpi_lpss_is_supplier(struct acpi_device *adev,
518503
const struct lpss_device_links *link)
519504
{
520-
return hid_uid_match(adev, link->supplier_hid, link->supplier_uid);
505+
return acpi_dev_hid_uid_match(adev, link->supplier_hid, link->supplier_uid);
521506
}
522507

523508
static bool acpi_lpss_is_consumer(struct acpi_device *adev,
524509
const struct lpss_device_links *link)
525510
{
526-
return hid_uid_match(adev, link->consumer_hid, link->consumer_uid);
511+
return acpi_dev_hid_uid_match(adev, link->consumer_hid, link->consumer_uid);
527512
}
528513

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

542-
return hid_uid_match(adev, id->hid, id->uid);
527+
return acpi_dev_hid_uid_match(adev, id->hid, id->uid);
543528
}
544529

545530
static struct device *acpi_lpss_find_device(const char *hid, const char *uid)

drivers/acpi/acpi_platform.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,44 @@ static const struct acpi_device_id forbidden_id_list[] = {
3131
{"", 0},
3232
};
3333

34+
static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
35+
{
36+
struct device *dev;
37+
38+
dev = bus_find_device_by_acpi_dev(&platform_bus_type, adev);
39+
return dev ? to_platform_device(dev) : NULL;
40+
}
41+
42+
static int acpi_platform_device_remove_notify(struct notifier_block *nb,
43+
unsigned long value, void *arg)
44+
{
45+
struct acpi_device *adev = arg;
46+
struct platform_device *pdev;
47+
48+
switch (value) {
49+
case ACPI_RECONFIG_DEVICE_ADD:
50+
/* Nothing to do here */
51+
break;
52+
case ACPI_RECONFIG_DEVICE_REMOVE:
53+
if (!acpi_device_enumerated(adev))
54+
break;
55+
56+
pdev = acpi_platform_device_find_by_companion(adev);
57+
if (!pdev)
58+
break;
59+
60+
platform_device_unregister(pdev);
61+
put_device(&pdev->dev);
62+
break;
63+
}
64+
65+
return NOTIFY_OK;
66+
}
67+
68+
static struct notifier_block acpi_platform_notifier = {
69+
.notifier_call = acpi_platform_device_remove_notify,
70+
};
71+
3472
static void acpi_platform_fill_resource(struct acpi_device *adev,
3573
const struct resource *src, struct resource *dest)
3674
{
@@ -130,3 +168,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
130168
return pdev;
131169
}
132170
EXPORT_SYMBOL_GPL(acpi_create_platform_device);
171+
172+
void __init acpi_platform_init(void)
173+
{
174+
acpi_reconfig_notifier_register(&acpi_platform_notifier);
175+
}

drivers/acpi/acpi_video.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,13 @@ acpi_video_device_EDID(struct acpi_video_device *device,
699699
* event notify code.
700700
* lcd_flag :
701701
* 0. The system BIOS should automatically control the brightness level
702-
* of the LCD when the power changes from AC to DC
702+
* of the LCD when:
703+
* - the power changes from AC to DC (ACPI appendix B)
704+
* - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
703705
* 1. The system BIOS should NOT automatically control the brightness
704-
* level of the LCD when the power changes from AC to DC.
706+
* level of the LCD when:
707+
* - the power changes from AC to DC (ACPI appendix B)
708+
* - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
705709
* Return Value:
706710
* -EINVAL wrong arg.
707711
*/

drivers/acpi/scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,7 @@ int __init acpi_scan_init(void)
21742174
acpi_pci_root_init();
21752175
acpi_pci_link_init();
21762176
acpi_processor_init();
2177+
acpi_platform_init();
21772178
acpi_lpss_init();
21782179
acpi_apd_init();
21792180
acpi_cmos_rtc_init();

drivers/acpi/utils.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ EXPORT_SYMBOL(acpi_evaluate_ost);
455455

456456
/**
457457
* acpi_handle_path: Return the object path of handle
458+
* @handle: ACPI device handle
458459
*
459460
* Caller must free the returned buffer
460461
*/
@@ -473,6 +474,9 @@ static char *acpi_handle_path(acpi_handle handle)
473474

474475
/**
475476
* acpi_handle_printk: Print message with ACPI prefix and object path
477+
* @level: log level
478+
* @handle: ACPI device handle
479+
* @fmt: format string
476480
*
477481
* This function is called through acpi_handle_<level> macros and prints
478482
* a message with ACPI prefix and object path. This function acquires
@@ -501,6 +505,9 @@ EXPORT_SYMBOL(acpi_handle_printk);
501505
#if defined(CONFIG_DYNAMIC_DEBUG)
502506
/**
503507
* __acpi_handle_debug: pr_debug with ACPI prefix and object path
508+
* @descriptor: Dynamic Debug descriptor
509+
* @handle: ACPI device handle
510+
* @fmt: format string
504511
*
505512
* This function is called through acpi_handle_debug macro and debug
506513
* prints a message with ACPI prefix and object path. This function
@@ -694,6 +701,31 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
694701
}
695702
EXPORT_SYMBOL(acpi_check_dsm);
696703

704+
/**
705+
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
706+
* @adev: ACPI device to match.
707+
* @hid2: Hardware ID of the device.
708+
* @uid2: Unique ID of the device, pass NULL to not check _UID.
709+
*
710+
* Matches HID and UID in @adev with given @hid2 and @uid2.
711+
* Returns true if matches.
712+
*/
713+
bool acpi_dev_hid_uid_match(struct acpi_device *adev,
714+
const char *hid2, const char *uid2)
715+
{
716+
const char *hid1 = acpi_device_hid(adev);
717+
const char *uid1 = acpi_device_uid(adev);
718+
719+
if (strcmp(hid1, hid2))
720+
return false;
721+
722+
if (!uid2)
723+
return true;
724+
725+
return uid1 && !strcmp(uid1, uid2);
726+
}
727+
EXPORT_SYMBOL(acpi_dev_hid_uid_match);
728+
697729
/**
698730
* acpi_dev_found - Detect presence of a given ACPI device in the namespace.
699731
* @hid: Hardware ID of the device.

drivers/iommu/amd_iommu.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ static struct lock_class_key reserved_rbtree_key;
124124
*
125125
****************************************************************************/
126126

127-
static inline int match_hid_uid(struct device *dev,
128-
struct acpihid_map_entry *entry)
129-
{
130-
struct acpi_device *adev = ACPI_COMPANION(dev);
131-
const char *hid, *uid;
132-
133-
if (!adev)
134-
return -ENODEV;
135-
136-
hid = acpi_device_hid(adev);
137-
uid = acpi_device_uid(adev);
138-
139-
if (!hid || !(*hid))
140-
return -ENODEV;
141-
142-
if (!uid || !(*uid))
143-
return strcmp(hid, entry->hid);
144-
145-
if (!(*entry->uid))
146-
return strcmp(hid, entry->hid);
147-
148-
return (strcmp(hid, entry->hid) || strcmp(uid, entry->uid));
149-
}
150-
151127
static inline u16 get_pci_device_id(struct device *dev)
152128
{
153129
struct pci_dev *pdev = to_pci_dev(dev);
@@ -158,10 +134,14 @@ static inline u16 get_pci_device_id(struct device *dev)
158134
static inline int get_acpihid_device_id(struct device *dev,
159135
struct acpihid_map_entry **entry)
160136
{
137+
struct acpi_device *adev = ACPI_COMPANION(dev);
161138
struct acpihid_map_entry *p;
162139

140+
if (!adev)
141+
return -ENODEV;
142+
163143
list_for_each_entry(p, &acpihid_map, list) {
164-
if (!match_hid_uid(dev, p)) {
144+
if (acpi_dev_hid_uid_match(adev, p->hid, p->uid)) {
165145
if (entry)
166146
*entry = p;
167147
return p->devid;

0 commit comments

Comments
 (0)