summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2003-10-14 09:23:17 +0000
committerMichael Hunold <devnull@localhost>2003-10-14 09:23:17 +0000
commit8197da3237749d7313a54a5db5811dc31c65f530 (patch)
tree98fcee2aa1de6b21cc8af870c7da92efdd1ebb6d /linux/drivers
parent35c7353c111f24f077da49c7ef824145bcb6af05 (diff)
downloadmediapointer-dvb-s2-8197da3237749d7313a54a5db5811dc31c65f530.tar.gz
mediapointer-dvb-s2-8197da3237749d7313a54a5db5811dc31c65f530.tar.bz2
In 2.6, the networking code has changed. Unfortunately, we
now have to keep 2 versions of the device register/unregister functions.
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.c71
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.h4
2 files changed, 71 insertions, 4 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c
index 73725594b..c5f0887eb 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c
@@ -455,8 +455,11 @@ static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
return &((struct dvb_net_priv*) dev->priv)->stats;
}
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
static int dvb_net_init_dev (struct net_device *dev)
+#else
+static void dvb_net_setup(struct net_device *dev)
+#endif
{
ether_setup(dev);
@@ -472,10 +475,10 @@ static int dvb_net_init_dev (struct net_device *dev)
dev->hard_header_cache = NULL;
dev->flags |= IFF_NOARP;
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
return 0;
}
-
+#endif
static int get_if(struct dvb_net *dvbnet)
{
@@ -492,7 +495,7 @@ static int get_if(struct dvb_net *dvbnet)
return i;
}
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
{
struct net_device *net;
@@ -537,8 +540,49 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
return if_num;
}
+#else
+static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
+{
+ struct net_device *net;
+ struct dvb_net_priv *priv;
+ int result;
+ int if_num;
+
+ if ((if_num = get_if(dvbnet)) < 0)
+ return -EINVAL;
+
+ net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
+ dvb_net_setup);
+ if (!net)
+ return -ENOMEM;
+
+ sprintf(net->name, "dvb%d_%d", dvbnet->dvbdev->adapter->num, if_num);
+
+ net->addr_len = 6;
+ memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
+
+ dvbnet->device[if_num] = net;
+
+ priv = net->priv;
+ priv->demux = dvbnet->demux;
+ priv->pid = pid;
+ priv->rx_mode = RX_MODE_UNI;
+
+ INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
+ INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
+
+ net->base_addr = pid;
+
+ if ((result = register_netdev(net)) < 0) {
+ kfree(net);
+ return result;
+ }
+ return if_num;
+}
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
static int dvb_net_remove_if(struct dvb_net *dvbnet, int num)
{
struct dvb_net_priv *priv = dvbnet->device[num].priv;
@@ -555,7 +599,26 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, int num)
dvbnet->state[num]=0;
return 0;
}
+#else
+static int dvb_net_remove_if(struct dvb_net *dvbnet, int num)
+{
+ struct net_device *net = dvbnet->device[num];
+ struct dvb_net_priv *priv = net->priv;
+
+ if (!dvbnet->state[num])
+ return -EINVAL;
+ if (priv->in_use)
+ return -EBUSY;
+ dvb_net_stop(net);
+ flush_scheduled_work();
+ unregister_netdev(net);
+ dvbnet->state[num]=0;
+ free_netdev(net);
+
+ return 0;
+}
+#endif
static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *parg)
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.h b/linux/drivers/media/dvb/dvb-core/dvb_net.h
index 93648d4d0..128796520 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.h
@@ -34,7 +34,11 @@
struct dvb_net {
struct dvb_device *dvbdev;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
struct net_device device[DVB_NET_DEVICES_MAX];
+#else
+ struct net_device *device[DVB_NET_DEVICES_MAX];
+#endif
int state[DVB_NET_DEVICES_MAX];
struct dmx_demux *demux;
};