Commit ad7f6cc3 authored by Tero Kristo's avatar Tero Kristo Committed by Jia, Yingbao
Browse files

platform/x86/intel-uncore-freq: Use generic helpers for current frequency

mainline inclusion
from mainline-v6.11
commit 7b3ffe0d815d15310545f77d444ada92c5d26903
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IB6QCW
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7b3ffe0d815d15310545f77d444ada92c5d26903



-------------------------------------------------

Intel-SIG: commit 7b3ffe0d815d platform/x86/intel-uncore-freq: Use generic helpers for current frequency.
Backport Intel-uncore-freq driver support for 6.6 from 6.11.

Use the generic sysfs helpers for reading the current frequency also,
and remove the custom ones.

No functional change intended.

Signed-off-by: default avatarTero Kristo <tero.kristo@linux.intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20240617060708.892981-8-tero.kristo@linux.intel.com


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Yingbao Jia: amend commit log ]
Signed-off-by: default avatarYingbao Jia <yingbao.jia@intel.com>
parent 1ce8d8f7
Loading
Loading
Loading
Loading
+1 −24
Original line number Diff line number Diff line
@@ -76,20 +76,6 @@ static ssize_t store_attr(struct uncore_data *data, const char *buf, ssize_t cou
	return count;
}

static ssize_t show_perf_status_freq_khz(struct uncore_data *data, char *buf)
{
	unsigned int freq;
	int ret;

	mutex_lock(&uncore_lock);
	ret = uncore_read(data, &freq, UNCORE_INDEX_CURRENT_FREQ);
	mutex_unlock(&uncore_lock);
	if (ret)
		return ret;

	return sprintf(buf, "%u\n", freq);
}

#define store_uncore_attr(name, index)					\
	static ssize_t store_##name(struct kobject *kobj,		\
				     struct kobj_attribute *attr,	\
@@ -109,22 +95,13 @@ static ssize_t show_perf_status_freq_khz(struct uncore_data *data, char *buf)
		return show_attr(data, buf, index);			\
	}

#define show_uncore_perf_status(name)					\
	static ssize_t show_##name(struct kobject *kobj,		\
				   struct kobj_attribute *attr, char *buf)\
	{                                                               \
		struct uncore_data *data = container_of(attr, struct uncore_data, name##_kobj_attr);\
									\
		return show_perf_status_freq_khz(data, buf); \
	}

store_uncore_attr(min_freq_khz, UNCORE_INDEX_MIN_FREQ);
store_uncore_attr(max_freq_khz, UNCORE_INDEX_MAX_FREQ);

show_uncore_attr(min_freq_khz, UNCORE_INDEX_MIN_FREQ);
show_uncore_attr(max_freq_khz, UNCORE_INDEX_MAX_FREQ);

show_uncore_perf_status(current_freq_khz);
show_uncore_attr(current_freq_khz, UNCORE_INDEX_CURRENT_FREQ);

#define show_uncore_data(member_name)					\
	static ssize_t show_##member_name(struct kobject *kobj,	\