diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c index c519c70755c00..87ad71b3984d3 100644 --- a/drivers/hwmon/macsmc-hwmon.c +++ b/drivers/hwmon/macsmc-hwmon.c @@ -58,15 +58,6 @@ module_param_unsafe(fan_control, bool, 0644); MODULE_PARM_DESC(fan_control, "Allow manual fan speeds on every fan with a mode key, also where the device tree does not (default: the device tree decides)"); -static bool macsmc_hwmon_is_m3(void) -{ - return of_machine_is_compatible("apple,t6030") || - of_machine_is_compatible("apple,t6031") || - of_machine_is_compatible("apple,t6032") || - of_machine_is_compatible("apple,t6034") || - of_machine_is_compatible("apple,t8122"); -} - struct macsmc_hwmon_sensor { struct apple_smc_key_info info; smc_key macsmc_key; @@ -863,22 +854,25 @@ static int macsmc_hwmon_create_sensor(struct device *dev, struct apple_smc *smc, if (ret) return ret; - if (macsmc_hwmon_is_m3()) { - if (!(sensor->info.flags & APPLE_SMC_READABLE)) - return -EACCES; + /* + * Admit a key only if its own metadata says it can be read in a + * format macsmc_hwmon_read_key() decodes. Any other key could only + * fail every read, whatever the SoC. + */ + if (!(sensor->info.flags & APPLE_SMC_READABLE)) + return -EACCES; - switch (sensor->info.type_code) { - case __SMC_KEY('f', 'l', 't', ' '): - if (sensor->info.size != sizeof(u32)) - return -EINVAL; - break; - case __SMC_KEY('i', 'o', 'f', 't'): - if (sensor->info.size != sizeof(u64)) - return -EINVAL; - break; - default: - return -EOPNOTSUPP; - } + switch (sensor->info.type_code) { + case __SMC_KEY('f', 'l', 't', ' '): + if (sensor->info.size != sizeof(u32)) + return -EINVAL; + break; + case __SMC_KEY('i', 'o', 'f', 't'): + if (sensor->info.size != sizeof(u64)) + return -EINVAL; + break; + default: + return -EOPNOTSUPP; } ret = of_property_read_string(sensor_node, "label", &label); @@ -1680,8 +1674,7 @@ static int macsmc_hwmon_probe(struct platform_device *pdev) return dev_err_probe(hwmon->dev, PTR_ERR(hwmon->hwmon_dev), "Probing SMC hwmon device failed\n"); - if (macsmc_hwmon_is_m3() || of_machine_is_compatible("apple,t6050")) - macsmc_hwmon_debugfs_init(hwmon); + macsmc_hwmon_debugfs_init(hwmon); ret = macsmc_hwmon_die_register(hwmon); if (ret)