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

drm/radeon: properly unregister hwmon interface (v2)

Need to properly unregister the hwmon device on driver
unload.

v2: minor clean up

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73931

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org

authored by

Alex Deucher and committed by
Christian König
cb3e4e7c 7e95cfb0

+15 -6
+15 -6
drivers/gpu/drm/radeon/radeon_pm.c
··· 603 603 static int radeon_hwmon_init(struct radeon_device *rdev) 604 604 { 605 605 int err = 0; 606 - struct device *hwmon_dev; 607 606 608 607 switch (rdev->pm.int_thermal_type) { 609 608 case THERMAL_TYPE_RV6XX: ··· 615 616 case THERMAL_TYPE_KV: 616 617 if (rdev->asic->pm.get_temperature == NULL) 617 618 return err; 618 - hwmon_dev = hwmon_device_register_with_groups(rdev->dev, 619 - "radeon", rdev, 620 - hwmon_groups); 621 - if (IS_ERR(hwmon_dev)) { 622 - err = PTR_ERR(hwmon_dev); 619 + rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev, 620 + "radeon", rdev, 621 + hwmon_groups); 622 + if (IS_ERR(rdev->pm.int_hwmon_dev)) { 623 + err = PTR_ERR(rdev->pm.int_hwmon_dev); 623 624 dev_err(rdev->dev, 624 625 "Unable to register hwmon device: %d\n", err); 625 626 } ··· 629 630 } 630 631 631 632 return err; 633 + } 634 + 635 + static void radeon_hwmon_fini(struct radeon_device *rdev) 636 + { 637 + if (rdev->pm.int_hwmon_dev) 638 + hwmon_device_unregister(rdev->pm.int_hwmon_dev); 632 639 } 633 640 634 641 static void radeon_dpm_thermal_work_handler(struct work_struct *work) ··· 1358 1353 device_remove_file(rdev->dev, &dev_attr_power_method); 1359 1354 } 1360 1355 1356 + radeon_hwmon_fini(rdev); 1357 + 1361 1358 if (rdev->pm.power_state) 1362 1359 kfree(rdev->pm.power_state); 1363 1360 } ··· 1378 1371 device_remove_file(rdev->dev, &dev_attr_power_method); 1379 1372 } 1380 1373 radeon_dpm_fini(rdev); 1374 + 1375 + radeon_hwmon_fini(rdev); 1381 1376 1382 1377 if (rdev->pm.power_state) 1383 1378 kfree(rdev->pm.power_state);