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

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: thinkpad_acpi: Move HWMON initialization to tpacpi_hwmon_pdriver's probe

Let the driver core manage the lifetime of the HWMON device, by
registering it inside tpacpi_hwmon_pdriver's probe and using
devm_hwmon_device_register_with_groups().

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250215000302.19753-3-kuurtb@gmail.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Kurt Borja and committed by
Ilpo Järvinen
43fc63a1 38b9ab80

+17 -27
+17 -27
drivers/platform/x86/thinkpad_acpi.c
··· 367 367 u32 beep_needs_two_args:1; 368 368 u32 mixer_no_level_control:1; 369 369 u32 battery_force_primary:1; 370 - u32 sensors_pdrv_registered:1; 371 370 u32 hotkey_poll_active:1; 372 371 u32 has_adaptive_kbd:1; 373 372 u32 kbd_lang:1; ··· 11814 11815 { 11815 11816 tpacpi_lifecycle = TPACPI_LIFE_EXITING; 11816 11817 11817 - if (tpacpi_hwmon) 11818 - hwmon_device_unregister(tpacpi_hwmon); 11819 - if (tp_features.sensors_pdrv_registered) 11818 + if (tpacpi_sensors_pdev) { 11820 11819 platform_driver_unregister(&tpacpi_hwmon_pdriver); 11821 - if (tpacpi_sensors_pdev) 11822 11820 platform_device_unregister(tpacpi_sensors_pdev); 11821 + } 11823 11822 11824 11823 if (tpacpi_pdev) { 11825 11824 platform_driver_unregister(&tpacpi_pdriver); ··· 11886 11889 pr_err("unable to register input device\n"); 11887 11890 11888 11891 return ret; 11892 + } 11893 + 11894 + static int __init tpacpi_hwmon_pdriver_probe(struct platform_device *pdev) 11895 + { 11896 + tpacpi_hwmon = devm_hwmon_device_register_with_groups( 11897 + &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); 11898 + 11899 + if (IS_ERR(tpacpi_hwmon)) 11900 + pr_err("unable to register hwmon device\n"); 11901 + 11902 + return PTR_ERR_OR_ZERO(tpacpi_hwmon); 11889 11903 } 11890 11904 11891 11905 static int __init thinkpad_acpi_module_init(void) ··· 11972 11964 return ret; 11973 11965 } 11974 11966 11975 - tpacpi_sensors_pdev = platform_device_register_simple( 11976 - TPACPI_HWMON_DRVR_NAME, 11977 - PLATFORM_DEVID_NONE, NULL, 0); 11967 + tpacpi_sensors_pdev = platform_create_bundle(&tpacpi_hwmon_pdriver, 11968 + tpacpi_hwmon_pdriver_probe, 11969 + NULL, 0, NULL, 0); 11978 11970 if (IS_ERR(tpacpi_sensors_pdev)) { 11979 11971 ret = PTR_ERR(tpacpi_sensors_pdev); 11980 11972 tpacpi_sensors_pdev = NULL; 11981 - pr_err("unable to register hwmon platform device\n"); 11973 + pr_err("unable to register hwmon platform device/driver bundle\n"); 11982 11974 thinkpad_acpi_module_exit(); 11983 11975 return ret; 11984 11976 } 11985 11977 11986 11978 tpacpi_lifecycle = TPACPI_LIFE_RUNNING; 11987 - 11988 - ret = platform_driver_register(&tpacpi_hwmon_pdriver); 11989 - if (ret) { 11990 - pr_err("unable to register hwmon platform driver\n"); 11991 - thinkpad_acpi_module_exit(); 11992 - return ret; 11993 - } 11994 - tp_features.sensors_pdrv_registered = 1; 11995 - 11996 - tpacpi_hwmon = hwmon_device_register_with_groups( 11997 - &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); 11998 - if (IS_ERR(tpacpi_hwmon)) { 11999 - ret = PTR_ERR(tpacpi_hwmon); 12000 - tpacpi_hwmon = NULL; 12001 - pr_err("unable to register hwmon device\n"); 12002 - thinkpad_acpi_module_exit(); 12003 - return ret; 12004 - } 12005 11979 12006 11980 return 0; 12007 11981 }