diff mbox series

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

Message ID 20241015105414.2825635-3-svens@linux.ibm.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series PtP driver for s390 clocks | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 2 of 2 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sven Schnelle Oct. 15, 2024, 10:54 a.m. UTC
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(-)

Comments

Greg KH Oct. 15, 2024, 10:59 a.m. UTC | #1
On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote:
> 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'.

Where are you documenting this new user/kernel api you are adding?

> 
> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
> ---
>  drivers/ptp/ptp_clock.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> 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);

Why is this needed?  Can't you get the name from the sysfs paths, the
symlink should be there already.

thanks,

greg k-h
Sven Schnelle Oct. 15, 2024, 12:02 p.m. UTC | #2
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

> On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote:
>> 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'.
>
> Where are you documenting this new user/kernel api you are adding?
>
>> 
>> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
>> ---
>>  drivers/ptp/ptp_clock.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>> 
>> 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);
>
> Why is this needed?  Can't you get the name from the sysfs paths, the
> symlink should be there already.

You mean the 'clock_name' attribute in sysfs? That would require to
write some script to iterate over all ptp devices and check the name,
or is there a way to match that in udev?
Greg KH Oct. 15, 2024, 12:16 p.m. UTC | #3
On Tue, Oct 15, 2024 at 02:02:17PM +0200, Sven Schnelle wrote:
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> 
> > On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote:
> >> 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'.
> >
> > Where are you documenting this new user/kernel api you are adding?
> >
> >> 
> >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
> >> ---
> >>  drivers/ptp/ptp_clock.c | 11 ++++++++++-
> >>  1 file changed, 10 insertions(+), 1 deletion(-)
> >> 
> >> 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);
> >
> > Why is this needed?  Can't you get the name from the sysfs paths, the
> > symlink should be there already.
> 
> You mean the 'clock_name' attribute in sysfs?

Great, yes, it's right there.

> That would require to
> write some script to iterate over all ptp devices and check the name,
> or is there a way to match that in udev?

Yes there is.  Please use that :)

thanks,

greg k-h
Sven Schnelle Oct. 15, 2024, 12:19 p.m. UTC | #4
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

> On Tue, Oct 15, 2024 at 02:02:17PM +0200, Sven Schnelle wrote:
>> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> 
>> > On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote:
>> >> 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'.
>> >
>> > Where are you documenting this new user/kernel api you are adding?
>> >
>> >> 
>> >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
>> >> ---
>> >>  drivers/ptp/ptp_clock.c | 11 ++++++++++-
>> >>  1 file changed, 10 insertions(+), 1 deletion(-)
>> >> 
>> >> 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);
>> >
>> > Why is this needed?  Can't you get the name from the sysfs paths, the
>> > symlink should be there already.
>> 
>> You mean the 'clock_name' attribute in sysfs?
>
> Great, yes, it's right there.
>
>> That would require to
>> write some script to iterate over all ptp devices and check the name,
>> or is there a way to match that in udev?
>
> Yes there is.  Please use that :)

Indeed. Sorry, will drop the patch.
diff mbox series

Patch

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