[PATCH net-next 6/9] ptp: ocp: report fw.cpld with an empty value until the USERCODE is read

From: Sagi Maimon

Date: Tue Sep 22 2026 - 10:36:58 EST


The fw.cpld running version was published as the literal string "unknown"
before the USERCODE had been read, which contradicts both the changelog
and the .rst entry describing it as the USERCODE formatted as 0x%08x, and
is not a version anyone can use.

The string was there because naming the component is what lets
"devlink dev flash ... component fw.cpld" through, and a part left holding
a bad image answers neither READ_ID nor READ_USERCODE - gating the
component on the read would make exactly that state unrecoverable.

An empty value gives both: devlink_info_version_put() invokes its
version_cb, which is what devlink_flash_component_get() collects names
with, before returning early on an empty value, so the component stays
flashable while no version attribute is emitted.

Suggested-by: netdev-bot+sashiko@xxxxxxxxxx
Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink")
Signed-off-by: Sagi Maimon <maimon.sagi@xxxxxxxxx>
---
drivers/ptp/ptp_ocp.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index e10f6b5149c9..4ce86df6e196 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2264,15 +2264,20 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
/* The flashable component. Naming it here is what lets
* "devlink dev flash ... component fw.cpld" through, as the
* core matches the name against the versions reported here,
- * so it is reported for every board that has the part and not
+ * so it is named for every board that has the part and not
* only once its USERCODE has been read: a part left holding a
* bad image answers neither, and gating the component on the
* read would make that state unrecoverable.
+ *
+ * An empty value still registers the name with the core -
+ * devlink_info_version_put() runs its version_cb before the
+ * empty-value early-out - while emitting no version attribute,
+ * so nothing is published until the USERCODE has been read.
*/
if (smp_load_acquire(&bp->cpld_usercode_ok))
sprintf(buf, "0x%08x", READ_ONCE(bp->cpld_usercode));
else
- strscpy(buf, "unknown", sizeof(buf));
+ buf[0] = '\0';
err = devlink_info_version_running_put_ext(req, "fw.cpld", buf,
ver_type);
if (err)
--
2.47.0