diff mbox series

[1/7] platform/x86: thinkpad_acpi: Accept ibm_init_struct.init() returning -ENODEV

Message ID 20211121191129.256713-2-hdegoede@redhat.com (mailing list archive)
State Accepted, archived
Headers show
Series thinkpad_acpi: 1 bugfix + a bunch of cleanups | expand

Commit Message

Hans de Goede Nov. 21, 2021, 7:11 p.m. UTC
Commit 79f960e29cfc ("platform/x86: thinkpad_acpi: Convert platform driver
to use dev_groups") accidentally modified tpacpi_kbdlang_init() causing it
to return -ENODEV instead of 0 on machines without kbdlang support
(which are most of them).

ibm_init() sees this -ENODEV as an error causing the entire module to not
load, not good.

Note that technically tpacpi_kbdlang_init() was already buggy before, it
should have returned 1 instead of 0 if the feature is not present.

Rather then fixing tpacpi_kbdlang_init() though, IMHO it is bettter to
just make ibm_init() treat -ENODEV as 1 to fix the issue; and then in
a followup commit also change all the existing "return 1"s from
ibm_init_struct.init() callbacks to "return -ENODEV" as -ENODEV clearly
states what it going on where as a magic return of "1" requires a deep
dive into the code to figure out what is going on.

This will also allow removing some extra ifs to translate -ENODEV to
return 1 in a couple of init() callbacks.

Fixes: 79f960e29cfc ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 055930f5d9f5..62daf0109b4a 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10738,8 +10738,8 @@  static int __init ibm_init(struct ibm_init_struct *iibm)
 
 	if (iibm->init) {
 		ret = iibm->init(iibm);
-		if (ret > 0)
-			return 0;	/* probe failed */
+		if (ret > 0 || ret == -ENODEV)
+			return 0; /* subdriver functionality not available */
 		if (ret)
 			return ret;