From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Javier Carrasco <javier.carrasco.cruz@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators
Date: Sun, 23 Aug 2026 19:59:04 +0200 [thread overview]
Message-ID: <20260823-chipcap2_locks-v2-4-6a26c8e9e2fc@gmail.com> (raw)
In-Reply-To: <20260823-chipcap2_locks-v2-0-6a26c8e9e2fc@gmail.com>
Access to low_alarm and high_alarm from the threaded interrupt handlers
and sysfs is not protected by any locking mechanism at the moment, which
can lead to missed events.
Use the hwmon subsystem lock to serialize access to the alarm indicators
and update their state before generating the corresponding event to keep
a consistent state.
Fixes: 3af350929e75 ("hwmon: Add support for Amphenol ChipCap 2")
Cc: stable@vger.kernel.org
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/hwmon/chipcap2.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c
index 57d22d65612c..0a56c55e9394 100644
--- a/drivers/hwmon/chipcap2.c
+++ b/drivers/hwmon/chipcap2.c
@@ -495,9 +495,11 @@ static irqreturn_t cc2_low_interrupt(int irq, void *data)
struct cc2_data *cc2 = data;
if (cc2->process_irqs) {
+ scoped_guard(hwmon_lock, cc2->hwmon);
+ cc2->rh_alarm.low_alarm = true;
+
hwmon_notify_event(cc2->hwmon, hwmon_humidity,
hwmon_humidity_min_alarm, 0);
- cc2->rh_alarm.low_alarm = true;
}
return IRQ_HANDLED;
@@ -508,9 +510,11 @@ static irqreturn_t cc2_high_interrupt(int irq, void *data)
struct cc2_data *cc2 = data;
if (cc2->process_irqs) {
+ scoped_guard(hwmon_lock, cc2->hwmon);
+ cc2->rh_alarm.high_alarm = true;
+
hwmon_notify_event(cc2->hwmon, hwmon_humidity,
hwmon_humidity_max_alarm, 0);
- cc2->rh_alarm.high_alarm = true;
}
return IRQ_HANDLED;
--
2.43.0
next prev parent reply other threads:[~2026-08-23 17:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 17:59 [PATCH v2 0/4] hwmon: chipcap2: various bug fixes Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 1/4] hwmon: chipcap2: fix channels in humidity alarm notifications Javier Carrasco
2026-08-23 18:11 ` sashiko-bot
2026-08-23 18:17 ` Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 2/4] hwmon: chipcap2: fix IRQ teardown ordering Javier Carrasco
2026-08-23 18:12 ` sashiko-bot
2026-08-23 18:22 ` Javier Carrasco
2026-08-23 21:14 ` Javier Carrasco
2026-08-23 17:59 ` [PATCH v2 3/4] hwmon: chipcap2: enable IRQ processing when regulator is already enabled Javier Carrasco
2026-08-23 18:11 ` sashiko-bot
2026-08-23 19:13 ` Javier Carrasco
2026-08-23 17:59 ` Javier Carrasco [this message]
2026-08-23 18:06 ` [PATCH v2 4/4] hwmon: chipcap2: serialize access to low/high_alarm indicators sashiko-bot
2026-08-23 18:16 ` Javier Carrasco
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=20260823-chipcap2_locks-v2-4-6a26c8e9e2fc@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=stable@vger.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