[linux-dvb] [patch] dvb_net hotplugging support

Markus Rechberger markus.rechberger at amd.com
Thu Aug 9 16:06:27 CEST 2007


This patch addresses the discussion between Trent and me back then [1] 
in april.
It improves dvb_net hotplugging support, even though it might still 
require some more improvements.
This patch hasn't been tested yet, it would be nice if someone could 
test it and give some more feedback on it.

[1] http://lkml.org/lkml/2007/4/27/507

http://mcentral.de/~mrec/patches/dvb_net_fixes.diff

Signed-off-by: Markus Rechberger <markus.rechberger at amd.com>

diff -r cae47793b091 linux/drivers/media/dvb/dvb-core/dvb_net.c
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c        Tue Aug 07 
10:52:55 2007 -0300
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c        Thu Aug 09 
16:00:40 2007 +0200
@@ -1501,10 +1501,12 @@ static int dvb_net_close(struct inode *i
 static int dvb_net_close(struct inode *inode, struct file *file)
 {
        struct dvb_device *dvbdev = file->private_data;
-       struct dvb_net *dvbnet = dvbdev->priv;
+       struct dvb_net *dvbnet;

        if (!dvbdev)
                return -ENODEV;
+
+       dvbnet = dvbdev->priv;

        if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
                dvbdev->readers++;
@@ -1522,11 +1524,40 @@ static int dvb_net_close(struct inode *i
        return 0;
 }

+static int dvb_net_open_node(struct inode *inode, struct file *file)
+{
+       struct dvb_device *dvbdev = file->private_data;
+       struct dvb_net *dvbnet;
+
+       if (!dvbdev)
+               return -ENODEV;
+
+       dvbnet = dvbdev->priv;
+      
+       if (dvbnet->exit)
+               return -ENODEV;
+      
+       if (!dvbdev->users)
+               return -EBUSY;
+
+       if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+               if (!dvbdev->readers)
+                       return -EBUSY;
+               dvbdev->readers--;
+       } else {
+               if (!dvbdev->writers)
+                       return -EBUSY;
+               dvbdev->writers--;
+       }
+
+       dvbdev->users--;
+       return 0;
+}

 static struct file_operations dvb_net_fops = {
        .owner = THIS_MODULE,
        .ioctl = dvb_net_ioctl,
-       .open = dvb_generic_open,
+       .open = dvb_net_open_node,
        .release = dvb_net_close,
 };






More information about the linux-dvb mailing list