Skip to contentSkip to conversation

docs: python: abi_parser: Detect a symbol repeated on one file

PATCH New TAKANO Mitsuhiro 2 participants 4 messages Nov 25

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 docs: python: abi_parser: Detect a symbol repeated on one file

check_issues() warns when a symbol shows up on more than one file, but it never looks at a symbol that two entries on the same file claim:
"if len(files) == 1: continue" skips that case.

The parser stores every entry under a key of its own, so a repeated symbol on one file is visible as two entries with the same file. Compare at that level and warn, and keep the cross-file case informational, because two drivers may expose an attribute with the same name for different devices, as sysfs-driver-hid-lenovo-go and sysfs-driver-hid-lenovo-go-s do.

Verification: get_abi.py --dir Documentation/ABI validate used to print four warnings for the cross-file case and nothing for the repeated one. It now prints four informational messages for the former and two warnings for the latter, at sysfs-driver-mlxreg-io lines 348 and 744 and at sysfs-driver-hid-lenovo-go lines 389 and 566.

---
 tools/lib/python/abi/abi_parser.py | 47 +++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 17 deletions(-)
tools/lib/python/abi/abi_parser.py +30 -17
index d7bb20ef3acc..519ccacbadca 100644
@@ -554,28 +554,41 @@ class AbiParser:
     def check_issues(self):
         """Warn about duplicated ABI entries."""
 
-        for what, v in self.what_symbols.items():
-            files = v.get("file")
-            if not files:
-                # Should never happen if the parser works properly
-                self.log.warning("%s doesn't have a file associated", what)
+        # Two entries on the same file that claim the same symbol are a
+        # copy-and-paste mistake.  The parser gives every entry a key of its
+        # own, so such a pair shows up as two entries here.
+        per_file = {}
+        for key, v in self.data.items():
+            if v.get("type") == "File":
                 continue
 
-            if len(files) == 1:
+            file_ref = v.get("file") or [None]
+            fname = file_ref[0]
+            if fname:
+                fname = fname[0]
+
+            for what in v.get("what", []):
+                per_file.setdefault((fname, what), []).append(v.get("line_no"))
+
+        for (fname, what), lines in sorted(per_file.items()):
+            if len(lines) < 2:
                 continue
 
-            f = []
-            for fname, lines in sorted(files.items()):
-                if not lines:
-                    f.append(f"{fname}")
-                elif len(lines) == 1:
-                    f.append(f"{fname}:{lines[0]}")
-                else:
-                    m = fname + "lines "
-                    m += ", ".join(str(x) for x in lines)
-                    f.append(m)
+            self.log.warning("%s is defined %d times at %s: lines %s",
+                             what, len(lines), fname,
+                             ", ".join(str(x) for x in lines))
+
+        # The same symbol on more than one file is normal: two drivers may
+        # expose an attribute with the same name for different devices, as
+        # sysfs-driver-hid-lenovo-go and sysfs-driver-hid-lenovo-go-s do.
+        # Report it, but do not call it a problem.
+        for what, v in self.what_symbols.items():
+            files = v.get("file")
+            if not files or len(files) < 2:
+                continue
 
-            self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
+            self.log.info("%s is documented on %d files: %s", what,
+                          len(files), "; ".join(sorted(files)))
 
     def search_symbols(self, expr):
         """ Searches for ABI symbols."""

base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f

Signature · 1 line
2.53.0
#1 lore raw

PATCH 2/3 docs: ABI: hid-lenovo-go: Point one entry at the version group

The protocol version of the internal MCU is exposed through the "version" attribute group, but two entries claim right_handle/protocol_version: the one that describes the internal MCU and the one that describes the right removable controller.

The "version" group has no entry at all. Point the internal MCU entry at version/protocol_version, which matches the description it already carries and the group hid-lenovo-go.c puts it in:

LEGO_DEVICE_ATTR_RO(version_protocol_mcu, "protocol_version",

                      USB_MCU, version);

Verification: get_abi.py --dir Documentation/ABI validate no longer reports right_handle/protocol_version twice.

---
 Documentation/ABI/testing/sysfs-driver-hid-lenovo-go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-driver-hid-lenovo-go +1 -1
index c8221373ef76..ed8d9a35b8ca 100644
@@ -386,7 +386,7 @@ Description:	This displays the product version of the internal MCU.
 
 		Applies to Lenovo Legion Go and Go 2 line of handheld devices.
 
-What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/right_handle/protocol_version
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/version/protocol_version
 Date:		April 2026
 Contact:	[email protected]
 Description:	This displays the protocol version of the internal MCU.
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 2/3] docs: ABI: hid-lenovo-go: Point one entry at the version group

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] docs: ABI: hid-lenovo-go: internal MCU protocol_version uses nonexistent path --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] docs: ABI: hid-lenovo-go: internal MCU protocol_version uses nonexistent path
--

commit 59c6e641f7a91e766d489a67c548d903d75c5b71
Author: TAKANO Mitsuhiro <[email protected]>

docs: ABI: hid-lenovo-go: Point one entry at the version group

This commit updates the sysfs ABI path for the internal MCU protocol_version attribute to avoid a duplicate right_handle/protocol_version entry in Documentation/ABI/testing/sysfs-driver-hid-lenovo-go.

Documentation/ABI/testing/sysfs-driver-hid-lenovo-go Description: This displays the product version of the internal MCU. · line 392

Quoted 13 lines
Documentation/ABI/testing/sysfs-driver-hid-lenovo-go +1 -1
index c8221373ef76a..ed8d9a35b8ca4 100644
@@ -386,7 +386,7 @@ Description:	This displays the product version of the internal MCU.
 
 		Applies to Lenovo Legion Go and Go 2 line of handheld devices.
 
-What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/right_handle/protocol_version
+What:		/sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/version/protocol_version
 Date:		April 2026
 Contact:	[email protected]
 Description:	This displays the protocol version of the internal MCU.

[Severity: Low]
Should this path be top-level .../protocol_version without the version/ subdirectory?

In LEGO_DEVICE_ATTR_RO(_name, _attrname, _dtype, _group), the fourth argument selects the _group##_show() callback prefix (version_show()), not a sysfs attribute group name. dev_attr_version_protocol_mcu.attr is added to mcu_attr_group, which has no .name field, so protocol_version is exposed directly in the HID device top-level directory alongside product_version and firmware_version:

drivers/hid/hid-lenovo-go.c:

    ...
	&dev_attr_version_product_mcu.attr,
	&dev_attr_version_protocol_mcu.attr,
	NULL,
};

static const struct attribute_group mcu_attr_group = {
.attrs = mcu_attrs,
};

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#3 lore raw

PATCH 3/3 docs: ABI: mlxreg-io: Drop the second shutdown_unlock entry

In reply to TAKANO Mitsuhiro

Commit 4e29dd3821df ("Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces") added shutdown_unlock as a new attribute, but sysfs-driver-mlxreg-io already described it in the October 2021 block. The tree ended up with two entries for the same file, and with two different defaults: the older one says "Default is 1", the newer one says "Default value is 0".

Keep the entry that came first, which documents the behaviour in full and carries the kernel version the attribute appeared in, and drop the later copy.

Verification: get_abi.py --dir Documentation/ABI validate no longer reports shutdown_unlock twice.

---
 Documentation/ABI/stable/sysfs-driver-mlxreg-io | 12 ------------
 1 file changed, 12 deletions(-)
Documentation/ABI/stable/sysfs-driver-mlxreg-io +0 -12
index f59461111221..00cff8965b22 100644
@@ -741,18 +741,6 @@ Description:	This file, when set 1, indicates that access to protected
 
 		The file is read only.
 
-What:		/sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/shutdown_unlock
-Date:		May 2025
-KernelVersion:	6.16
-Contact:	Vadim Pasternak <[email protected]>
-Description:	When ASICs are getting overheated, system protection
-		hardware mechanism enforces system reboot. After system
-		reboot ASICs come up in locked state. To unlock ASICs,
-		this file should be written 1
-		Default value is 0.
-
-		The file is read/write.
-
 What:		/sys/devices/platform/mlxplat/i2c_mlxcpld.*/i2c-*/i2c-*/*-00**/mlxreg-io.*/hwmon/hwmon*/boot_progress
 Date:		May 2025
 KernelVersion:	6.16
Signature · 1 line
2.53.0