Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 19 additions & 26 deletions drivers/hwmon/macsmc-hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
Loading