From: Aditya Garg <aditya.garg@linux.dev>
To: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Neal Gompa <neal@gompa.dev>, Guenter Roeck <linux@roeck-us.net>
Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs
Date: Sun, 18 Oct 2026 17:02:48 +0530 [thread overview]
Message-ID: <20261018113248.12243-1-aditya.garg@linux.dev> (raw)
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
reply other threads:[~2026-10-18 11:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018113248.12243-1-aditya.garg@linux.dev \
--to=aditya.garg@linux.dev \
--cc=asahi@lists.linux.dev \
--cc=j@jannau.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=neal@gompa.dev \
--cc=sven@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®