[Patch] Add links in sysfs to DVB adapter devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, this is a patch which adds sysfs links back to the root adapter for DVB 
devices. Example:

Currently in /sys/class/dvb/dvbX.demuxY/ we have:
dev
uevent

With the patch, we have (for a PCI DVB device):
dev
device -> ../../../devices/pci0000:00/0000:00:1e.0/0000:03:0d.0
uevent

So userspace tools can (finally) work out which physical device a DVB adapter 
refers to. Previously you had to kinda look through dmesg and hope that it 
hadn't been dumped out of the buffer. This makes debugging a lot easier if 
the system has been up for a long time!

This is done by adding an extra 'struct device *' parameter to 
dvb_register_adapter(). It will work with any kind of standard 
linux 'device'. Additionally, if someone has an embedded system which does 
things differently, they can simply supply 'NULL' and the behaviour will be 
as before - the link will simply not appear.

Since this affects the dvb-related files in the video4linux tree, I've sent it 
to the video4linux list as well.

Patch attached - please comment.
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/b2c2/flexcop.c
--- a/linux/drivers/media/dvb/b2c2/flexcop.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/b2c2/flexcop.c	Thu Apr  6 19:48:44 2006 +0100
@@ -67,7 +67,7 @@ static int flexcop_dvb_init(struct flexc
 static int flexcop_dvb_init(struct flexcop_device *fc)
 {
 	int ret;
-	if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner)) < 0) {
+	if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner,fc->dev)) < 0) {
 		err("error registering DVB adapter");
 		return ret;
 	}
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
--- a/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c	Thu Apr  6 19:48:44 2006 +0100
@@ -714,7 +714,7 @@ static int __init dvb_bt8xx_load_card(st
 {
 	int result;
 
-	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) {
+	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE, &card->bt->dev->dev)) < 0) {
 		printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
 		return result;
 	}
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/cinergyT2/cinergyT2.c
--- a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c	Thu Apr  6 19:48:44 2006 +0100
@@ -919,7 +919,7 @@ static int cinergyt2_probe (struct usb_i
 		return -ENOMEM;
 	}
 
-	dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE);
+	dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE, &cinergyt2->udev->dev);
 
 	cinergyt2->demux.priv = cinergyt2;
 	cinergyt2->demux.filternum = 256;
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/dvb-core/dvbdev.c
--- a/linux/drivers/media/dvb/dvb-core/dvbdev.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c	Thu Apr  6 19:48:44 2006 +0100
@@ -247,7 +247,7 @@ int dvb_register_device(struct dvb_adapt
 			"dvb/adapter%d/%s%d", adap->num, dnames[type], id);
 
 	class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
-			    NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
+			    adap->device, "dvb%d.%s%d", adap->num, dnames[type], id);
 
 	dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
 		adap->num, dnames[type], id, nums2minor(adap->num, type, id),
@@ -296,7 +296,7 @@ skip:
 }
 
 
-int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module)
+int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module, struct device *device)
 {
 	int num;
 
@@ -317,6 +317,7 @@ int dvb_register_adapter(struct dvb_adap
 	adap->num = num;
 	adap->name = name;
 	adap->module = module;
+	adap->device = device;
 
 	list_add_tail (&adap->list_head, &dvb_adapter_list);
 
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/dvb-core/dvbdev.h
--- a/linux/drivers/media/dvb/dvb-core/dvbdev.h	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/dvb-core/dvbdev.h	Thu Apr  6 19:48:44 2006 +0100
@@ -52,6 +52,8 @@ struct dvb_adapter {
 	u8 proposed_mac [6];
 	void* priv;
 
+	struct device *device;
+
 	struct module *module;
 };
 
@@ -77,7 +79,7 @@ struct dvb_device {
 };
 
 
-extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module);
+extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device);
 extern int dvb_unregister_adapter (struct dvb_adapter *adap);
 
 extern int dvb_register_device (struct dvb_adapter *adap,
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
--- a/linux/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c	Thu Apr  6 19:48:44 2006 +0100
@@ -82,7 +82,7 @@ int dvb_usb_dvb_init(struct dvb_usb_devi
 	int ret;
 
 	if ((ret = dvb_register_adapter(&d->dvb_adap, d->desc->name,
-			d->owner)) < 0) {
+			d->owner, &d->udev->dev)) < 0) {
 		deb_info("dvb_register_adapter failed: error %d", ret);
 		goto err;
 	}
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/pluto2/pluto2.c
--- a/linux/drivers/media/dvb/pluto2/pluto2.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/pluto2/pluto2.c	Thu Apr  6 19:48:44 2006 +0100
@@ -647,7 +647,7 @@ static int __devinit pluto2_probe(struct
 		goto err_pluto_hw_exit;
 
 	/* dvb */
-	ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE);
+	ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev);
 	if (ret < 0)
 		goto err_i2c_bit_del_bus;
 
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/ttpci/av7110.c
--- a/linux/drivers/media/dvb/ttpci/av7110.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/ttpci/av7110.c	Thu Apr  6 19:48:44 2006 +0100
@@ -2413,7 +2413,7 @@ static int __devinit av7110_attach(struc
 		goto err_kfree_0;
 
 	ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name,
-				   THIS_MODULE);
+				   THIS_MODULE, &dev->pci->dev);
 	if (ret < 0)
 		goto err_put_firmware_1;
 
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/ttpci/budget-core.c
--- a/linux/drivers/media/dvb/ttpci/budget-core.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/ttpci/budget-core.c	Thu Apr  6 19:48:44 2006 +0100
@@ -400,7 +400,7 @@ int ttpci_budget_init(struct budget *bud
 		budget->dev->name, budget->buffer_width, budget->buffer_height);
 	printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size);
 
-	if ((ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner)) < 0) {
+	if ((ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner, &budget->dev->pci->dev)) < 0) {
 		return ret;
 	}
 
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
--- a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	Thu Apr  6 19:48:44 2006 +0100
@@ -1515,7 +1515,7 @@ static int ttusb_probe(struct usb_interf
 
 	mutex_unlock(&ttusb->semi2c);
 
-	dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
+	dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE, &udev->dev);
 	ttusb->adapter.priv = ttusb;
 
 	/* i2c */
diff -r 4b6fdf1bb935 linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
--- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c	Thu Apr  6 19:48:44 2006 +0100
@@ -1443,7 +1443,7 @@ static int ttusb_dec_init_dvb(struct ttu
 	dprintk("%s\n", __FUNCTION__);
 
 	if ((result = dvb_register_adapter(&dec->adapter,
-					   dec->model_name, THIS_MODULE)) < 0) {
+					   dec->model_name, THIS_MODULE, &dec->udev->dev)) < 0) {
 		printk("%s: dvb_register_adapter failed: error %d\n",
 		       __FUNCTION__, result);
 
diff -r 4b6fdf1bb935 linux/drivers/media/video/cx88/cx88-dvb.c
--- a/linux/drivers/media/video/cx88/cx88-dvb.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/video/cx88/cx88-dvb.c	Thu Apr  6 19:48:44 2006 +0100
@@ -700,7 +700,7 @@ static int dvb_register(struct cx8802_de
 	cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
 
 	/* register everything */
-	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
+	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
 }
 
 /* ----------------------------------------------------------- */
diff -r 4b6fdf1bb935 linux/drivers/media/video/saa7134/saa7134-dvb.c
--- a/linux/drivers/media/video/saa7134/saa7134-dvb.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/video/saa7134/saa7134-dvb.c	Thu Apr  6 19:48:44 2006 +0100
@@ -1090,7 +1090,7 @@ static int dvb_init(struct saa7134_dev *
 	}
 
 	/* register everything else */
-	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
+	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
 }
 
 static int dvb_fini(struct saa7134_dev *dev)
diff -r 4b6fdf1bb935 linux/drivers/media/video/video-buf-dvb.c
--- a/linux/drivers/media/video/video-buf-dvb.c	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/drivers/media/video/video-buf-dvb.c	Thu Apr  6 19:48:44 2006 +0100
@@ -144,14 +144,15 @@ static int videobuf_dvb_stop_feed(struct
 
 int videobuf_dvb_register(struct videobuf_dvb *dvb,
 			  struct module *module,
-			  void *adapter_priv)
+			  void *adapter_priv,
+			  struct device *device)
 {
 	int result;
 
 	mutex_init(&dvb->lock);
 
 	/* register adapter */
-	result = dvb_register_adapter(&dvb->adapter, dvb->name, module);
+	result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device);
 	if (result < 0) {
 		printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n",
 		       dvb->name, result);
diff -r 4b6fdf1bb935 linux/include/media/video-buf-dvb.h
--- a/linux/include/media/video-buf-dvb.h	Thu Apr  6 18:32:23 2006 +0100
+++ b/linux/include/media/video-buf-dvb.h	Thu Apr  6 19:48:44 2006 +0100
@@ -35,7 +35,8 @@ struct videobuf_dvb {
 
 int videobuf_dvb_register(struct videobuf_dvb *dvb,
 			  struct module *module,
-			  void *adapter_priv);
+			  void *adapter_priv,
+			  struct device *device);
 void videobuf_dvb_unregister(struct videobuf_dvb *dvb);
 
 /*
_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux