mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs
@ 2026-10-18 11:32 Aditya Garg
  0 siblings, 0 replies; only message in thread
From: Aditya Garg @ 2026-10-18 11:32 UTC (permalink / raw)
  To: Sven Peter, Janne Grunau, Neal Gompa, Guenter Roeck
  Cc: asahi, linux-arm-kernel, linux-hwmon, linux-kernel

The fan_control module parameter in the driver enables/disables the user's
ability to manually modify the fan speeds. In case the user attempts to
change the module parameter via sysfs rather than at the time of modprobe,
changing fan speeds is still restricted.

The reason behind this is because during probe the fan_control variable is
used to restrict the user in the following two ways:

1.	if (!fan_control || hwmon->fan.fans[channel].mode.macsmc_key == 0)
		return -EOPNOTSUPP;

Here, if disabled, the OS will return an error and will not allow changing
the speeds.

2.	if (fan->attrs & BIT(attr)) {
		if (attr == hwmon_fan_target && fan_control && fan->mode.macsmc_key)
			return 0644;

		return 0444;
	}

Here, if disabled, the sysfs files are with permissions 0444.

In case a user changes the module parameter via sysfs, due to the second
check, the sysfs files remain with permissions 0444, and user isn't able to
change the speeds.

Since 2 checks are practically unnecessary, and the second is causing problems
this patch removes the second check. Now, if the module parameter is changed
via sysfs, the first check will pass and user will be able to modify the fan
speeds.

Signed-off-by: Aditya Garg <aditya.garg@linux.dev>
---
 drivers/hwmon/macsmc-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c
index 1500ec2cc..76c485832 100644
--- a/drivers/hwmon/macsmc-hwmon.c
+++ b/drivers/hwmon/macsmc-hwmon.c
@@ -390,7 +390,7 @@ static umode_t macsmc_hwmon_fan_is_visible(const struct macsmc_hwmon_fan *fan,
 					   u32 attr)
 {
 	if (fan->attrs & BIT(attr)) {
-		if (attr == hwmon_fan_target && fan_control && fan->mode.macsmc_key)
+		if (attr == hwmon_fan_target && fan->mode.macsmc_key)
 			return 0644;
 
 		return 0444;
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-18 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 11:32 [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs Aditya Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®