Skip to content

Commit 882c982

Browse files
Heikki Krogerusgregkh
authored andcommitted
acpi: Store CRC-32 hash of the _PLD in struct acpi_device
Storing CRC-32 hash of the Physical Location of Device object (_PLD) with devices that have it. The hash is stored to a new struct acpi_device member "pld_crc". The hash makes it easier to find devices that share a location, as there is no need to evaluate the entire object every time. Knowledge about devices that share a location can be used in device drivers that need to know the connections to other components inside a system. USB3 ports will for example always share their location with a USB2 port. Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 13068b7 commit 882c982

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/acpi/scan.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/dma-map-ops.h>
2020
#include <linux/platform_data/x86/apple.h>
2121
#include <linux/pgtable.h>
22+
#include <linux/crc32.h>
2223

2324
#include "internal.h"
2425

@@ -654,6 +655,19 @@ static int acpi_tie_acpi_dev(struct acpi_device *adev)
654655
return 0;
655656
}
656657

658+
static void acpi_store_pld_crc(struct acpi_device *adev)
659+
{
660+
struct acpi_pld_info *pld;
661+
acpi_status status;
662+
663+
status = acpi_get_physical_device_location(adev->handle, &pld);
664+
if (ACPI_FAILURE(status))
665+
return;
666+
667+
adev->pld_crc = crc32(~0, pld, sizeof(*pld));
668+
ACPI_FREE(pld);
669+
}
670+
657671
static int __acpi_device_add(struct acpi_device *device,
658672
void (*release)(struct device *))
659673
{
@@ -712,6 +726,8 @@ static int __acpi_device_add(struct acpi_device *device,
712726
if (device->wakeup.flags.valid)
713727
list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
714728

729+
acpi_store_pld_crc(device);
730+
715731
mutex_unlock(&acpi_device_lock);
716732

717733
if (device->parent)

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ struct acpi_gpio_mapping;
358358

359359
/* Device */
360360
struct acpi_device {
361+
u32 pld_crc;
361362
int device_type;
362363
acpi_handle handle; /* no handle for fixed hardware */
363364
struct fwnode_handle fwnode;

0 commit comments

Comments
 (0)