platform/x86: thinkpad_acpi: Move subdriver initialization to tpacpi_pdriver's probe.
authorKurt Borja <kuurtb@gmail.com>
Sat, 15 Feb 2025 00:03:01 +0000 (19:03 -0500)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 24 Feb 2025 11:49:18 +0000 (13:49 +0200)
commit38b9ab80db31cf993a8f3ab2baf772083b62ca6f
treef7c56982a5cd9d0dce0454d1941e87c4a25158a3
parentc5855d2022b0d33702d5da24ed8caa80a3e57c23
platform/x86: thinkpad_acpi: Move subdriver initialization to tpacpi_pdriver's probe.

It was reported that if subdrivers assigned devres resources inside
ibm_init_struct's .init callbacks, driver binding would fail with the
following error message:

platform thinkpad_acpi: Resources present before probing

Let the driver core manage the lifetimes of the subdrivers and children
devices, by initializing them inside tpacpi_driver's .probe callback.
This is appropriate because these subdrivers usually expose sysfs groups
and the driver core manages this automatically to avoid races.

One immediate benefit of this, is that we are now able to use devres
inside .init subdriver callbacks.

platform_create_bundle is specifically used because it makes the
driver's probe type synchronous and returns an ERR_PTR if attachment
failed.

Additionally, to make error handling simpler, allocate the input device
using devm_input_allocate_device().

Reported-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Closes: https://lore.kernel.org/platform-driver-x86/20250208091438.5972-1-mpearson-lenovo@squebb.ca/#t
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250215000302.19753-2-kuurtb@gmail.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/thinkpad_acpi.c