Message ID | 20240802154634.2563920-1-vadfed@meta.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] ptp: ocp: adjust sysfs entries to expose tty information | expand |
On Fri, Aug 02, 2024 at 08:46:34AM -0700, Vadim Fedorenko wrote: > Starting v6.8 the serial port subsystem changed the hierarchy of devices > and symlinks are not working anymore. Previous discussion made it clear > that the idea of symlinks for tty devices was wrong by design. Implement > additional attributes to expose the information. Fixes tag points to the > commit which introduced the change. > > Fixes: b286f4e87e32 ("serial: core: Move tty and serdev to be children of serial core port device") > Signed-off-by: Vadim Fedorenko <vadfed@meta.com> > --- > drivers/ptp/ptp_ocp.c | 68 +++++++++++++++++++++++++++++++++---------- > 1 file changed, 52 insertions(+), 16 deletions(-) > > diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c > index ee2ced88ab34..7a5026656452 100644 > --- a/drivers/ptp/ptp_ocp.c > +++ b/drivers/ptp/ptp_ocp.c > @@ -3346,6 +3346,55 @@ static EXT_ATTR_RO(freq, frequency, 1); > static EXT_ATTR_RO(freq, frequency, 2); > static EXT_ATTR_RO(freq, frequency, 3); > > +static ssize_t > +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); > + struct ptp_ocp_serial_port *port; > + > + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); > + return sysfs_emit(buf, "ttyS%d", port->line); > +} > + > +static umode_t > +ptp_ocp_timecard_tty_is_visible(struct kobject *kobj, struct attribute *attr, int n) > +{ > + struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj)); > + struct ptp_ocp_serial_port *port; > + struct device_attribute *dattr; > + struct dev_ext_attribute *ea; > + > + if (strncmp(attr->name, "tty", 3)) > + return attr->mode; > + > + dattr = container_of(attr, struct device_attribute, attr); > + ea = container_of(dattr, struct dev_ext_attribute, attr); > + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); > + return port->line == -1 ? 0 : 0444; > +} > +#define EXT_TTY_ATTR_RO(_name, _val) \ > + struct dev_ext_attribute dev_attr_tty##_name = \ > + { __ATTR(tty##_name, 0444, ptp_ocp_tty_show, NULL), (void *)_val } > + > +static EXT_TTY_ATTR_RO(GNSS, offsetof(struct ptp_ocp, gnss_port)); > +static EXT_TTY_ATTR_RO(GNSS2, offsetof(struct ptp_ocp, gnss2_port)); > +static EXT_TTY_ATTR_RO(MAC, offsetof(struct ptp_ocp, mac_port)); > +static EXT_TTY_ATTR_RO(NMEA, offsetof(struct ptp_ocp, nmea_port)); > +static struct attribute *ptp_ocp_timecard_tty_attrs[] = { > + &dev_attr_ttyGNSS.attr.attr, > + &dev_attr_ttyGNSS2.attr.attr, > + &dev_attr_ttyMAC.attr.attr, > + &dev_attr_ttyNMEA.attr.attr, > + NULL, > +}; > + > +static const struct attribute_group ptp_ocp_timecard_tty_group = { > + .name = "tty", > + .attrs = ptp_ocp_timecard_tty_attrs, > + .is_visible = ptp_ocp_timecard_tty_is_visible, > +}; > + > static ssize_t > serialnum_show(struct device *dev, struct device_attribute *attr, char *buf) > { > @@ -3775,6 +3824,7 @@ static const struct attribute_group fb_timecard_group = { > > static const struct ocp_attr_group fb_timecard_groups[] = { > { .cap = OCP_CAP_BASIC, .group = &fb_timecard_group }, > + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, > { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, > { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, > { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal2_group }, > @@ -3814,6 +3864,7 @@ static const struct attribute_group art_timecard_group = { > > static const struct ocp_attr_group art_timecard_groups[] = { > { .cap = OCP_CAP_BASIC, .group = &art_timecard_group }, > + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, > { }, > }; > > @@ -3841,6 +3892,7 @@ static const struct attribute_group adva_timecard_group = { > > static const struct ocp_attr_group adva_timecard_groups[] = { > { .cap = OCP_CAP_BASIC, .group = &adva_timecard_group }, > + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, > { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, > { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, > { .cap = OCP_CAP_FREQ, .group = &fb_timecard_freq0_group }, > @@ -4352,22 +4404,6 @@ ptp_ocp_complete(struct ptp_ocp *bp) > struct pps_device *pps; > char buf[32]; > > - if (bp->gnss_port.line != -1) { > - sprintf(buf, "ttyS%d", bp->gnss_port.line); > - ptp_ocp_link_child(bp, buf, "ttyGNSS"); > - } > - if (bp->gnss2_port.line != -1) { > - sprintf(buf, "ttyS%d", bp->gnss2_port.line); > - ptp_ocp_link_child(bp, buf, "ttyGNSS2"); > - } > - if (bp->mac_port.line != -1) { > - sprintf(buf, "ttyS%d", bp->mac_port.line); > - ptp_ocp_link_child(bp, buf, "ttyMAC"); > - } > - if (bp->nmea_port.line != -1) { > - sprintf(buf, "ttyS%d", bp->nmea_port.line); > - ptp_ocp_link_child(bp, buf, "ttyNMEA"); > - } > sprintf(buf, "ptp%d", ptp_clock_index(bp->ptp)); > ptp_ocp_link_child(bp, buf, "ptp"); > > -- > 2.43.5 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
On Fri, Aug 02, 2024 at 08:46:34AM -0700, Vadim Fedorenko wrote: > Starting v6.8 the serial port subsystem changed the hierarchy of devices > and symlinks are not working anymore. Previous discussion made it clear > that the idea of symlinks for tty devices was wrong by design. Implement > additional attributes to expose the information. Fixes tag points to the > commit which introduced the change. No Documentation/ABI/ updates?
On 03.08.2024 08:12, Greg Kroah-Hartman wrote: > On Fri, Aug 02, 2024 at 08:46:34AM -0700, Vadim Fedorenko wrote: >> Starting v6.8 the serial port subsystem changed the hierarchy of devices >> and symlinks are not working anymore. Previous discussion made it clear >> that the idea of symlinks for tty devices was wrong by design. Implement >> additional attributes to expose the information. Fixes tag points to the >> commit which introduced the change. > > No Documentation/ABI/ updates? > Ah... totally forgot about it. Will make it in v2, Thanks!
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index ee2ced88ab34..7a5026656452 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -3346,6 +3346,55 @@ static EXT_ATTR_RO(freq, frequency, 1); static EXT_ATTR_RO(freq, frequency, 2); static EXT_ATTR_RO(freq, frequency, 3); +static ssize_t +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); + struct ptp_ocp_serial_port *port; + + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); + return sysfs_emit(buf, "ttyS%d", port->line); +} + +static umode_t +ptp_ocp_timecard_tty_is_visible(struct kobject *kobj, struct attribute *attr, int n) +{ + struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj)); + struct ptp_ocp_serial_port *port; + struct device_attribute *dattr; + struct dev_ext_attribute *ea; + + if (strncmp(attr->name, "tty", 3)) + return attr->mode; + + dattr = container_of(attr, struct device_attribute, attr); + ea = container_of(dattr, struct dev_ext_attribute, attr); + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); + return port->line == -1 ? 0 : 0444; +} +#define EXT_TTY_ATTR_RO(_name, _val) \ + struct dev_ext_attribute dev_attr_tty##_name = \ + { __ATTR(tty##_name, 0444, ptp_ocp_tty_show, NULL), (void *)_val } + +static EXT_TTY_ATTR_RO(GNSS, offsetof(struct ptp_ocp, gnss_port)); +static EXT_TTY_ATTR_RO(GNSS2, offsetof(struct ptp_ocp, gnss2_port)); +static EXT_TTY_ATTR_RO(MAC, offsetof(struct ptp_ocp, mac_port)); +static EXT_TTY_ATTR_RO(NMEA, offsetof(struct ptp_ocp, nmea_port)); +static struct attribute *ptp_ocp_timecard_tty_attrs[] = { + &dev_attr_ttyGNSS.attr.attr, + &dev_attr_ttyGNSS2.attr.attr, + &dev_attr_ttyMAC.attr.attr, + &dev_attr_ttyNMEA.attr.attr, + NULL, +}; + +static const struct attribute_group ptp_ocp_timecard_tty_group = { + .name = "tty", + .attrs = ptp_ocp_timecard_tty_attrs, + .is_visible = ptp_ocp_timecard_tty_is_visible, +}; + static ssize_t serialnum_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -3775,6 +3824,7 @@ static const struct attribute_group fb_timecard_group = { static const struct ocp_attr_group fb_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &fb_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal2_group }, @@ -3814,6 +3864,7 @@ static const struct attribute_group art_timecard_group = { static const struct ocp_attr_group art_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &art_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { }, }; @@ -3841,6 +3892,7 @@ static const struct attribute_group adva_timecard_group = { static const struct ocp_attr_group adva_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &adva_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, { .cap = OCP_CAP_FREQ, .group = &fb_timecard_freq0_group }, @@ -4352,22 +4404,6 @@ ptp_ocp_complete(struct ptp_ocp *bp) struct pps_device *pps; char buf[32]; - if (bp->gnss_port.line != -1) { - sprintf(buf, "ttyS%d", bp->gnss_port.line); - ptp_ocp_link_child(bp, buf, "ttyGNSS"); - } - if (bp->gnss2_port.line != -1) { - sprintf(buf, "ttyS%d", bp->gnss2_port.line); - ptp_ocp_link_child(bp, buf, "ttyGNSS2"); - } - if (bp->mac_port.line != -1) { - sprintf(buf, "ttyS%d", bp->mac_port.line); - ptp_ocp_link_child(bp, buf, "ttyMAC"); - } - if (bp->nmea_port.line != -1) { - sprintf(buf, "ttyS%d", bp->nmea_port.line); - ptp_ocp_link_child(bp, buf, "ttyNMEA"); - } sprintf(buf, "ptp%d", ptp_clock_index(bp->ptp)); ptp_ocp_link_child(bp, buf, "ptp");
Starting v6.8 the serial port subsystem changed the hierarchy of devices and symlinks are not working anymore. Previous discussion made it clear that the idea of symlinks for tty devices was wrong by design. Implement additional attributes to expose the information. Fixes tag points to the commit which introduced the change. Fixes: b286f4e87e32 ("serial: core: Move tty and serdev to be children of serial core port device") Signed-off-by: Vadim Fedorenko <vadfed@meta.com> --- drivers/ptp/ptp_ocp.c | 68 +++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 16 deletions(-)