V4L/DVB (3762): Add sysfs device links to dvb devices
authorAndrew de Quincey <adq_dvb@lidskialf.net>
Mon, 10 Apr 2006 12:27:37 +0000 (09:27 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 25 Jun 2006 04:57:55 +0000 (01:57 -0300)
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.

Ack'd-by: Manu Abraham <manu@linuxtv.org>
Acked-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
15 files changed:
drivers/media/dvb/b2c2/flexcop.c
drivers/media/dvb/bt8xx/dvb-bt8xx.c
drivers/media/dvb/cinergyT2/cinergyT2.c
drivers/media/dvb/dvb-core/dvbdev.c
drivers/media/dvb/dvb-core/dvbdev.h
drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
drivers/media/dvb/pluto2/pluto2.c
drivers/media/dvb/ttpci/av7110.c
drivers/media/dvb/ttpci/budget-core.c
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
drivers/media/dvb/ttusb-dec/ttusb_dec.c
drivers/media/video/cx88/cx88-dvb.c
drivers/media/video/saa7134/saa7134-dvb.c
drivers/media/video/video-buf-dvb.c
include/media/video-buf-dvb.h

index 56ba52470676821070a88050b43c35d634f3d209..5c276b3793ea21a708f602f3c632cbf0c44af104 100644 (file)
@@ -67,7 +67,7 @@ static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
 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;
        }
index ccc7b2eb4a2d33a424e243612634928821c0e096..1bf3392ac80dc910a9e1104f47836335ba27e5d7 100644 (file)
@@ -713,7 +713,7 @@ static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
 {
        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;
        }
index 9325d039ea652c622071b04d8c31ed7e6ff473ef..c7e4134872d4ed295d5e5cf3e865bd9a2f94b8d4 100644 (file)
@@ -902,7 +902,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
                return -ENOMEM;
        }
 
-       if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE)) < 0) {
+       if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE, &cinergyt2->udev->dev)) < 0) {
                kfree(cinergyt2);
                return err;
        }
index 3852430d0260e65fc5daf8045c07bd19031933e0..134c2bbbeeb5f75e89921413850a0bffec367ed6 100644 (file)
@@ -236,7 +236,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
                        "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),
@@ -285,7 +285,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;
 
@@ -306,6 +306,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
        adap->num = num;
        adap->name = name;
        adap->module = module;
+       adap->device = device;
 
        list_add_tail (&adap->list_head, &dvb_adapter_list);
 
index 74ed5853f0fb02c1d0be40518d7426b50c2d3b44..d7a976d040d72249ab8d5558529d328802356c4e 100644 (file)
@@ -51,6 +51,8 @@ struct dvb_adapter {
        u8 proposed_mac [6];
        void* priv;
 
+       struct device *device;
+
        struct module *module;
 };
 
@@ -76,7 +78,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,
index 6fa92100248b8291b7353b070dc7347bfea67d38..500896d02d5a3664f515e1d4e908cd0924c1d34e 100644 (file)
@@ -82,7 +82,7 @@ int dvb_usb_dvb_init(struct dvb_usb_device *d)
        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;
        }
index 1c5316e209efc9993ccc4d4def81e3032e6142e6..c9afad038c1f2b2145ed47483ad1f24141c42eea 100644 (file)
@@ -647,7 +647,7 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
                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;
 
index d028245c8eede256eee4fdd6de60610ea266816f..21e331d32ca13377f90791b88bdb7193562bc85b 100644 (file)
@@ -2413,7 +2413,7 @@ static int __devinit av7110_attach(struct saa7146_dev* dev,
                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;
 
index d8af690fa55c356ba6c3a55bea40adcb03d7223a..e4cf7775e07f75f21447fa2f051af771180aad63 100644 (file)
@@ -400,7 +400,7 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
                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;
        }
 
index 6ceae38125c7546990623d62028e35c56750f4a1..95558608b03e9c5b28beb197f5fba96512dae8f5 100644 (file)
@@ -1507,7 +1507,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 
        mutex_unlock(&ttusb->semi2c);
 
-       if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE)) < 0) {
+       if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE, &udev->dev)) < 0) {
                ttusb_free_iso_urbs(ttusb);
                kfree(ttusb);
                return result;
index 44dea32118483e9dbf14868dd927b84fdfad7ea1..da1090afad54abeec293c198e64ea3857606da53 100644 (file)
@@ -1432,7 +1432,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
        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);
 
index 5c05e09e73fa578dc9ca300a803113a581a257de..28e0d3d945159796100d4fdb7f591a62cb9f795b 100644 (file)
@@ -722,7 +722,7 @@ static int dvb_register(struct cx8802_dev *dev)
        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);
 }
 
 /* ----------------------------------------------------------- */
index 222a36c3891756489c20ca9b1a0c1553ed2298f2..98a492ddc216081cc8a0e1ca8e9359171c67ed25 100644 (file)
@@ -1088,7 +1088,7 @@ static int dvb_init(struct saa7134_dev *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)
index caf3e7e2f21989cac195c23e88d07beb53194a64..7ee8a53cd336f1702a35b2532071b1955d9af3f2 100644 (file)
@@ -135,14 +135,15 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed)
 
 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);
index b78d90fe629fb0b816f336015e07126116ce6af8..8233cafdeef6de74970ed18f752294e42005c525 100644 (file)
@@ -26,7 +26,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);
 
 /*