diff mbox series

[07/10] platform: mips: cpu_hwmon: Disable driver on unsupported hardware

Message ID 20240614-ls3k-mips-v1-7-7614340ace7d@flygoat.com (mailing list archive)
State Accepted
Commit f4d430db17b4ef4e9c3c352a04b2fe3c93011978
Headers show
Series MIPS: Loongson64: Loongson-2K1000 fixes | expand

Commit Message

Jiaxun Yang June 14, 2024, 3:40 p.m. UTC
cpu_hwmon is unsupported on CPUs without loongson_chiptemp
register and csr.

Cc: stable@vger.kernel.org
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/platform/mips/cpu_hwmon.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/platform/mips/cpu_hwmon.c b/drivers/platform/mips/cpu_hwmon.c
index d8c5f9195f85..2ac2f31090f9 100644
--- a/drivers/platform/mips/cpu_hwmon.c
+++ b/drivers/platform/mips/cpu_hwmon.c
@@ -139,6 +139,9 @@  static int __init loongson_hwmon_init(void)
 		csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) &
 				  LOONGSON_CSRF_TEMP;
 
+	if (!csr_temp_enable && !loongson_chiptemp[0])
+		return -ENODEV;
+
 	nr_packages = loongson_sysconf.nr_cpus /
 		loongson_sysconf.cores_per_package;