@@ -367,7 +367,6 @@ static struct {
367367 u32 beep_needs_two_args :1 ;
368368 u32 mixer_no_level_control :1 ;
369369 u32 battery_force_primary :1 ;
370- u32 sensors_pdrv_registered :1 ;
371370 u32 hotkey_poll_active :1 ;
372371 u32 has_adaptive_kbd :1 ;
373372 u32 kbd_lang :1 ;
@@ -11815,12 +11814,10 @@ static void thinkpad_acpi_module_exit(void)
1181511814{
1181611815 tpacpi_lifecycle = TPACPI_LIFE_EXITING ;
1181711816
11818- if (tpacpi_hwmon )
11819- hwmon_device_unregister (tpacpi_hwmon );
11820- if (tp_features .sensors_pdrv_registered )
11817+ if (tpacpi_sensors_pdev ) {
1182111818 platform_driver_unregister (& tpacpi_hwmon_pdriver );
11822- if (tpacpi_sensors_pdev )
1182311819 platform_device_unregister (tpacpi_sensors_pdev );
11820+ }
1182411821
1182511822 if (tpacpi_pdev ) {
1182611823 platform_driver_unregister (& tpacpi_pdriver );
@@ -11891,6 +11888,17 @@ static int __init tpacpi_pdriver_probe(struct platform_device *pdev)
1189111888 return ret ;
1189211889}
1189311890
11891+ static int __init tpacpi_hwmon_pdriver_probe (struct platform_device * pdev )
11892+ {
11893+ tpacpi_hwmon = devm_hwmon_device_register_with_groups (
11894+ & tpacpi_sensors_pdev -> dev , TPACPI_NAME , NULL , tpacpi_hwmon_groups );
11895+
11896+ if (IS_ERR (tpacpi_hwmon ))
11897+ pr_err ("unable to register hwmon device\n" );
11898+
11899+ return PTR_ERR_OR_ZERO (tpacpi_hwmon );
11900+ }
11901+
1189411902static int __init thinkpad_acpi_module_init (void )
1189511903{
1189611904 const struct dmi_system_id * dmi_id ;
@@ -11964,37 +11972,19 @@ static int __init thinkpad_acpi_module_init(void)
1196411972 return ret ;
1196511973 }
1196611974
11967- tpacpi_sensors_pdev = platform_device_register_simple (
11968- TPACPI_HWMON_DRVR_NAME ,
11969- PLATFORM_DEVID_NONE , NULL , 0 );
11975+ tpacpi_sensors_pdev = platform_create_bundle ( & tpacpi_hwmon_pdriver ,
11976+ tpacpi_hwmon_pdriver_probe ,
11977+ NULL , 0 , NULL , 0 );
1197011978 if (IS_ERR (tpacpi_sensors_pdev )) {
1197111979 ret = PTR_ERR (tpacpi_sensors_pdev );
1197211980 tpacpi_sensors_pdev = NULL ;
11973- pr_err ("unable to register hwmon platform device\n" );
11981+ pr_err ("unable to register hwmon platform device/driver bundle \n" );
1197411982 thinkpad_acpi_module_exit ();
1197511983 return ret ;
1197611984 }
1197711985
1197811986 tpacpi_lifecycle = TPACPI_LIFE_RUNNING ;
1197911987
11980- ret = platform_driver_register (& tpacpi_hwmon_pdriver );
11981- if (ret ) {
11982- pr_err ("unable to register hwmon platform driver\n" );
11983- thinkpad_acpi_module_exit ();
11984- return ret ;
11985- }
11986- tp_features .sensors_pdrv_registered = 1 ;
11987-
11988- tpacpi_hwmon = hwmon_device_register_with_groups (
11989- & tpacpi_sensors_pdev -> dev , TPACPI_NAME , NULL , tpacpi_hwmon_groups );
11990- if (IS_ERR (tpacpi_hwmon )) {
11991- ret = PTR_ERR (tpacpi_hwmon );
11992- tpacpi_hwmon = NULL ;
11993- pr_err ("unable to register hwmon device\n" );
11994- thinkpad_acpi_module_exit ();
11995- return ret ;
11996- }
11997-
1199811988 return 0 ;
1199911989}
1200011990
0 commit comments