int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
{
	unsigned int cpu = dev->id;
	struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);

	if (!policy)
		return;

	scoped_guard(cpufreq_policy_write, policy) {
		if (cpu_online(cpu))
			__cpufreq_offline(cpu, policy);

		remove_cpu_dev_symlink(policy, cpu, dev);

		if (!cpumask_empty(policy->real_cpus))
			return 0;

		/*
		 * Unregister cpufreq cooling once all the CPUs of the policy
		 * are removed.
		 */
		if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
			cpufreq_cooling_unregister(policy->cdev);
			policy->cdev = NULL;
		}

		/* We did light-weight exit earlier, do full tear down now */
		if (cpufreq_driver->offline && cpufreq_driver->exit)
			cpufreq_driver->exit(policy);
	}

	cpufreq_policy_free(policy);
}
