Re: [PATCH 2/3] ptp: Add clock name to uevent

From: Andrew Lunn
Date: Tue Oct 15 2024 - 08:45:35 EST


>
> +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