Skip to contentSkip to conversation

Add some uevent variables on DVB to support persistent names on udev

PATCH In review Mauro Carvalho Chehab 3 participants 5 messages Feb 20, 2024 – Feb 26, 2024

Subsystems (2)
lore
Share & tools
lore

Mauro Carvalho Chehab

author maintainer
#0 lore raw

cover Add some uevent variables on DVB to support persistent names on udev

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(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/2 media: dvbdev: export adapter's name and bus ID to DVB uevent variables

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

---
 drivers/media/dvb-core/dvbdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/dvb-core/dvbdev.c +2 -0
index 733d0bc4b4cc..01227c695cbd 100644
@@ -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);
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH 2/2 em28xx-dvb: fix DVB adapter device name

In reply to Mauro Carvalho Chehab

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

---
 drivers/media/usb/em28xx/em28xx-dvb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-dvb.c +1 -1
index 9fce59979e3b..759c04fbd8cf 100644
@@ -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,
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] media: dvbdev: export adapter's name and bus ID to DVB uevent variables

In reply to Mauro Carvalho Chehab
Quoted 4 lines · Mauro Carvalho Chehab

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

Regards,

Hans

Quoted 17 lines
---
 drivers/media/dvb-core/dvbdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/dvb-core/dvbdev.c +2 -0
index 733d0bc4b4cc..01227c695cbd 100644
@@ -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);
#4 lore raw

Re: [PATCH 2/2] em28xx-dvb: fix DVB adapter device name

In reply to Mauro Carvalho Chehab

Hi Mauro,

Quoted 13 lines · Mauro Carvalho Chehab

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

---
 drivers/media/usb/em28xx/em28xx-dvb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-dvb.c +0 -0
index 9fce59979e3b..759c04fbd8cf 100644

drivers/media/usb/em28xx/em28xx-dvb.c static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, · line 983

Quoted 5 lines
drivers/media/usb/em28xx/em28xx-dvb.c +1 -1
@@ -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

Quoted 3 lines
drivers/media/usb/em28xx/em28xx-dvb.c +0 -0
 				      device, adapter_nr);
 	if (result < 0) {
 		dev_warn(&dev->intf->dev,