Skip to content

Commit 94e0d43

Browse files
committed
Merge tag 'acpi-6.5-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more ACPI updates from Rafael Wysocki: "These fix a couple of compiler warnings, refine an ACPI device enumeration quirk to address a driver regression and clean up code. Specifics: - Make acpi_companion_match() return a const pointer and update its callers accordingly (Andy Shevchenko) - Move the extern declaration of the acpi_root variable to a header file so as to address a compiler warning (Andy Shevchenko) - Address compiler warnings in the ACPI device enumeration code by adding a missing header file include to it (Ben Dooks) - Refine the SMB0001 quirk in the ACPI device enumeration code so as to address an i2c-scmi driver regression (Andy Shevchenko) - Clean up two pieces of the ACPI device enumeration code (Andy Shevchenko)" * tag 'acpi-6.5-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: scan: Use the acpi_match_acpi_device() helper ACPI: platform: Move SMB0001 HID to the header and reuse ACPI: platform: Ignore SMB0001 only when it has resources ACPI: bus: Introduce acpi_match_acpi_device() helper ACPI: scan: fix undeclared variable warnings by including sleep.h ACPI: bus: Constify acpi_companion_match() returned value ACPI: scan: Move acpi_root to internal header
2 parents 7210de3 + 2e178ee commit 94e0d43

File tree

8 files changed

+80
-26
lines changed

8 files changed

+80
-26
lines changed

drivers/acpi/acpi_platform.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/acpi.h>
12+
#include <linux/bits.h>
1213
#include <linux/device.h>
1314
#include <linux/err.h>
1415
#include <linux/kernel.h>
@@ -19,13 +20,16 @@
1920

2021
#include "internal.h"
2122

23+
/* Exclude devices that have no _CRS resources provided */
24+
#define ACPI_ALLOW_WO_RESOURCES BIT(0)
25+
2226
static const struct acpi_device_id forbidden_id_list[] = {
2327
{"ACPI0009", 0}, /* IOxAPIC */
2428
{"ACPI000A", 0}, /* IOAPIC */
2529
{"PNP0000", 0}, /* PIC */
2630
{"PNP0100", 0}, /* Timer */
2731
{"PNP0200", 0}, /* AT DMA Controller */
28-
{"SMB0001", 0}, /* ACPI SMBUS virtual device */
32+
{ACPI_SMBUS_MS_HID, ACPI_ALLOW_WO_RESOURCES}, /* ACPI SMBUS virtual device */
2933
{ }
3034
};
3135

@@ -83,6 +87,15 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
8387
dest->parent = pci_find_resource(to_pci_dev(parent), dest);
8488
}
8589

90+
static unsigned int acpi_platform_resource_count(struct acpi_resource *ares, void *data)
91+
{
92+
bool *has_resources = data;
93+
94+
*has_resources = true;
95+
96+
return AE_CTRL_TERMINATE;
97+
}
98+
8699
/**
87100
* acpi_create_platform_device - Create platform device for ACPI device node
88101
* @adev: ACPI device node to create a platform device for.
@@ -100,6 +113,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
100113
struct acpi_device *parent = acpi_dev_parent(adev);
101114
struct platform_device *pdev = NULL;
102115
struct platform_device_info pdevinfo;
116+
const struct acpi_device_id *match;
103117
struct resource_entry *rentry;
104118
struct list_head resource_list;
105119
struct resource *resources = NULL;
@@ -109,8 +123,19 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
109123
if (adev->physical_node_count)
110124
return NULL;
111125

112-
if (!acpi_match_device_ids(adev, forbidden_id_list))
113-
return ERR_PTR(-EINVAL);
126+
match = acpi_match_acpi_device(forbidden_id_list, adev);
127+
if (match) {
128+
if (match->driver_data & ACPI_ALLOW_WO_RESOURCES) {
129+
bool has_resources = false;
130+
131+
acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
132+
acpi_platform_resource_count, &has_resources);
133+
if (has_resources)
134+
return ERR_PTR(-EINVAL);
135+
} else {
136+
return ERR_PTR(-EINVAL);
137+
}
138+
}
114139

115140
INIT_LIST_HEAD(&resource_list);
116141
count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);

drivers/acpi/bus.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ bool acpi_device_is_first_physical_node(struct acpi_device *adev,
682682
* resources available from it but they will be matched normally using functions
683683
* provided by their bus types (and analogously for their modalias).
684684
*/
685-
struct acpi_device *acpi_companion_match(const struct device *dev)
685+
const struct acpi_device *acpi_companion_match(const struct device *dev)
686686
{
687687
struct acpi_device *adev;
688688

@@ -706,7 +706,7 @@ struct acpi_device *acpi_companion_match(const struct device *dev)
706706
* identifiers and a _DSD object with the "compatible" property, use that
707707
* property to match against the given list of identifiers.
708708
*/
709-
static bool acpi_of_match_device(struct acpi_device *adev,
709+
static bool acpi_of_match_device(const struct acpi_device *adev,
710710
const struct of_device_id *of_match_table,
711711
const struct of_device_id **of_id)
712712
{
@@ -808,7 +808,7 @@ static bool __acpi_match_device_cls(const struct acpi_device_id *id,
808808
return true;
809809
}
810810

811-
static bool __acpi_match_device(struct acpi_device *device,
811+
static bool __acpi_match_device(const struct acpi_device *device,
812812
const struct acpi_device_id *acpi_ids,
813813
const struct of_device_id *of_ids,
814814
const struct acpi_device_id **acpi_id,
@@ -850,6 +850,26 @@ static bool __acpi_match_device(struct acpi_device *device,
850850
return true;
851851
}
852852

853+
/**
854+
* acpi_match_acpi_device - Match an ACPI device against a given list of ACPI IDs
855+
* @ids: Array of struct acpi_device_id objects to match against.
856+
* @adev: The ACPI device pointer to match.
857+
*
858+
* Match the ACPI device @adev against a given list of ACPI IDs @ids.
859+
*
860+
* Return:
861+
* a pointer to the first matching ACPI ID on success or %NULL on failure.
862+
*/
863+
const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
864+
const struct acpi_device *adev)
865+
{
866+
const struct acpi_device_id *id = NULL;
867+
868+
__acpi_match_device(adev, ids, NULL, &id, NULL);
869+
return id;
870+
}
871+
EXPORT_SYMBOL_GPL(acpi_match_acpi_device);
872+
853873
/**
854874
* acpi_match_device - Match a struct device against a given list of ACPI IDs
855875
* @ids: Array of struct acpi_device_id object to match against.
@@ -864,10 +884,7 @@ static bool __acpi_match_device(struct acpi_device *device,
864884
const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
865885
const struct device *dev)
866886
{
867-
const struct acpi_device_id *id = NULL;
868-
869-
__acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL);
870-
return id;
887+
return acpi_match_acpi_device(ids, acpi_companion_match(dev));
871888
}
872889
EXPORT_SYMBOL_GPL(acpi_match_device);
873890

drivers/acpi/device_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env
283283
}
284284
EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
285285

286-
static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
286+
static int __acpi_device_modalias(const struct acpi_device *adev, char *buf, int size)
287287
{
288288
int len, count;
289289

drivers/acpi/internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <linux/idr.h>
1313

14+
extern struct acpi_device *acpi_root;
15+
1416
int early_acpi_osi_init(void);
1517
int acpi_osi_init(void);
1618
acpi_status acpi_os_initialize1(void);
@@ -119,7 +121,7 @@ int acpi_bus_register_early_device(int type);
119121
/* --------------------------------------------------------------------------
120122
Device Matching and Notification
121123
-------------------------------------------------------------------------- */
122-
struct acpi_device *acpi_companion_match(const struct device *dev);
124+
const struct acpi_device *acpi_companion_match(const struct device *dev);
123125
int __acpi_device_uevent_modalias(const struct acpi_device *adev,
124126
struct kobj_uevent_env *env);
125127

drivers/acpi/scan.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include <linux/dma-direct.h>
2424

2525
#include "internal.h"
26-
27-
extern struct acpi_device *acpi_root;
26+
#include "sleep.h"
2827

2928
#define ACPI_BUS_CLASS "system_bus"
3029
#define ACPI_BUS_HID "LNXSYBUS"
@@ -930,26 +929,29 @@ static int acpi_bus_extract_wakeup_device_power_package(struct acpi_device *dev)
930929
return err;
931930
}
932931

932+
/* Do not use a button for S5 wakeup */
933+
#define ACPI_AVOID_WAKE_FROM_S5 BIT(0)
934+
933935
static bool acpi_wakeup_gpe_init(struct acpi_device *device)
934936
{
935937
static const struct acpi_device_id button_device_ids[] = {
936-
{"PNP0C0C", 0}, /* Power button */
937-
{"PNP0C0D", 0}, /* Lid */
938-
{"PNP0C0E", 0}, /* Sleep button */
938+
{"PNP0C0C", 0}, /* Power button */
939+
{"PNP0C0D", ACPI_AVOID_WAKE_FROM_S5}, /* Lid */
940+
{"PNP0C0E", ACPI_AVOID_WAKE_FROM_S5}, /* Sleep button */
939941
{"", 0},
940942
};
941943
struct acpi_device_wakeup *wakeup = &device->wakeup;
944+
const struct acpi_device_id *match;
942945
acpi_status status;
943946

944947
wakeup->flags.notifier_present = 0;
945948

946949
/* Power button, Lid switch always enable wakeup */
947-
if (!acpi_match_device_ids(device, button_device_ids)) {
948-
if (!acpi_match_device_ids(device, &button_device_ids[1])) {
949-
/* Do not use Lid/sleep button for S5 wakeup */
950-
if (wakeup->sleep_state == ACPI_STATE_S5)
951-
wakeup->sleep_state = ACPI_STATE_S4;
952-
}
950+
match = acpi_match_acpi_device(button_device_ids, device);
951+
if (match) {
952+
if ((match->driver_data & ACPI_AVOID_WAKE_FROM_S5) &&
953+
wakeup->sleep_state == ACPI_STATE_S5)
954+
wakeup->sleep_state = ACPI_STATE_S4;
953955
acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number);
954956
device_set_wakeup_capable(&device->dev, true);
955957
return true;

drivers/i2c/busses/i2c-scmi.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include <linux/i2c.h>
1414
#include <linux/acpi.h>
1515

16-
/* SMBUS HID definition as supported by Microsoft Windows */
17-
#define ACPI_SMBUS_MS_HID "SMB0001"
18-
1916
struct smbus_methods_t {
2017
char *mt_info;
2118
char *mt_sbr;

include/acpi/acpi_drivers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define ACPI_BAY_HID "LNXIOBAY"
2828
#define ACPI_DOCK_HID "LNXDOCK"
2929
#define ACPI_ECDT_HID "LNXEC"
30+
/* SMBUS HID definition as supported by Microsoft Windows */
31+
#define ACPI_SMBUS_MS_HID "SMB0001"
3032
/* Quirk for broken IBM BIOSes */
3133
#define ACPI_SMBUS_IBM_HID "SMBUSIBM"
3234

include/linux/acpi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ extern int acpi_nvs_register(__u64 start, __u64 size);
707707
extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
708708
void *data);
709709

710+
const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids,
711+
const struct acpi_device *adev);
712+
710713
const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
711714
const struct device *dev);
712715

@@ -922,6 +925,12 @@ static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
922925

923926
struct acpi_device_id;
924927

928+
static inline const struct acpi_device_id *acpi_match_acpi_device(
929+
const struct acpi_device_id *ids, const struct acpi_device *adev)
930+
{
931+
return NULL;
932+
}
933+
925934
static inline const struct acpi_device_id *acpi_match_device(
926935
const struct acpi_device_id *ids, const struct device *dev)
927936
{

0 commit comments

Comments
 (0)