Linux-Media Archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add some uevent variables on DVB to support persistent names on udev
@ 2024-02-20  9:46 Mauro Carvalho Chehab
  2024-02-20  9:46 ` [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables Mauro Carvalho Chehab
  2024-02-20  9:46 ` [PATCH 2/2] em28xx-dvb: fix DVB adapter device name Mauro Carvalho Chehab
  0 siblings, 2 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2024-02-20  9:46 UTC (permalink / raw
  Cc: Mauro Carvalho Chehab, linux-kernel, linux-media

As pointed by https://github.com/systemd/systemd/issues/31406,
currently, udev doesn't have pesistent names for the subsystem.

Add adapter's name and device's parent device, as those may help
adding unique persistent names.

While here, also change em28xx-dvb to use a real name instead of
the parent dev name. With that,  uevent for DVB devnodes will
resemble this:

/sys/class/dvb/dvb0.demux0/uevent:MAJOR=212
/sys/class/dvb/dvb0.demux0/uevent:MINOR=1
/sys/class/dvb/dvb0.demux0/uevent:DEVNAME=dvb/adapter0/demux0
/sys/class/dvb/dvb0.demux0/uevent:DVB_ADAPTER_NAME=PCTV nanoStick T2 290e
/sys/class/dvb/dvb0.demux0/uevent:DVB_ADAPTER_PDEV=2-1:1.0
/sys/class/dvb/dvb0.demux0/uevent:DVB_ADAPTER_NUM=0
/sys/class/dvb/dvb0.demux0/uevent:DVB_DEVICE_TYPE=demux
/sys/class/dvb/dvb0.demux0/uevent:DVB_DEVICE_NUM=0

Tested with a PCTV nanoStick T2 290e device.

Mauro Carvalho Chehab (2):
  media: dvbdev: export adapter's name and bus ID to DVB uevent
    variables
  em28xx-dvb: fix DVB adapter device name

 drivers/media/dvb-core/dvbdev.c       | 2 ++
 drivers/media/usb/em28xx/em28xx-dvb.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables
  2024-02-20  9:46 [PATCH 0/2] Add some uevent variables on DVB to support persistent names on udev Mauro Carvalho Chehab
@ 2024-02-20  9:46 ` Mauro Carvalho Chehab
  2024-02-26  8:41   ` Hans Verkuil
  2024-02-20  9:46 ` [PATCH 2/2] em28xx-dvb: fix DVB adapter device name Mauro Carvalho Chehab
  1 sibling, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2024-02-20  9:46 UTC (permalink / raw
  Cc: Mauro Carvalho Chehab, Benjamin Tissoires, Dan Carpenter,
	Greg Kroah-Hartman, Hans Verkuil, Hyunwoo Kim, Sakari Ailus,
	Zhipeng Lu, linux-kernel, linux-media

Add two new variables for uevent, helping udev to be able to setup
a persistent name for the device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 drivers/media/dvb-core/dvbdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 733d0bc4b4cc..01227c695cbd 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -1064,6 +1064,8 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)
 {
 	const struct dvb_device *dvbdev = dev_get_drvdata(dev);
 
+	add_uevent_var(env, "DVB_ADAPTER_NAME=%s", dvbdev->adapter->name);
+	add_uevent_var(env, "DVB_ADAPTER_PDEV=%s", dev_name(dev->parent));
 	add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num);
 	add_uevent_var(env, "DVB_DEVICE_TYPE=%s", dnames[dvbdev->type]);
 	add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] em28xx-dvb: fix DVB adapter device name
  2024-02-20  9:46 [PATCH 0/2] Add some uevent variables on DVB to support persistent names on udev Mauro Carvalho Chehab
  2024-02-20  9:46 ` [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables Mauro Carvalho Chehab
@ 2024-02-20  9:46 ` Mauro Carvalho Chehab
  2024-02-26  9:03   ` Hans Verkuil
  1 sibling, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2024-02-20  9:46 UTC (permalink / raw
  Cc: Mauro Carvalho Chehab, linux-kernel, linux-media

This will be used for uevent, so it needs to be filled with the
device name, and not with it's parent ID.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 drivers/media/usb/em28xx/em28xx-dvb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 9fce59979e3b..759c04fbd8cf 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -980,7 +980,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
 
 	/* register adapter */
 	result = dvb_register_adapter(&dvb->adapter,
-				      dev_name(&dev->intf->dev), module,
+				      em28xx_boards[dev->model].name, module,
 				      device, adapter_nr);
 	if (result < 0) {
 		dev_warn(&dev->intf->dev,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables
  2024-02-20  9:46 ` [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables Mauro Carvalho Chehab
@ 2024-02-26  8:41   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2024-02-26  8:41 UTC (permalink / raw
  To: Mauro Carvalho Chehab
  Cc: Benjamin Tissoires, Dan Carpenter, Greg Kroah-Hartman,
	Hyunwoo Kim, Sakari Ailus, Zhipeng Lu, linux-kernel, linux-media

On 20/02/2024 10:46, Mauro Carvalho Chehab wrote:
> Add two new variables for uevent, helping udev to be able to setup
> a persistent name for the device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Regards,

	Hans

> ---
>  drivers/media/dvb-core/dvbdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 733d0bc4b4cc..01227c695cbd 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -1064,6 +1064,8 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)
>  {
>  	const struct dvb_device *dvbdev = dev_get_drvdata(dev);
>  
> +	add_uevent_var(env, "DVB_ADAPTER_NAME=%s", dvbdev->adapter->name);
> +	add_uevent_var(env, "DVB_ADAPTER_PDEV=%s", dev_name(dev->parent));
>  	add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num);
>  	add_uevent_var(env, "DVB_DEVICE_TYPE=%s", dnames[dvbdev->type]);
>  	add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] em28xx-dvb: fix DVB adapter device name
  2024-02-20  9:46 ` [PATCH 2/2] em28xx-dvb: fix DVB adapter device name Mauro Carvalho Chehab
@ 2024-02-26  9:03   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2024-02-26  9:03 UTC (permalink / raw
  To: Mauro Carvalho Chehab; +Cc: linux-kernel, linux-media

Hi Mauro,

On 20/02/2024 10:46, Mauro Carvalho Chehab wrote:
> This will be used for uevent, so it needs to be filled with the
> device name, and not with it's parent ID.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
> ---
>  drivers/media/usb/em28xx/em28xx-dvb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
> index 9fce59979e3b..759c04fbd8cf 100644
> --- a/drivers/media/usb/em28xx/em28xx-dvb.c
> +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
> @@ -980,7 +980,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
>  
>  	/* register adapter */
>  	result = dvb_register_adapter(&dvb->adapter,
> -				      dev_name(&dev->intf->dev), module,
> +				      em28xx_boards[dev->model].name, module,

It is not clear what the 'adapter name' should be: looking at how this is
used today it is either the name of the card or the name of the driver module
(KBUILD_MODNAME or a hardcoded string).

This driver appears to be the only one that uses dev_name, but I did not
do an exhaustive search, so there may be more.

In any case, I think this should be consistent and documented somewhere.

Personally, I think using the model/card name would be best.

But how does this relate to the name reported by FE_GET_INFO? Is it
supposed to be the same name? Is that handled correctly or documented
somewhere?

Regards,

	Hans

>  				      device, adapter_nr);
>  	if (result < 0) {
>  		dev_warn(&dev->intf->dev,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-26  9:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20  9:46 [PATCH 0/2] Add some uevent variables on DVB to support persistent names on udev Mauro Carvalho Chehab
2024-02-20  9:46 ` [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables Mauro Carvalho Chehab
2024-02-26  8:41   ` Hans Verkuil
2024-02-20  9:46 ` [PATCH 2/2] em28xx-dvb: fix DVB adapter device name Mauro Carvalho Chehab
2024-02-26  9:03   ` Hans Verkuil

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 read-only IMAP folder(s) and NNTP newsgroup(s).