From patchwork Wed May 8 13:21:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13658753 X-Patchwork-Delegate: kuba@kernel.org Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5A379945 for ; Wed, 8 May 2024 13:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715174385; cv=none; b=GHJlSuIR4egzdCgSVD0wGgO2MYlSbTOsLYSe/GFe92fRnno/Fs7q2GEW1YrPQ2w+guvpnKRuak4+5+TvwGOCun9b2TYD005FZcgHwvdhtUqFift4bTlPO5fR2sej/E0TQwEJLDo3/eXgDP/D66RkW3XrNuuLbDdzWmvr3E42LXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715174385; c=relaxed/simple; bh=ocluJHKG5H67LGLj+kkg7g2CrvBwTZcXIsaY6UFAY0o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PYJIi279I5p82vDq/Um7YdNiKsXVCKqsRk/u2ZYJI4vy/AHjSOjTFZvvGg2dnFSMOwS8U0Er6e/z6EIwwcNKJEXIplS4ExBtJyOPRr9XDudg1aSjFkxmmYq0Op4RLflylBWQ1JO7De8Valn4yMhciVqZeLqECb9XSpkryh6+/iU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=XkEPPNN2; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XkEPPNN2" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715174381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lBzxJEZkTr2twh/tIhpqNl8YWzKURmo6vkMsWYPZA7g=; b=XkEPPNN2Wjdaq3EekZyraMVtoJcWyNHvm2asikrJt2OgdY0GUiqx+O3aLsObD6yoF7Ytlz wBhOAaZ8caeqRiWnotoSHVK/oueumUZfPot5qUh1J84d/G0VIDORV9esIvty/7wakcRkhK cMeXXZUfpQSqN5qQdIAZDLZ78aQHp0Q= From: Vadim Fedorenko To: Jakub Kicinski , Jonathan Lemon Cc: Richard Cochran , Vadim Fedorenko , netdev@vger.kernel.org Subject: [PATCH net] ptp: ocp: adjust serial port symlink creation Date: Wed, 8 May 2024 13:21:44 +0000 Message-ID: <20240508132144.11560-1-vadim.fedorenko@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/ptp/ptp_ocp.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) 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 #include +#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)