Browse Source

V4L/DVB (9473): add DVB_DEVICE_NUM and DVB_ADAPTER_NUM to uevent

This allows udev to create proper device nodes without any
hacky shell scripts/programs to call, which guess these numbers
from the kernel device names.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Kay Sievers 16 years ago
parent
commit
a5f4c0ce68
1 changed files with 11 additions and 1 deletions
  1. 11 1
      drivers/media/dvb/dvb-core/dvbdev.c

+ 11 - 1
drivers/media/dvb/dvb-core/dvbdev.c

@@ -252,7 +252,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 
 
 	clsdev = device_create(dvb_class, adap->device,
 	clsdev = device_create(dvb_class, adap->device,
 			       MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
 			       MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
-			       NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
+			       dvbdev, "dvb%d.%s%d", adap->num, dnames[type], id);
 	if (IS_ERR(clsdev)) {
 	if (IS_ERR(clsdev)) {
 		printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
 		printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
 		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
 		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
@@ -432,6 +432,15 @@ out:
 	return err;
 	return err;
 }
 }
 
 
+static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+	add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id);
+	add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num);
+	return 0;
+}
+
 static int __init init_dvbdev(void)
 static int __init init_dvbdev(void)
 {
 {
 	int retval;
 	int retval;
@@ -453,6 +462,7 @@ static int __init init_dvbdev(void)
 		retval = PTR_ERR(dvb_class);
 		retval = PTR_ERR(dvb_class);
 		goto error;
 		goto error;
 	}
 	}
+	dvb_class->dev_uevent = dvb_uevent;
 	return 0;
 	return 0;
 
 
 error:
 error: