netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptp: ocp: Document sysfs output format for backward compatibility
@ 2025-11-07  7:45 Zhongqiu Han
  2025-11-07 18:01 ` Vadim Fedorenko
  2025-11-11  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zhongqiu Han @ 2025-11-07  7:45 UTC (permalink / raw)
  To: jonathan.lemon, vadim.fedorenko, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, zhongqiu.han

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 <kuba@kernel.org>
Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
---
 drivers/ptp/ptp_ocp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index a5c363252986..eeebe4d149f7 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);
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: ocp: Document sysfs output format for backward compatibility
  2025-11-07  7:45 [PATCH] ptp: ocp: Document sysfs output format for backward compatibility Zhongqiu Han
@ 2025-11-07 18:01 ` Vadim Fedorenko
  2025-11-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2025-11-07 18:01 UTC (permalink / raw)
  To: Zhongqiu Han, jonathan.lemon, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel

On 07/11/2025 07:45, Zhongqiu Han wrote:
> 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 <kuba@kernel.org>
> Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
>   drivers/ptp/ptp_ocp.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index a5c363252986..eeebe4d149f7 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);
>   }
>   
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: ocp: Document sysfs output format for backward compatibility
  2025-11-07  7:45 [PATCH] ptp: ocp: Document sysfs output format for backward compatibility Zhongqiu Han
  2025-11-07 18:01 ` Vadim Fedorenko
@ 2025-11-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-11  0:30 UTC (permalink / raw)
  To: Zhongqiu Han
  Cc: jonathan.lemon, vadim.fedorenko, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  7 Nov 2025 15:45:33 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - ptp: ocp: Document sysfs output format for backward compatibility
    https://git.kernel.org/netdev/net-next/c/5b9192c2c075

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-11  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07  7:45 [PATCH] ptp: ocp: Document sysfs output format for backward compatibility Zhongqiu Han
2025-11-07 18:01 ` Vadim Fedorenko
2025-11-11  0:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).