From: Zhongqiu Han Date: Fri, 7 Nov 2025 07:45:33 +0000 (+0800) Subject: ptp: ocp: Document sysfs output format for backward compatibility X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b9192c2c075edf8a35f8c6c2b5ef36cdc8ce9f9;p=thirdparty%2Fkernel%2Flinux.git ptp: ocp: Document sysfs output format for backward compatibility Add a comment to ptp_ocp_tty_show() explaining that the sysfs output intentionally does not include a trailing newline. This is required for backward compatibility with existing userspace software that reads the sysfs attribute and uses the value directly as a device path. A previous attempt to add a newline to align with common kernel conventions broke userspace applications that were opening device paths like "/dev/ttyS4\n" instead of "/dev/ttyS4", resulting in ENOENT errors. This comment prevents future attempts to "fix" this behavior, which would break existing userspace applications. Link: https://lore.kernel.org/netdev/20251030124519.1828058-1-zhongqiu.han@oss.qualcomm.com/ Link: https://lore.kernel.org/netdev/aef3b850-5f38-4c28-a018-3b0006dc2f08@linux.dev/ Suggested-by: Jakub Kicinski Signed-off-by: Zhongqiu Han Reviewed-by: Vadim Fedorenko Link: https://patch.msgid.link/20251107074533.416048-1-zhongqiu.han@oss.qualcomm.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index a5c3632529862..eeebe4d149f71 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -3430,6 +3430,12 @@ ptp_ocp_tty_show(struct device *dev, struct device_attribute *attr, char *buf) struct dev_ext_attribute *ea = to_ext_attr(attr); struct ptp_ocp *bp = dev_get_drvdata(dev); + /* + * NOTE: This output does not include a trailing newline for backward + * compatibility. Existing userspace software uses this value directly + * as a device path (e.g., "/dev/ttyS4"), and adding a newline would + * break those applications. Do not add a newline to this output. + */ return sysfs_emit(buf, "ttyS%d", bp->port[(uintptr_t)ea->var].line); }