All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs
@ 2026-10-18 11:32 Aditya Garg
  2026-10-18 11:37 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages 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 related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs
  2026-10-18 11:32 [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs Aditya Garg
@ 2026-10-18 11:37 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-18 11:37 UTC (permalink / raw)
  To: Aditya Garg; +Cc: linux-hwmon

> 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)) {
> [ ... ]
> 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>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261018113248.12243-1-aditya.garg@linux.dev?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-18 11:37 UTC | newest]

Thread overview: 2+ messages (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
2026-10-18 11:37 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.