netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Jonathan Lemon <jonathan.lemon@gmail.com>,
	linux-serial@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 net] ptp: ocp: adjust serial port symlink creation
Date: Thu, 23 May 2024 08:39:43 -0700	[thread overview]
Message-ID: <20240523083943.6ecb60d9@kernel.org> (raw)
In-Reply-To: <20240510110405.15115-1-vadim.fedorenko@linux.dev>

On Fri, 10 May 2024 11:04:05 +0000 Vadim Fedorenko wrote:
> 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>
> ---
> v2:
>  add serial/8250 maintainers
> ---
>  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 <linux/crc16.h>
>  #include <linux/dpll.h>
>  
> +#include "../tty/serial/8250/8250.h"

Hi Greg, Jiri, does this look reasonable to you?
The cross tree include raises an obvious red flag.

Should serial / u8250 provide a more official API?
Can we use device_for_each_child() to deal with the extra
layer in the hierarchy?

>  #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)


  parent reply	other threads:[~2024-05-23 15:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 11:04 [PATCH v2 net] ptp: ocp: adjust serial port symlink creation Vadim Fedorenko
2024-05-10 11:13 ` Greg Kroah-Hartman
2024-05-22 12:39   ` Vadim Fedorenko
2024-06-04 11:50     ` Greg Kroah-Hartman
2024-06-04 23:53       ` Vadim Fedorenko
2024-06-05 10:05         ` Greg Kroah-Hartman
2024-06-05 10:14           ` Vadim Fedorenko
2024-06-05 10:41             ` Greg Kroah-Hartman
2024-06-05 10:59               ` Vadim Fedorenko
2024-06-05 11:07                 ` Greg Kroah-Hartman
2024-06-05 11:25                   ` Vadim Fedorenko
2024-06-05 12:22                     ` Greg Kroah-Hartman
2024-05-23 15:39 ` Jakub Kicinski [this message]
2024-05-23 16:26   ` Greg Kroah-Hartman
2024-05-23 21:06     ` Vadim Fedorenko
2024-05-24  4:06       ` Greg Kroah-Hartman
2024-06-08 10:10 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240523083943.6ecb60d9@kernel.org \
    --to=kuba@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).