Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+80 -26
+28 -3
drivers/acpi/acpi_platform.c
··· 9 9 */ 10 10 11 11 #include <linux/acpi.h> 12 + #include <linux/bits.h> 12 13 #include <linux/device.h> 13 14 #include <linux/err.h> 14 15 #include <linux/kernel.h> ··· 20 19 21 20 #include "internal.h" 22 21 22 + /* Exclude devices that have no _CRS resources provided */ 23 + #define ACPI_ALLOW_WO_RESOURCES BIT(0) 24 + 23 25 static const struct acpi_device_id forbidden_id_list[] = { 24 26 {"ACPI0009", 0}, /* IOxAPIC */ 25 27 {"ACPI000A", 0}, /* IOAPIC */ 26 28 {"PNP0000", 0}, /* PIC */ 27 29 {"PNP0100", 0}, /* Timer */ 28 30 {"PNP0200", 0}, /* AT DMA Controller */ 29 - {"SMB0001", 0}, /* ACPI SMBUS virtual device */ 31 + {ACPI_SMBUS_MS_HID, ACPI_ALLOW_WO_RESOURCES}, /* ACPI SMBUS virtual device */ 30 32 { } 31 33 }; 32 34 ··· 87 83 dest->parent = pci_find_resource(to_pci_dev(parent), dest); 88 84 } 89 85 86 + static unsigned int acpi_platform_resource_count(struct acpi_resource *ares, void *data) 87 + { 88 + bool *has_resources = data; 89 + 90 + *has_resources = true; 91 + 92 + return AE_CTRL_TERMINATE; 93 + } 94 + 90 95 /** 91 96 * acpi_create_platform_device - Create platform device for ACPI device node 92 97 * @adev: ACPI device node to create a platform device for. ··· 113 100 struct acpi_device *parent = acpi_dev_parent(adev); 114 101 struct platform_device *pdev = NULL; 115 102 struct platform_device_info pdevinfo; 103 + const struct acpi_device_id *match; 116 104 struct resource_entry *rentry; 117 105 struct list_head resource_list; 118 106 struct resource *resources = NULL; ··· 123 109 if (adev->physical_node_count) 124 110 return NULL; 125 111 126 - if (!acpi_match_device_ids(adev, forbidden_id_list)) 127 - return ERR_PTR(-EINVAL); 112 + match = acpi_match_acpi_device(forbidden_id_list, adev); 113 + if (match) { 114 + if (match->driver_data & ACPI_ALLOW_WO_RESOURCES) { 115 + bool has_resources = false; 116 + 117 + acpi_walk_resources(adev->handle, METHOD_NAME__CRS, 118 + acpi_platform_resource_count, &has_resources); 119 + if (has_resources) 120 + return ERR_PTR(-EINVAL); 121 + } else { 122 + return ERR_PTR(-EINVAL); 123 + } 124 + } 128 125 129 126 INIT_LIST_HEAD(&resource_list); 130 127 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
+24 -7
drivers/acpi/bus.c
··· 682 682 * resources available from it but they will be matched normally using functions 683 683 * provided by their bus types (and analogously for their modalias). 684 684 */ 685 - struct acpi_device *acpi_companion_match(const struct device *dev) 685 + const struct acpi_device *acpi_companion_match(const struct device *dev) 686 686 { 687 687 struct acpi_device *adev; 688 688 ··· 706 706 * identifiers and a _DSD object with the "compatible" property, use that 707 707 * property to match against the given list of identifiers. 708 708 */ 709 - static bool acpi_of_match_device(struct acpi_device *adev, 709 + static bool acpi_of_match_device(const struct acpi_device *adev, 710 710 const struct of_device_id *of_match_table, 711 711 const struct of_device_id **of_id) 712 712 { ··· 808 808 return true; 809 809 } 810 810 811 - static bool __acpi_match_device(struct acpi_device *device, 811 + static bool __acpi_match_device(const struct acpi_device *device, 812 812 const struct acpi_device_id *acpi_ids, 813 813 const struct of_device_id *of_ids, 814 814 const struct acpi_device_id **acpi_id, ··· 851 851 } 852 852 853 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 + 873 + /** 854 874 * acpi_match_device - Match a struct device against a given list of ACPI IDs 855 875 * @ids: Array of struct acpi_device_id object to match against. 856 876 * @dev: The device structure to match. ··· 884 864 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 885 865 const struct device *dev) 886 866 { 887 - const struct acpi_device_id *id = NULL; 888 - 889 - __acpi_match_device(acpi_companion_match(dev), ids, NULL, &id, NULL); 890 - return id; 867 + return acpi_match_acpi_device(ids, acpi_companion_match(dev)); 891 868 } 892 869 EXPORT_SYMBOL_GPL(acpi_match_device); 893 870
+1 -1
drivers/acpi/device_sysfs.c
··· 283 283 } 284 284 EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias); 285 285 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) 287 287 { 288 288 int len, count; 289 289
+3 -1
drivers/acpi/internal.h
··· 11 11 12 12 #include <linux/idr.h> 13 13 14 + extern struct acpi_device *acpi_root; 15 + 14 16 int early_acpi_osi_init(void); 15 17 int acpi_osi_init(void); 16 18 acpi_status acpi_os_initialize1(void); ··· 121 119 /* -------------------------------------------------------------------------- 122 120 Device Matching and Notification 123 121 -------------------------------------------------------------------------- */ 124 - struct acpi_device *acpi_companion_match(const struct device *dev); 122 + const struct acpi_device *acpi_companion_match(const struct device *dev); 125 123 int __acpi_device_uevent_modalias(const struct acpi_device *adev, 126 124 struct kobj_uevent_env *env); 127 125
+13 -11
drivers/acpi/scan.c
··· 23 23 #include <linux/dma-direct.h> 24 24 25 25 #include "internal.h" 26 - 27 - extern struct acpi_device *acpi_root; 26 + #include "sleep.h" 28 27 29 28 #define ACPI_BUS_CLASS "system_bus" 30 29 #define ACPI_BUS_HID "LNXSYBUS" ··· 929 930 return err; 930 931 } 931 932 933 + /* Do not use a button for S5 wakeup */ 934 + #define ACPI_AVOID_WAKE_FROM_S5 BIT(0) 935 + 932 936 static bool acpi_wakeup_gpe_init(struct acpi_device *device) 933 937 { 934 938 static const struct acpi_device_id button_device_ids[] = { 935 - {"PNP0C0C", 0}, /* Power button */ 936 - {"PNP0C0D", 0}, /* Lid */ 937 - {"PNP0C0E", 0}, /* Sleep button */ 939 + {"PNP0C0C", 0}, /* Power button */ 940 + {"PNP0C0D", ACPI_AVOID_WAKE_FROM_S5}, /* Lid */ 941 + {"PNP0C0E", ACPI_AVOID_WAKE_FROM_S5}, /* Sleep button */ 938 942 {"", 0}, 939 943 }; 940 944 struct acpi_device_wakeup *wakeup = &device->wakeup; 945 + const struct acpi_device_id *match; 941 946 acpi_status status; 942 947 943 948 wakeup->flags.notifier_present = 0; 944 949 945 950 /* Power button, Lid switch always enable wakeup */ 946 - if (!acpi_match_device_ids(device, button_device_ids)) { 947 - if (!acpi_match_device_ids(device, &button_device_ids[1])) { 948 - /* Do not use Lid/sleep button for S5 wakeup */ 949 - if (wakeup->sleep_state == ACPI_STATE_S5) 950 - wakeup->sleep_state = ACPI_STATE_S4; 951 - } 951 + match = acpi_match_acpi_device(button_device_ids, device); 952 + if (match) { 953 + if ((match->driver_data & ACPI_AVOID_WAKE_FROM_S5) && 954 + wakeup->sleep_state == ACPI_STATE_S5) 955 + wakeup->sleep_state = ACPI_STATE_S4; 952 956 acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number); 953 957 device_set_wakeup_capable(&device->dev, true); 954 958 return true;
-3
drivers/i2c/busses/i2c-scmi.c
··· 13 13 #include <linux/i2c.h> 14 14 #include <linux/acpi.h> 15 15 16 - /* SMBUS HID definition as supported by Microsoft Windows */ 17 - #define ACPI_SMBUS_MS_HID "SMB0001" 18 - 19 16 struct smbus_methods_t { 20 17 char *mt_info; 21 18 char *mt_sbr;
+2
include/acpi/acpi_drivers.h
··· 27 27 #define ACPI_BAY_HID "LNXIOBAY" 28 28 #define ACPI_DOCK_HID "LNXDOCK" 29 29 #define ACPI_ECDT_HID "LNXEC" 30 + /* SMBUS HID definition as supported by Microsoft Windows */ 31 + #define ACPI_SMBUS_MS_HID "SMB0001" 30 32 /* Quirk for broken IBM BIOSes */ 31 33 #define ACPI_SMBUS_IBM_HID "SMBUSIBM" 32 34
+9
include/linux/acpi.h
··· 707 707 extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), 708 708 void *data); 709 709 710 + const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids, 711 + const struct acpi_device *adev); 712 + 710 713 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 711 714 const struct device *dev); 712 715 ··· 924 921 } 925 922 926 923 struct acpi_device_id; 924 + 925 + static inline const struct acpi_device_id *acpi_match_acpi_device( 926 + const struct acpi_device_id *ids, const struct acpi_device *adev) 927 + { 928 + return NULL; 929 + } 927 930 928 931 static inline const struct acpi_device_id *acpi_match_device( 929 932 const struct acpi_device_id *ids, const struct device *dev)