From 7c058c7c74b3dbeb7d157c273959f87faf710350 Mon Sep 17 00:00:00 2001 From: Ravi Chandra Sadineni Date: Wed, 27 Jun 2018 10:55:02 -0700 Subject: ACPI / button: increment wakeup count only when notified Because acpi_lid_initialize_state() is called on every system resume and it triggers acpi_lid_notify_state() which invokes acpi_pm_wakeup_event() for the lid device, the lid's wakeup count is incremented even if the lid was not the source of the event that woke up the system. That behavior confuses user space deamons using wakeup_count to identify the potential system wakeup source. To avoid the confusion, only trigger acpi_pm_wakeup_event() in the acpi_button_notify() path and don't do that in the acpi_lid_initialize_state() path. Signed-off-by: Ravi Chandra Sadineni Signed-off-by: Rafael J. Wysocki --- drivers/acpi/button.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 2345a5e..40ed3ec 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -235,9 +235,6 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state) button->last_time = ktime_get(); } - if (state) - acpi_pm_wakeup_event(&device->dev); - ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, device); if (ret == NOTIFY_DONE) ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, @@ -366,7 +363,8 @@ int acpi_lid_open(void) } EXPORT_SYMBOL(acpi_lid_open); -static int acpi_lid_update_state(struct acpi_device *device) +static int acpi_lid_update_state(struct acpi_device *device, + bool signal_wakeup) { int state; @@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct acpi_device *device) if (state < 0) return state; + if (state && signal_wakeup) + acpi_pm_wakeup_event(&device->dev); + return acpi_lid_notify_state(device, state); } @@ -384,7 +385,7 @@ static void acpi_lid_initialize_state(struct acpi_device *device) (void)acpi_lid_notify_state(device, 1); break; case ACPI_BUTTON_LID_INIT_METHOD: - (void)acpi_lid_update_state(device); + (void)acpi_lid_update_state(device, false); break; case ACPI_BUTTON_LID_INIT_IGNORE: default: @@ -409,7 +410,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) users = button->input->users; mutex_unlock(&button->input->mutex); if (users) - acpi_lid_update_state(device); + acpi_lid_update_state(device, true); } else { int keycode; -- cgit v1.1 From 72a361a5b91c77b33ab2533674fdcec4de3278d0 Mon Sep 17 00:00:00 2001 From: Tristian Celestin Date: Sat, 9 Jun 2018 18:18:06 -0400 Subject: ACPI / x86: enable touchscreen on Dell Venue Pro 7139 Permanently enable the SYNA7500 touchscreen device on the Dell Venue Pro 7139. The DSDT hides the touchscreen ACPI device on the 7139 in the same fashion as the 7130, and needs to be enabled in the same way. Signed-off-by: Tristian Celestin Signed-off-by: Rafael J. Wysocki --- drivers/acpi/x86/utils.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c index ec5b0f1..3a13b2a 100644 --- a/drivers/acpi/x86/utils.c +++ b/drivers/acpi/x86/utils.c @@ -62,14 +62,20 @@ static const struct always_present_id always_present_ids[] = { */ ENTRY("INT0002", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}), /* - * On the Dell Venue 11 Pro 7130 the DSDT hides the touchscreen ACPI - * device until a certain time after _SB.PCI0.GFX0.LCD.LCD1._ON gets - * called has passed *and* _STA has been called at least 3 times since. + * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides + * the touchscreen ACPI device until a certain time + * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed + * *and* _STA has been called at least 3 times since. */ ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), }), + ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), + }), + /* * The GPD win BIOS dated 20170221 has disabled the accelerometer, the * drivers sometimes cause crashes under Windows and this is how the -- cgit v1.1 From da7f7126f04c37cf0b33a75b7a5dd3c1b2adfa2b Mon Sep 17 00:00:00 2001 From: Erik Schmauss Date: Fri, 29 Jun 2018 11:28:11 -0700 Subject: ACPICA: Revert "iASL: change processing of external op namespace nodes for correctness" Revert commit b43eac6f3384 (ACPICA: iASL: change processing of external op namespace nodes for correctness; upstream ACPICA commit aa866a9b4f24bbec9f158d10325b486d7d12d90f). This was done in order to allow more relaxed usage of ASL external declarations. Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/nsaccess.c | 13 ++++++------- drivers/acpi/acpica/nssearch.c | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 220a718..3c571fe 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -608,18 +608,17 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, this_node->object; } } +#ifdef ACPI_ASL_COMPILER + if (!acpi_gbl_disasm_flag && + (this_node->flags & ANOBJ_IS_EXTERNAL)) { + this_node->flags |= IMPLICIT_EXTERNAL; + } +#endif } /* Special handling for the last segment (num_segments == 0) */ else { -#ifdef ACPI_ASL_COMPILER - if (!acpi_gbl_disasm_flag - && (this_node->flags & ANOBJ_IS_EXTERNAL)) { - this_node->flags &= ~IMPLICIT_EXTERNAL; - } -#endif - /* * Sanity typecheck of the target object: * diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c index e9c9a63..f594ab7 100644 --- a/drivers/acpi/acpica/nssearch.c +++ b/drivers/acpi/acpica/nssearch.c @@ -381,7 +381,6 @@ acpi_ns_search_and_enter(u32 target_name, if (flags & ACPI_NS_EXTERNAL || (walk_state && walk_state->opcode == AML_SCOPE_OP)) { new_node->flags |= ANOBJ_IS_EXTERNAL; - new_node->flags |= IMPLICIT_EXTERNAL; } #endif -- cgit v1.1 From a9efdcffd54dc1098a089c3c833eef8d7bee4d77 Mon Sep 17 00:00:00 2001 From: Erik Schmauss Date: Fri, 29 Jun 2018 11:28:12 -0700 Subject: ACPICA: Revert "iASL compiler: allow compilation of externals with paths that refer to existing names" Revert commit 3ddd3f6a9410 (ACPICA: iASL compiler: allow compilation of externals with paths that refer to existing names; upstream ACPICA commit 9a252114197409290813bee570e9d53c22b99d32). This was done in order to allow more relaxed usage of ASL external declarations. Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/aclocal.h | 1 - drivers/acpi/acpica/nsaccess.c | 6 ------ 2 files changed, 7 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 51c386b..c5367bf 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -165,7 +165,6 @@ struct acpi_namespace_node { #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ -#define IMPLICIT_EXTERNAL 0x02 /* iASL only: This object created implicitly via External */ #define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ #define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 3c571fe..83a593e 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -608,12 +608,6 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, this_node->object; } } -#ifdef ACPI_ASL_COMPILER - if (!acpi_gbl_disasm_flag && - (this_node->flags & ANOBJ_IS_EXTERNAL)) { - this_node->flags |= IMPLICIT_EXTERNAL; - } -#endif } /* Special handling for the last segment (num_segments == 0) */ -- cgit v1.1 From 2c4c2a71bd6f75c3982ac09407889b110673ac83 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sat, 7 Jul 2018 08:25:01 -0700 Subject: ACPI / button: fix defined but not used warning Fix a build warning in the ACPI button driver when CONFIG_PROC_FS is not enabled by marking the unused function as __maybe_unused. ../drivers/acpi/button.c:252:12: warning: 'acpi_button_state_seq_show' defined but not used [-Wunused-function] Signed-off-by: Randy Dunlap Signed-off-by: Rafael J. Wysocki --- drivers/acpi/button.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 40ed3ec..a19ff39 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -21,6 +21,7 @@ #define pr_fmt(fmt) "ACPI: button: " fmt +#include #include #include #include @@ -249,7 +250,8 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state) return ret; } -static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) +static int __maybe_unused acpi_button_state_seq_show(struct seq_file *seq, + void *offset) { struct acpi_device *device = seq->private; int state; -- cgit v1.1 From ae976358cd7b0272ccfbd2517edaf0d46f2a356b Mon Sep 17 00:00:00 2001 From: Kai Heng Feng Date: Thu, 19 Jul 2018 19:00:30 +0800 Subject: Revert "ACPI / bus: Parse tables as term_list for Dell XPS 9570 and Precision M5530" Reverts commit 36904703aeee (ACPI / bus: Parse tables as term_list for Dell XPS 9570 and Precision M5530). Since commit 5a8361f7ecce (ACPICA: Integrate package handling with module-level code), acpi_gbl_execute_tables_as_methods is always true, so we can remove the quirk for XPS 9570/Precision M5530. Signed-off-by: Kai-Heng Feng Signed-off-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 84b4a62..f61f892 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -66,37 +66,10 @@ static int set_copy_dsdt(const struct dmi_system_id *id) return 0; } #endif -static int set_gbl_term_list(const struct dmi_system_id *id) -{ - acpi_gbl_execute_tables_as_methods = 1; - return 0; -} -static const struct dmi_system_id acpi_quirks_dmi_table[] __initconst = { - /* - * Touchpad on Dell XPS 9570/Precision M5530 doesn't work under I2C - * mode. - * https://bugzilla.kernel.org/show_bug.cgi?id=198515 - */ - { - .callback = set_gbl_term_list, - .ident = "Dell Precision M5530", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Precision M5530"), - }, - }, - { - .callback = set_gbl_term_list, - .ident = "Dell XPS 15 9570", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "XPS 15 9570"), - }, - }, +static const struct dmi_system_id dsdt_dmi_table[] __initconst = { /* * Invoke DSDT corruption work-around on all Toshiba Satellite. - * DSDT will be copied to memory. * https://bugzilla.kernel.org/show_bug.cgi?id=14679 */ { @@ -110,7 +83,7 @@ static const struct dmi_system_id acpi_quirks_dmi_table[] __initconst = { {} }; #else -static const struct dmi_system_id acpi_quirks_dmi_table[] __initconst = { +static const struct dmi_system_id dsdt_dmi_table[] __initconst = { {} }; #endif @@ -1060,8 +1033,11 @@ void __init acpi_early_init(void) acpi_permanent_mmap = true; - /* Check machine-specific quirks */ - dmi_check_system(acpi_quirks_dmi_table); + /* + * If the machine falls into the DMI check table, + * DSDT will be copied to memory + */ + dmi_check_system(dsdt_dmi_table); status = acpi_reallocate_root_table(); if (ACPI_FAILURE(status)) { -- cgit v1.1 From 887532ca7ca59fcf0547a79211756791128030a3 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 18 Jul 2018 11:46:55 -0700 Subject: ACPI / OSI: Add OEM _OSI string to enable NVidia HDMI audio Some ThinkPad systems have a power-saving feature that turns off HDMI audio device in Windows, but NVidia Linux driver does not support this feature. As a result, HDMI audio will not work on Linux. A BIOS workaround is added with an OEM_OSI string "Linux-Lenovo-NV-HDMI-Audio" to power on NVidia HDMI audio when booting. The form of the OEM _OSI strings is defined by each OEMs and is discussed in Documentation/acpi/osi.txt. Signed-off-by: Alex Hung Signed-off-by: Rafael J. Wysocki --- drivers/acpi/osi.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osi.c b/drivers/acpi/osi.c index 8a8f435..b2a16ed 100644 --- a/drivers/acpi/osi.c +++ b/drivers/acpi/osi.c @@ -66,6 +66,14 @@ osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { * be removed if both new and old graphics cards are supported. */ {"Linux-Dell-Video", true}, + /* + * Linux-Lenovo-NV-HDMI-Audio is used by BIOS to power on NVidia's HDMI + * audio device which is turned off for power-saving in Windows OS. + * This power management feature observed on some Lenovo Thinkpad + * systems which will not be able to output audio via HDMI without + * a BIOS workaround. + */ + {"Linux-Lenovo-NV-HDMI-Audio", true}, }; static u32 acpi_osi_handler(acpi_string interface, u32 supported) -- cgit v1.1 From 977d5ad39f3ea12ac0bd51d75020cea5ecdca235 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 17 Jul 2018 17:19:11 +0300 Subject: ACPI: Convert ACPI reference args to generic fwnode reference args Convert all users of struct acpi_reference_args to more generic fwnode_reference_args. This will 1) avoid an ACPI specific references to device nodes with integer arguments as well as 2) allow making references to nodes other than device nodes in ACPI. As a by-product, convert the fwnode interger arguments to u64. The arguments were 64-bit integers on ACPI but the fwnode arguments were just 32-bit. Signed-off-by: Sakari Ailus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/property.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 5815356..3fa4001 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -579,7 +579,7 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data, */ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, const char *propname, size_t index, size_t num_args, - struct acpi_reference_args *args) + struct fwnode_reference_args *args) { const union acpi_object *element, *end; const union acpi_object *obj; @@ -607,7 +607,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, if (ret) return ret == -ENODEV ? -EINVAL : ret; - args->adev = device; + args->fwnode = acpi_fwnode_handle(device); args->nargs = 0; return 0; } @@ -653,11 +653,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, return -EINVAL; } - if (nargs > MAX_ACPI_REFERENCE_ARGS) + if (nargs > NR_FWNODE_REFERENCE_ARGS) return -EINVAL; if (idx == index) { - args->adev = device; + args->fwnode = acpi_fwnode_handle(device); args->nargs = nargs; for (i = 0; i < nargs; i++) args->args[i] = element[i].integer.value; @@ -1089,7 +1089,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, { struct fwnode_handle *fwnode; unsigned int port_nr, endpoint_nr; - struct acpi_reference_args args; + struct fwnode_reference_args args; int ret; memset(&args, 0, sizeof(args)); @@ -1098,6 +1098,10 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, if (ret) return ret; + /* Ensure this is a device node. */ + if (!is_acpi_device_node(args.fwnode)) + return -ENODEV; + /* * Always require two arguments with the reference: port and * endpoint indices. @@ -1105,7 +1109,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, if (args.nargs != 2) return -EPROTO; - fwnode = acpi_fwnode_handle(args.adev); + fwnode = args.fwnode; port_nr = args.args[0]; endpoint_nr = args.args[1]; @@ -1209,24 +1213,8 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, unsigned int args_count, unsigned int index, struct fwnode_reference_args *args) { - struct acpi_reference_args acpi_args; - unsigned int i; - int ret; - - ret = __acpi_node_get_property_reference(fwnode, prop, index, - args_count, &acpi_args); - if (ret < 0) - return ret; - if (!args) - return 0; - - args->nargs = acpi_args.nargs; - args->fwnode = acpi_fwnode_handle(acpi_args.adev); - - for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++) - args->args[i] = i < acpi_args.nargs ? acpi_args.args[i] : 0; - - return 0; + return __acpi_node_get_property_reference(fwnode, prop, index, + args_count, args); } static struct fwnode_handle * -- cgit v1.1 From 4eb0c3bf5ee52ffc88500763d80ba01393879794 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 17 Jul 2018 17:19:12 +0300 Subject: ACPI: property: Allow making references to non-device nodes Implement references to non-device nodes using the first package entry in the hierarchical data extension reference, the second one being the name of the referred object. The data node references are parsed just after the device arguments before the integer arguments. If there are no strings after the device arguments, the parsing works exactly as it used to be. Referring to a data node called "node" under device DEV, with integer arguments 0, 2 would thus look like: Package() { DEV, "node", 0, 2 } Signed-off-by: Sakari Ailus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/property.c | 51 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 3fa4001..5878d36 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -542,6 +542,23 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data, return 0; } +static struct fwnode_handle * +acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode, + const char *childname) +{ + struct fwnode_handle *child; + + /* + * Find first matching named child node of this fwnode. + * For ACPI this will be a data only sub-node. + */ + fwnode_for_each_child_node(fwnode, child) + if (acpi_data_node_match(child, childname)) + return child; + + return NULL; +} + /** * __acpi_node_get_property_reference - returns handle to the referenced object * @fwnode: Firmware node to get the property from @@ -633,6 +650,8 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, u32 nargs, i; if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { + struct fwnode_handle *ref_fwnode; + ret = acpi_bus_get_device(element->reference.handle, &device); if (ret) @@ -641,6 +660,19 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, nargs = 0; element++; + /* + * Find the referred data extension node under the + * referred device node. + */ + for (ref_fwnode = acpi_fwnode_handle(device); + element < end && element->type == ACPI_TYPE_STRING; + element++) { + ref_fwnode = acpi_fwnode_get_named_child_node( + ref_fwnode, element->string.pointer); + if (!ref_fwnode) + return -EINVAL; + } + /* assume following integer elements are all args */ for (i = 0; element + i < end && i < num_args; i++) { int type = element[i].type; @@ -657,7 +689,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, return -EINVAL; if (idx == index) { - args->fwnode = acpi_fwnode_handle(device); + args->fwnode = ref_fwnode; args->nargs = nargs; for (i = 0; i < nargs; i++) args->args[i] = element[i].integer.value; @@ -1190,23 +1222,6 @@ acpi_fwnode_property_read_string_array(const struct fwnode_handle *fwnode, val, nval); } -static struct fwnode_handle * -acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode, - const char *childname) -{ - struct fwnode_handle *child; - - /* - * Find first matching named child node of this fwnode. - * For ACPI this will be a data only sub-node. - */ - fwnode_for_each_child_node(fwnode, child) - if (acpi_data_node_match(child, childname)) - return child; - - return NULL; -} - static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, const char *prop, const char *nargs_prop, -- cgit v1.1 From 0ef7478639c5165a672f01b4024aacfffa951813 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 17 Jul 2018 17:19:14 +0300 Subject: ACPI: property: Make the ACPI graph API private The fwnode graph API is preferred over the ACPI graph API. Therefore make the ACPI graph API private, and use it as a back-end for the fwnode graph API only. Unused functionality is removed while the functionality actually used remains the same. Signed-off-by: Sakari Ailus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/property.c | 83 ++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 67 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 5878d36..19bdada 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1033,10 +1033,10 @@ struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode) * @prev: Previous endpoint node or %NULL to get the first * * Looks up next endpoint ACPI firmware node below a given @fwnode. Returns - * %NULL if there is no next endpoint, ERR_PTR() in case of error. In case - * of success the next endpoint is returned. + * %NULL if there is no next endpoint or in case of error. In case of success + * the next endpoint is returned. */ -struct fwnode_handle *acpi_graph_get_next_endpoint( +static struct fwnode_handle *acpi_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev) { struct fwnode_handle *port = NULL; @@ -1065,11 +1065,9 @@ struct fwnode_handle *acpi_graph_get_next_endpoint( endpoint = fwnode_get_next_child_node(port, NULL); } - if (endpoint) { - /* Endpoints must have "endpoint" property */ - if (!fwnode_property_present(endpoint, "endpoint")) - return ERR_PTR(-EPROTO); - } + /* Endpoints must have "endpoint" property */ + if (!fwnode_property_present(endpoint, "endpoint")) + return NULL; return endpoint; } @@ -1106,18 +1104,12 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value( /** * acpi_graph_get_remote_enpoint - Parses and returns remote end of an endpoint * @fwnode: Endpoint firmware node pointing to a remote device - * @parent: Firmware node of remote port parent is filled here if not %NULL - * @port: Firmware node of remote port is filled here if not %NULL * @endpoint: Firmware node of remote endpoint is filled here if not %NULL * - * Function parses remote end of ACPI firmware remote endpoint and fills in - * fields requested by the caller. Returns %0 in case of success and - * negative errno otherwise. + * Returns the remote endpoint corresponding to @__fwnode. NULL on error. */ -int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, - struct fwnode_handle **parent, - struct fwnode_handle **port, - struct fwnode_handle **endpoint) +static struct fwnode_handle * +acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode) { struct fwnode_handle *fwnode; unsigned int port_nr, endpoint_nr; @@ -1128,47 +1120,27 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, &args); if (ret) - return ret; + return NULL; /* Ensure this is a device node. */ if (!is_acpi_device_node(args.fwnode)) - return -ENODEV; + return NULL; /* * Always require two arguments with the reference: port and * endpoint indices. */ if (args.nargs != 2) - return -EPROTO; + return NULL; fwnode = args.fwnode; port_nr = args.args[0]; endpoint_nr = args.args[1]; - if (parent) - *parent = fwnode; - - if (!port && !endpoint) - return 0; - fwnode = acpi_graph_get_child_prop_value(fwnode, "port", port_nr); - if (!fwnode) - return -EPROTO; - - if (port) - *port = fwnode; - - if (!endpoint) - return 0; - - fwnode = acpi_graph_get_child_prop_value(fwnode, "endpoint", - endpoint_nr); - if (!fwnode) - return -EPROTO; - *endpoint = fwnode; - - return 0; + return acpi_graph_get_child_prop_value(fwnode, "endpoint", + endpoint_nr); } static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) @@ -1233,29 +1205,6 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, } static struct fwnode_handle * -acpi_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode, - struct fwnode_handle *prev) -{ - struct fwnode_handle *endpoint; - - endpoint = acpi_graph_get_next_endpoint(fwnode, prev); - if (IS_ERR(endpoint)) - return NULL; - - return endpoint; -} - -static struct fwnode_handle * -acpi_fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode) -{ - struct fwnode_handle *endpoint = NULL; - - acpi_graph_get_remote_endpoint(fwnode, NULL, NULL, &endpoint); - - return endpoint; -} - -static struct fwnode_handle * acpi_fwnode_get_parent(struct fwnode_handle *fwnode) { return acpi_node_get_parent(fwnode); @@ -1295,9 +1244,9 @@ acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, .get_named_child_node = acpi_fwnode_get_named_child_node, \ .get_reference_args = acpi_fwnode_get_reference_args, \ .graph_get_next_endpoint = \ - acpi_fwnode_graph_get_next_endpoint, \ + acpi_graph_get_next_endpoint, \ .graph_get_remote_endpoint = \ - acpi_fwnode_graph_get_remote_endpoint, \ + acpi_graph_get_remote_endpoint, \ .graph_get_port_parent = acpi_fwnode_get_parent, \ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ }; \ -- cgit v1.1 From 6561eb3d3a23c4d38ba428396b7a14e184804535 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 17 Jul 2018 17:19:15 +0300 Subject: ACPI: property: Allow direct graph endpoint references By using device and further data node references, allow direct references to endpoints. These are of form Package() { \DEV, "portX", "endpointY" } where X is the number of the port and Y is the number of the endpoint. Signed-off-by: Sakari Ailus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 19bdada..10af340 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1122,9 +1122,9 @@ acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode) if (ret) return NULL; - /* Ensure this is a device node. */ + /* Direct endpoint reference? */ if (!is_acpi_device_node(args.fwnode)) - return NULL; + return args.nargs ? NULL : args.fwnode; /* * Always require two arguments with the reference: port and -- cgit v1.1 From 18f1e58d1536f69d4e35f6eabaa07e57eb317314 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 17 Jul 2018 17:19:16 +0300 Subject: ACPI: property: Use data node name and reg property for graphs Instead of using the port and endpoint properties, rely on the names of the port and endpoint nodes as well as the reg property, as on DT. Signed-off-by: Sakari Ailus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/property.c | 51 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 10af340..693cf05 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1027,6 +1027,26 @@ struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode) return NULL; } +/* + * Return true if the node is an ACPI graph node. Called on either ports + * or endpoints. + */ +static bool is_acpi_graph_node(struct fwnode_handle *fwnode, + const char *str) +{ + unsigned int len = strlen(str); + const char *name; + + if (!len || !is_acpi_data_node(fwnode)) + return false; + + name = to_acpi_data_node(fwnode)->name; + + return (fwnode_property_present(fwnode, "reg") && + !strncmp(name, str, len) && name[len] == '@') || + fwnode_property_present(fwnode, str); +} + /** * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node * @fwnode: Pointer to the parent firmware node @@ -1045,8 +1065,14 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint( if (!prev) { do { port = fwnode_get_next_child_node(fwnode, port); - /* Ports must have port property */ - if (fwnode_property_present(port, "port")) + /* + * The names of the port nodes begin with "port@" + * followed by the number of the port node and they also + * have a "reg" property that also has the number of the + * port node. For compatibility reasons a node is also + * recognised as a port node from the "port" property. + */ + if (is_acpi_graph_node(port, "port")) break; } while (port); } else { @@ -1061,12 +1087,18 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint( port = fwnode_get_next_child_node(fwnode, port); if (!port) break; - if (fwnode_property_present(port, "port")) + if (is_acpi_graph_node(port, "port")) endpoint = fwnode_get_next_child_node(port, NULL); } - /* Endpoints must have "endpoint" property */ - if (!fwnode_property_present(endpoint, "endpoint")) + /* + * The names of the endpoint nodes begin with "endpoint@" followed by + * the number of the endpoint node and they also have a "reg" property + * that also has the number of the endpoint node. For compatibility + * reasons a node is also recognised as an endpoint node from the + * "endpoint" property. + */ + if (!is_acpi_graph_node(endpoint, "endpoint")) return NULL; return endpoint; @@ -1139,8 +1171,7 @@ acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode) fwnode = acpi_graph_get_child_prop_value(fwnode, "port", port_nr); - return acpi_graph_get_child_prop_value(fwnode, "endpoint", - endpoint_nr); + return acpi_graph_get_child_prop_value(fwnode, "endpoint", endpoint_nr); } static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) @@ -1217,8 +1248,10 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, endpoint->local_fwnode = fwnode; - fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); - fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); + if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) + fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); + if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) + fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); return 0; } -- cgit v1.1 From 82f2d30570b7ecdf1ce7e6376805f063ae86a7e5 Mon Sep 17 00:00:00 2001 From: Lucas Rangit Magasweran Date: Sat, 14 Jul 2018 15:40:18 -0700 Subject: ACPI: battery: remove redundant old_present check on insertion On removal battery_present changes from 1 to 0 after calling acpi_battery_get_status() and battery->update_time is set to 0 before returning. On insertion battery_present changes from 0 to 1 after calling acpi_battery_get_status() and acpi_battery_get_info() is called because battery->update_time is 0. The old_present condition is therefore redundant. This was added in the commit below when there was a path without sysfs that would skip getting the newly inserted battery info. commit 50b178512b7d ("Newly inserted battery might differ from one just removed, so update of battery info fields is required.") Signed-off-by: Lucas Rangit Magasweran Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index d79ad84..78e40a9 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -918,10 +918,11 @@ static void acpi_battery_quirks(struct acpi_battery *battery) static int acpi_battery_update(struct acpi_battery *battery, bool resume) { - int result, old_present = acpi_battery_present(battery); - result = acpi_battery_get_status(battery); + int result = acpi_battery_get_status(battery); + if (result) return result; + if (!acpi_battery_present(battery)) { sysfs_remove_battery(battery); battery->update_time = 0; @@ -931,8 +932,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume) if (resume) return 0; - if (!battery->update_time || - old_present != acpi_battery_present(battery)) { + if (!battery->update_time) { result = acpi_battery_get_info(battery); if (result) return result; -- cgit v1.1 From 3461dfbabcc40d48c7b4b3ebb26a4ec927303e16 Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Tue, 24 Jul 2018 14:27:31 +0300 Subject: ACPI / battery: drop inclusion of init.h The driver can be built as a module thus inclusion of init.h is redundant in battery.c since it's always included by module.h. Suggested-by: Andy Shevchenko Signed-off-by: Dmitry Rozhkov Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 78e40a9..642e51f 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include -- cgit v1.1 From 53dd200a2eed1413f2ef980dd5a193a3d45cc9a9 Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Tue, 24 Jul 2018 14:27:32 +0300 Subject: ACPI / battery: reorder headers alphabetically Headers ordered alphabetically as easier to maintain. Suggested-by: Andy Shevchenko Signed-off-by: Dmitry Rozhkov Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 642e51f..321b5f9 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -23,17 +23,18 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include #include #include +#include + #include #ifdef CONFIG_ACPI_PROCFS_POWER -- cgit v1.1 From dd1fca9e6cd4c5c179f4e854ceddbc22890109ce Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Tue, 24 Jul 2018 14:27:33 +0300 Subject: ACPI / battery: use specialized print macros The kernel provides specialized macros for printing info and warning messages which make the code shorter. Use the specialized macros instead of bare printk()'s. Also format one user visible string literal into a searchable one line string. Suggested-by: Andy Shevchenko Signed-off-by: Dmitry Rozhkov Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 321b5f9..6d302bb 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -577,8 +577,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery) battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && (s16)(battery->rate_now) < 0) { battery->rate_now = abs((s16)battery->rate_now); - printk_once(KERN_WARNING FW_BUG - "battery: (dis)charge rate invalid.\n"); + pr_warn_once(FW_BUG "battery: (dis)charge rate invalid.\n"); } if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) @@ -1170,8 +1169,7 @@ static const struct file_operations acpi_battery_alarm_fops = { static int acpi_battery_add_fs(struct acpi_device *device) { - printk(KERN_WARNING PREFIX "Deprecated procfs I/F for battery is loaded," - " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n"); + pr_warning(PREFIX "Deprecated procfs I/F for battery is loaded, please retry with CONFIG_ACPI_PROCFS_POWER cleared\n"); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_battery_dir); @@ -1398,7 +1396,7 @@ static int acpi_battery_add(struct acpi_device *device) } #endif - printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", + pr_info(PREFIX "%s Slot [%s] (battery %s)\n", ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), device->status.battery_present ? "present" : "absent"); -- cgit v1.1 From 2754435d4c820875412785da9bfa017a74fe51a7 Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Tue, 24 Jul 2018 14:27:34 +0300 Subject: ACPI / battery: get rid of negations in conditions Simple conditions without negations inflict less cognitive load on readers. Rework conditional branches not to use negations. Also add braces around single statement branches where their counterpart else-branches consist of more than one statement as suggested in the paragraph 3 of the coding style. Suggested-by: Andy Shevchenko Signed-off-by: Dmitry Rozhkov Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 6d302bb..cb664e8 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -1020,7 +1020,7 @@ static int acpi_battery_info_proc_show(struct seq_file *seq, void *offset) acpi_battery_units(battery)); seq_printf(seq, "battery technology: %srechargeable\n", - (!battery->technology)?"non-":""); + battery->technology ? "" : "non-"); if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) seq_printf(seq, "design voltage: unknown\n"); @@ -1111,11 +1111,12 @@ static int acpi_battery_alarm_proc_show(struct seq_file *seq, void *offset) goto end; } seq_printf(seq, "alarm: "); - if (!battery->alarm) - seq_printf(seq, "unsupported\n"); - else + if (battery->alarm) { seq_printf(seq, "%u %sh\n", battery->alarm, acpi_battery_units(battery)); + } else { + seq_printf(seq, "unsupported\n"); + } end: if (result) seq_printf(seq, "ERROR: Unable to read battery alarm\n"); @@ -1148,9 +1149,9 @@ static ssize_t acpi_battery_write_alarm(struct file *file, } result = acpi_battery_set_alarm(battery); end: - if (!result) - return count; - return result; + if (result) + return result; + return count; } static int acpi_battery_alarm_proc_open(struct inode *inode, struct file *file) @@ -1245,7 +1246,9 @@ static int battery_notify(struct notifier_block *nb, if (!acpi_battery_present(battery)) return 0; - if (!battery->bat) { + if (battery->bat) { + acpi_battery_refresh(battery); + } else { result = acpi_battery_get_info(battery); if (result) return result; @@ -1253,8 +1256,7 @@ static int battery_notify(struct notifier_block *nb, result = sysfs_add_battery(battery); if (result) return result; - } else - acpi_battery_refresh(battery); + } acpi_battery_init_alarm(battery); acpi_battery_get_state(battery); -- cgit v1.1 From b047c62e24418b9f62b721be017ec5c0364166a5 Mon Sep 17 00:00:00 2001 From: Aaron Ma Date: Tue, 31 Jul 2018 18:52:39 +0800 Subject: ACPI / EC: Use ec_no_wakeup on ThinkPad X1 Yoga 3rd Like on X1C6, on X1Y3 EC interrupts constantly wake up system from s2idle, the power consumption is extremely high. So make ec_no_wakeup be true as default to keep system in s2idle mode and reduce power consumption. Power button works when ec_no_wakeup=true. Signed-off-by: Aaron Ma Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 917f77f..6291d5c7 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -2045,6 +2045,13 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = { DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"), }, }, + { + .ident = "ThinkPad X1 Yoga 3rd", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Yoga 3rd"), + }, + }, { }, }; -- cgit v1.1 From b41901a2cf06f33c030be96c075872201089d47a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 7 Aug 2018 09:36:30 +0200 Subject: ACPI / battery: Do not export energy_full[_design] on devices without full_charge_capacity On some devices (with a buggy _BIX implementation) full_charge_capacity always reports as 0. This means that our energy_full sysfs attribute will also always be 0, which is not useful to export. Worse we calculate our reported capacity on full_charge_capacity and if it is 0 we always report 0. This causes userspace to immediately shutdown or hibernate the laptop since it assumes that the battery is critically low. This commit makes us not report energy_full[_design] or capacity on such broken devices, avoiding the immediate shutdown / hibernate from userspace. Link: https://bugzilla.kernel.org/show_bug.cgi?id=83941 Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index cb664e8..cb97b61 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -364,6 +364,20 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; +static enum power_supply_property energy_battery_full_cap_broken_props[] = { + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_TECHNOLOGY, + POWER_SUPPLY_PROP_CYCLE_COUNT, + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, + POWER_SUPPLY_PROP_VOLTAGE_NOW, + POWER_SUPPLY_PROP_POWER_NOW, + POWER_SUPPLY_PROP_ENERGY_NOW, + POWER_SUPPLY_PROP_MODEL_NAME, + POWER_SUPPLY_PROP_MANUFACTURER, + POWER_SUPPLY_PROP_SERIAL_NUMBER, +}; + /* -------------------------------------------------------------------------- Battery Management -------------------------------------------------------------------------- */ @@ -798,6 +812,11 @@ static int sysfs_add_battery(struct acpi_battery *battery) battery->bat_desc.properties = charge_battery_props; battery->bat_desc.num_properties = ARRAY_SIZE(charge_battery_props); + } else if (battery->full_charge_capacity == 0) { + battery->bat_desc.properties = + energy_battery_full_cap_broken_props; + battery->bat_desc.num_properties = + ARRAY_SIZE(energy_battery_full_cap_broken_props); } else { battery->bat_desc.properties = energy_battery_props; battery->bat_desc.num_properties = -- cgit v1.1 From a6f0729508df6a067c4a074ec187ecd9d2457a6b Mon Sep 17 00:00:00 2001 From: John Garry Date: Tue, 7 Aug 2018 21:15:05 +0800 Subject: ACPI / scan: Add static attribute to indirect_io_hosts[] Array indirect_io_hosts[] is declared in acpi_is_indirect_io_slave() as a const array, which means that the array will be re-built for each call. Optimise by adding the static attribute, which means that the array is added to const-data pool and not re-built per function call. Reported-by: Hans de Goede Signed-off-by: John Garry Signed-off-by: Rafael J. Wysocki --- drivers/acpi/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 970dd87..199c8ea6 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1528,7 +1528,7 @@ static int acpi_check_serial_bus_slave(struct acpi_resource *ares, void *data) static bool acpi_is_indirect_io_slave(struct acpi_device *device) { struct acpi_device *parent = device->parent; - const struct acpi_device_id indirect_io_hosts[] = { + static const struct acpi_device_id indirect_io_hosts[] = { {"HISI0191", 0}, {} }; -- cgit v1.1 From 67fbd0a3a802bc80218f6c33d594f34f0ecb02f9 Mon Sep 17 00:00:00 2001 From: Tom Todd Date: Wed, 8 Aug 2018 01:52:02 +0100 Subject: ACPI: bus: Fix a pointer coding style issue Fix white space in the argument list of acpi_device_remove(). Signed-off-by: Tom Todd Signed-off-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index f61f892..292088f 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -935,7 +935,7 @@ static int acpi_device_probe(struct device *dev) return 0; } -static int acpi_device_remove(struct device * dev) +static int acpi_device_remove(struct device *dev) { struct acpi_device *acpi_dev = to_acpi_device(dev); struct acpi_driver *acpi_drv = acpi_dev->driver; -- cgit v1.1 From 4c3be61e41b4206878cd021afbdb85f5b76f2099 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Wed, 8 Aug 2018 12:50:37 +0300 Subject: ACPI / EC: Add another entry for Thinkpad X1 Carbon 6th Commit 2c4d6baf1bc4 (ACPI / EC: Use ec_no_wakeup on more Thinkpad X1 Carbon 6th systems) changed the DMI table to match all systems where DMI product family is "Thinkpad X1 Carbon 6th". However, the system I have here has this string written differently (ThinkPad vs. Thinkpad) which makes the match fail. In addition to that, after BIOS upgrade Robin now has the same string than my system has (perhaps newer BIOS has changed the string). In any case add another DMI entry to acpi_ec_no_wakeup[] table hopefully covering all the X1 Carbon 6th systems out there. Fixes: 2c4d6baf1bc4 (ACPI / EC: Use ec_no_wakeup on more Thinkpad X1 Carbon 6th systems) Signed-off-by: Mika Westerberg [ rjw: Rebase and change the ident string to match the product familiy ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 6291d5c7..d4e5610 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -2046,6 +2046,13 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = { }, }, { + .ident = "ThinkPad X1 Carbon 6th", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Carbon 6th"), + }, + }, + { .ident = "ThinkPad X1 Yoga 3rd", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), -- cgit v1.1 From 5971b0c1594d6c34e257101ed5fdffec65205c50 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 8 Aug 2018 10:30:03 +0200 Subject: ACPI / scan: Initialize status to ACPI_STA_DEFAULT Since commit 63347db0affa "ACPI / scan: Use acpi_bus_get_status() to initialize ACPI_TYPE_DEVICE devs" the status field of normal acpi_devices gets set to 0 by acpi_bus_type_and_status() and filled with its actual value later when acpi_add_single_object() calls acpi_bus_get_status(). This means that any acpi_match_device_ids() calls in between will always fail with -ENOENT. We already have a workaround for this, which temporary forces status to ACPI_STA_DEFAULT in drivers/acpi/x86/utils.c: acpi_device_always_present() and the next commit in this series adds another acpi_match_device_ids() call between status being initialized as 0 and the acpi_bus_get_status() call. Rather then adding another workaround, this commit makes acpi_bus_type_and_status() initialize status to ACPI_STA_DEFAULT, this is safe to do as the only code looking at status between the initialization and the acpi_bus_get_status() call is those acpi_match_device_ids() calls. Note this does mean that we need to (re)set status to 0 in case the acpi_bus_get_status() call fails. Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki --- drivers/acpi/scan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 199c8ea6..798a734 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1612,7 +1612,8 @@ static int acpi_add_single_object(struct acpi_device **child, * Note this must be done before the get power-/wakeup_dev-flags calls. */ if (type == ACPI_BUS_TYPE_DEVICE) - acpi_bus_get_status(device); + if (acpi_bus_get_status(device) < 0) + acpi_set_device_status(device, 0); acpi_bus_get_power_flags(device); acpi_bus_get_wakeup_device_flags(device); @@ -1690,7 +1691,7 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, * acpi_add_single_object updates this once we've an acpi_device * so that acpi_bus_get_status' quirk handling can be used. */ - *sta = 0; + *sta = ACPI_STA_DEFAULT; break; case ACPI_TYPE_PROCESSOR: *type = ACPI_BUS_TYPE_PROCESSOR; -- cgit v1.1 From aba941392aeef2d1bc064a1e4b09293473ef7b9b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 9 Aug 2018 11:15:56 +0200 Subject: ACPI / scan: Create platform device for fwnodes with multiple i2c devices Some devices have multiple I2cSerialBus resources and for things to work an i2c-client must be instantiated for each, each with its own i2c_device_id. Normally we only instantiate an i2c-client for the first resource, using the ACPI HID as id. This commit adds a list of HIDs of devices, which need multiple i2c-clients instantiated from a single fwnode, to acpi_device_enumeration_by_parent and makes acpi_device_enumeration_by_parent return false for these devices so that a platform device will be instantiated. This allows the drivers/platform/x86/i2c-multi-instantiate.c driver, which knows which i2c_device_id to use for each resource, to bind to the fwnode and initiate an i2c-client for each resource. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/scan.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 798a734..e1b6231 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1540,6 +1540,18 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) { struct list_head resource_list; bool is_serial_bus_slave = false; + /* + * These devices have multiple I2cSerialBus resources and an i2c-client + * must be instantiated for each, each with its own i2c_device_id. + * Normally we only instantiate an i2c-client for the first resource, + * using the ACPI HID as id. These special cases are handled by the + * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows + * which i2c_device_id to use for each resource. + */ + static const struct acpi_device_id i2c_multi_instantiate_ids[] = { + {"BSG1160", }, + {} + }; if (acpi_is_indirect_io_slave(device)) return true; @@ -1551,6 +1563,10 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) fwnode_property_present(&device->fwnode, "baud"))) return true; + /* Instantiate a pdev for the i2c-multi-instantiate drv to bind to */ + if (!acpi_match_device_ids(device, i2c_multi_instantiate_ids)) + return false; + INIT_LIST_HEAD(&resource_list); acpi_dev_get_resources(device, &resource_list, acpi_check_serial_bus_slave, -- cgit v1.1 From 21ba074cb47171a34f60e250e8f7ef3dc1529e43 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 9 Aug 2018 11:15:57 +0200 Subject: ACPI / x86: utils: Remove status workaround from acpi_device_always_present() Now that we init the status field to ACPI_STA_DEFAULT rather then to 0, the workaround for acpi_match_device_ids() always returning -ENOENT when status is 0 is no longer needed. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/x86/utils.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c index 3a13b2a..06c31ec 100644 --- a/drivers/acpi/x86/utils.c +++ b/drivers/acpi/x86/utils.c @@ -109,13 +109,9 @@ static const struct always_present_id always_present_ids[] = { bool acpi_device_always_present(struct acpi_device *adev) { - u32 *status = (u32 *)&adev->status; - u32 old_status = *status; bool ret = false; unsigned int i; - /* acpi_match_device_ids checks status, so set it to default */ - *status = ACPI_STA_DEFAULT; for (i = 0; i < ARRAY_SIZE(always_present_ids); i++) { if (acpi_match_device_ids(adev, always_present_ids[i].hid)) continue; @@ -131,15 +127,9 @@ bool acpi_device_always_present(struct acpi_device *adev) !dmi_check_system(always_present_ids[i].dmi_ids)) continue; - if (old_status != ACPI_STA_DEFAULT) /* Log only once */ - dev_info(&adev->dev, - "Device [%s] is in always present list\n", - adev->pnp.bus_id); - ret = true; break; } - *status = old_status; return ret; } -- cgit v1.1