diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 4e2a17fdb6a7..9b9fa51067bd 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1015,8 +1015,6 @@ static int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void device_initialize(&cdev->device); cdev->devdata = devdata; - thermal_cooling_device_setup_sysfs(cdev); - ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); if (ret) goto out_put_device; @@ -1037,6 +1035,8 @@ static int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void if (ret) current_state = ULONG_MAX; + thermal_cooling_device_setup_sysfs(cdev); + ret = device_add(&cdev->device); if (ret) goto out_put_device;