Message ID | 20241015084728.1833876-3-svens@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | PtP driver for s390 clocks | expand |
> > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); No forward declarations please. Put the code in the correct order. > const struct class ptp_class = { > .name = "ptp", > - .dev_groups = ptp_groups > + .dev_groups = ptp_groups, > + .dev_uevent = ptp_udev_uevent > }; > > /* private globals */ > @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); > > /* module operations */ > > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) > +{ > + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); > + > + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); > +} https://elixir.bootlin.com/linux/v6.11.3/source/include/linux/ptp_clock_kernel.h#L60 * @name: A short "friendly name" to identify the clock and to * help distinguish PHY based devices from MAC based ones. * The string is not meant to be a unique id. If the name is not unique, you probably should not be using it for udev naming. Andrew
On Tue, Oct 15, 2024 at 02:43:28PM +0200, Andrew Lunn wrote: > * @name: A short "friendly name" to identify the clock and to > * help distinguish PHY based devices from MAC based ones. > * The string is not meant to be a unique id. > > If the name is not unique, you probably should not be using it for > udev naming. +1 Maybe the name is unique for s390, but it will not be in general. Thanks, Richard
Richard Cochran <richardcochran@gmail.com> writes: > On Tue, Oct 15, 2024 at 02:43:28PM +0200, Andrew Lunn wrote: >> * @name: A short "friendly name" to identify the clock and to >> * help distinguish PHY based devices from MAC based ones. >> * The string is not meant to be a unique id. >> >> If the name is not unique, you probably should not be using it for >> udev naming. > > +1 > > Maybe the name is unique for s390, but it will not be in general. As already written to Greg, i will drop this Patch. The name is unique, i was just not aware that the clock_name attribute is present in sysfs.
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index c56cd0f63909..15937acb79c6 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -25,9 +25,11 @@ #define PTP_PPS_EVENT PPS_CAPTUREASSERT #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); const struct class ptp_class = { .name = "ptp", - .dev_groups = ptp_groups + .dev_groups = ptp_groups, + .dev_uevent = ptp_udev_uevent }; /* private globals */ @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); /* module operations */ +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) +{ + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); + + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); +} + static void __exit ptp_exit(void) { class_unregister(&ptp_class);
To allow users to have stable device names with the help of udev, add the name to the udev event that is sent when a new PtP clock is available. The key is called 'PTP_CLOCK_NAME'. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- drivers/ptp/ptp_clock.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)