diff mbox series

[net] ptp: ocp: adjust serial port symlink creation

Message ID 20240508132144.11560-1-vadim.fedorenko@linux.dev (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] ptp: ocp: adjust serial port symlink creation | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 926 this patch: 926
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 2 blamed authors not CCed: tony@atomide.com gregkh@linuxfoundation.org; 3 maintainers not CCed: tony@atomide.com vadfed@linux.dev gregkh@linuxfoundation.org
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch warning WARNING: line length of 94 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-10--06-00 (tests: 1010)

Commit Message

Vadim Fedorenko May 8, 2024, 1:21 p.m. UTC
The commit b286f4e87e32 ("serial: core: Move tty and serdev to be children
of serial core port device") changed the hierarchy of serial port devices
and device_find_child_by_name cannot find ttyS* devices because they are
no longer directly attached. Add some logic to restore symlinks creation
to the driver for OCP TimeCard.

Fixes: b286f4e87e32 ("serial: core: Move tty and serdev to be children of serial core port device")
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
 drivers/ptp/ptp_ocp.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

Comments

Jakub Kicinski May 10, 2024, 3:23 a.m. UTC | #1
On Wed,  8 May 2024 13:21:44 +0000 Vadim Fedorenko wrote:
> +#include "../tty/serial/8250/8250.h"

Hm, is there no cleaner way to get the device structs?
Could you repost and CC the serial/8250 maintainers?
Greg can probably tell us how to do this..
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index ee2ced88ab34..50b7cb9db3be 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -25,6 +25,8 @@ 
 #include <linux/crc16.h>
 #include <linux/dpll.h>
 
+#include "../tty/serial/8250/8250.h"
+
 #define PCI_VENDOR_ID_FACEBOOK			0x1d9b
 #define PCI_DEVICE_ID_FACEBOOK_TIMECARD		0x0400
 
@@ -4330,11 +4332,9 @@  ptp_ocp_symlink(struct ptp_ocp *bp, struct device *child, const char *link)
 }
 
 static void
-ptp_ocp_link_child(struct ptp_ocp *bp, const char *name, const char *link)
+ptp_ocp_link_child(struct ptp_ocp *bp, struct device *dev, const char *name, const char *link)
 {
-	struct device *dev, *child;
-
-	dev = &bp->pdev->dev;
+	struct device *child;
 
 	child = device_find_child_by_name(dev, name);
 	if (!child) {
@@ -4349,27 +4349,39 @@  ptp_ocp_link_child(struct ptp_ocp *bp, const char *name, const char *link)
 static int
 ptp_ocp_complete(struct ptp_ocp *bp)
 {
+	struct device *dev, *port_dev;
+	struct uart_8250_port *port;
 	struct pps_device *pps;
 	char buf[32];
 
+	dev = &bp->pdev->dev;
+
 	if (bp->gnss_port.line != -1) {
+		port = serial8250_get_port(bp->gnss_port.line);
+		port_dev = (struct device *)port->port.port_dev;
 		sprintf(buf, "ttyS%d", bp->gnss_port.line);
-		ptp_ocp_link_child(bp, buf, "ttyGNSS");
+		ptp_ocp_link_child(bp, port_dev, buf, "ttyGNSS");
 	}
 	if (bp->gnss2_port.line != -1) {
+		port = serial8250_get_port(bp->gnss2_port.line);
+		port_dev = (struct device *)port->port.port_dev;
 		sprintf(buf, "ttyS%d", bp->gnss2_port.line);
-		ptp_ocp_link_child(bp, buf, "ttyGNSS2");
+		ptp_ocp_link_child(bp, port_dev, buf, "ttyGNSS2");
 	}
 	if (bp->mac_port.line != -1) {
+		port = serial8250_get_port(bp->mac_port.line);
+		port_dev = (struct device *)port->port.port_dev;
 		sprintf(buf, "ttyS%d", bp->mac_port.line);
-		ptp_ocp_link_child(bp, buf, "ttyMAC");
+		ptp_ocp_link_child(bp, port_dev, buf, "ttyMAC");
 	}
 	if (bp->nmea_port.line != -1) {
+		port = serial8250_get_port(bp->nmea_port.line);
+		port_dev = (struct device *)port->port.port_dev;
 		sprintf(buf, "ttyS%d", bp->nmea_port.line);
-		ptp_ocp_link_child(bp, buf, "ttyNMEA");
+		ptp_ocp_link_child(bp, port_dev, buf, "ttyNMEA");
 	}
 	sprintf(buf, "ptp%d", ptp_clock_index(bp->ptp));
-	ptp_ocp_link_child(bp, buf, "ptp");
+	ptp_ocp_link_child(bp, dev, buf, "ptp");
 
 	pps = pps_lookup_dev(bp->ptp);
 	if (pps)