From: Lorenzo Castellani <lorenzo.castellani@pd.infn.it>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] w1: w1_therm: fix missing therm_bulk_read sysfs attribute with multiple bus masters
Date: Wed, 30 Sep 2026 08:01:09 +0200 [thread overview]
Message-ID: <ac2cdbd8-ce83-47ed-9783-4e5b8dd0e11f@pd.infn.it> (raw)
In-Reply-To: <73adf4db-52f8-439f-99d4-1dab14e1bfc7@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]
The patch is attached.
Lorenzo
Il 30/09/2026 07:23, Krzysztof Kozlowski ha scritto:
> On 27/09/2026 12:43, lorenzo.castellani wrote:
>> From 32e145b49cf41ce150a97ce52c63f5aae1bbbea7 Mon Sep 17 00:00:00 2001
>> From: Lorenzo Castellani <lorenzo.castellani@pd.infn.it>
>> Date: Tue, 22 Sep 2026 11:12:30 +0200
>> Subject: [PATCH] w1: w1_therm: fix missing therm_bulk_read sysfs attribute
>> with multiple bus masters
> Your mailing is corrupted.
>
>> +static int w1_therm_count_bulk_read_slaves(struct w1_master *dev_master,
>> + struct w1_slave *exclude_sl)
>> +{
>> + struct w1_slave *sl;
>> + int count = 0;
>> +
>> + list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
>> + if (sl != exclude_sl && sl->family_data && bulk_read_support(sl))
>> + count++;
>> + }
>> + return count;
>> +}
> And here.
>
> Best regards,
> Krzysztof
--
--------------------------------------
Lorenzo Castellani
Istituto Nazionale di Fisica Nucleare
Sezione di Padova
Via Marzolo 8
35131 PADOVA
Italy
E-mail: lorenzo.castellani@pd.infn.it
Phone: +39 049 9677227
--------------------------------------
[-- Attachment #2: 0001-w1-w1_therm-fix-missing-therm_bulk_read-sysfs-attrib.patch --]
[-- Type: text/plain, Size: 3552 bytes --]
From 32e145b49cf41ce150a97ce52c63f5aae1bbbea7 Mon Sep 17 00:00:00 2001
From: Lorenzo Castellani <lorenzo.castellani@pd.infn.it>
Date: Tue, 22 Sep 2026 11:12:30 +0200
Subject: [PATCH] w1: w1_therm: fix missing therm_bulk_read sysfs attribute
with multiple bus masters
When multiple 1-Wire bus masters are present in the
system, the global module-level counter causes the
therm_bulk_read sysfs attribute to be created only
for the first master where a bulk-read capable slave
is discovered. Subsequent bus masters fail to expose
the attribute because the counter is already non-zero.
Fix this by replacing the global static counter with
a per-master helper function that iterates over the
slaves associated specifically with the given master
(dev_master->slist). This ensures that each bus
master independently correctly tracks and exposes the
therm_bulk_read sysfs attribute when bulk-read
capable devices are present.
Signed-off-by: Lorenzo Castellani <lorenzo.castellani@pd.infn.it>
---
linux-rpi-6.18.y/drivers/w1/slaves/w1_therm.c | 30 ++++++++++++-------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/linux-rpi-6.18.y/drivers/w1/slaves/w1_therm.c b/linux-rpi-6.18.y/drivers/w1/slaves/w1_therm.c
index 832e3da94..4c8e67ec8 100644
--- a/linux-rpi-6.18.y/drivers/w1/slaves/w1_therm.c
+++ b/linux-rpi-6.18.y/drivers/w1/slaves/w1_therm.c
@@ -44,9 +44,6 @@
static int w1_strong_pullup = 1;
module_param_named(strong_pullup, w1_strong_pullup, int, 0);
-/* Counter for devices supporting bulk reading */
-static u16 bulk_read_device_counter; /* =0 as per C standard */
-
/* This command should be in public header w1.h but is not */
#define W1_RECALL_EEPROM 0xB8
@@ -968,6 +965,19 @@ static inline s8 int_to_short(int i)
/* Interface Functions */
+static int w1_therm_count_bulk_read_slaves(struct w1_master *dev_master,
+ struct w1_slave *exclude_sl)
+{
+ struct w1_slave *sl;
+ int count = 0;
+
+ list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
+ if (sl != exclude_sl && sl->family_data && bulk_read_support(sl))
+ count++;
+ }
+ return count;
+}
+
static int w1_therm_add_slave(struct w1_slave *sl)
{
struct w1_therm_family_converter *sl_family_conv;
@@ -992,9 +1002,11 @@ static int w1_therm_add_slave(struct w1_slave *sl)
if (bulk_read_support(sl)) {
/*
* add the sys entry to trigger bulk_read
- * at master level only the 1st time
+ * at master level only the 1st time on this master
*/
- if (!bulk_read_device_counter) {
+ int bulk_count = w1_therm_count_bulk_read_slaves(sl->master, sl);
+
+ if (!bulk_count) {
int err = device_create_file(&sl->master->dev,
&dev_attr_therm_bulk_read);
@@ -1003,8 +1015,6 @@ static int w1_therm_add_slave(struct w1_slave *sl)
"%s: Device has been added, but bulk read is unavailable. err=%d\n",
__func__, err);
}
- /* Increment the counter */
- bulk_read_device_counter++;
}
/* Getting the power mode of the device {external, parasite} */
@@ -1040,9 +1050,9 @@ static void w1_therm_remove_slave(struct w1_slave *sl)
int refcnt = atomic_sub_return(1, THERM_REFCNT(sl->family_data));
if (bulk_read_support(sl)) {
- bulk_read_device_counter--;
- /* Delete the entry if no more device support the feature */
- if (!bulk_read_device_counter)
+ int bulk_count = w1_therm_count_bulk_read_slaves(sl->master, sl);
+ /* Delete the entry if no more device support the feature on this master */
+ if (!bulk_count)
device_remove_file(&sl->master->dev,
&dev_attr_therm_bulk_read);
}
--
2.43.0
next prev parent reply other threads:[~2026-09-30 6:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 10:43 lorenzo.castellani
2026-09-30 5:23 ` Krzysztof Kozlowski
2026-09-30 6:01 ` Lorenzo Castellani [this message]
2026-09-30 8:41 ` Krzysztof Kozlowski
-- strict thread matches above, loose matches on Subject: below --
2026-09-27 9:59 Lorenzo Castellani
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=ac2cdbd8-ce83-47ed-9783-4e5b8dd0e11f@pd.infn.it \
--to=lorenzo.castellani@pd.infn.it \
--cc=krzk@kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®