summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2003-10-14 09:05:25 +0000
committerMichael Hunold <devnull@localhost>2003-10-14 09:05:25 +0000
commit35c7353c111f24f077da49c7ef824145bcb6af05 (patch)
tree6333821edf39f20ac0356fadba3e2c0ff37fbbec /linux/drivers/media
parente243c3d8dd6651711af480c436fc78a347b5e68e (diff)
downloadmediapointer-dvb-s2-35c7353c111f24f077da49c7ef824145bcb6af05.tar.gz
mediapointer-dvb-s2-35c7353c111f24f077da49c7ef824145bcb6af05.tar.bz2
Backfeed whitespace changes from linux-2.6.0-test7, so this won't
drive me insane anymore. No other changes: whitespace tolerant diff shows no differences.
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.c262
1 files changed, 126 insertions, 136 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c
index 4bbca09cd..73725594b 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1,27 +1,27 @@
-/*
+/*
* dvb_net.c
*
* Copyright (C) 2001 Convergence integrated media GmbH
- * Ralph Metzler <ralph@convergence.de>
+ * Ralph Metzler <ralph@convergence.de>
* Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
+ *
*/
#include <linux/dvb/net.h>
@@ -43,10 +43,10 @@
struct dvb_net_priv {
int in_use;
- struct net_device_stats stats;
- char name[6];
+ struct net_device_stats stats;
+ char name[6];
u16 pid;
- struct dmx_demux *demux;
+ struct dmx_demux *demux;
struct dmx_section_feed *secfeed;
struct dmx_section_filter *secfilter;
int multi_num;
@@ -62,9 +62,8 @@ struct dvb_net_priv {
};
-
/**
- * Determine the packet's protocol ID. The rule here is that we
+ * Determine the packet's protocol ID. The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*
@@ -76,32 +75,32 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb,
{
struct ethhdr *eth;
unsigned char *rawp;
-
- skb->mac.raw = skb->data;
- skb_pull(skb, dev->hard_header_len);
- eth = skb->mac.ethernet;
-
+
+ skb->mac.raw=skb->data;
+ skb_pull(skb,dev->hard_header_len);
+ eth= skb->mac.ethernet;
+
if (*eth->h_dest & 1) {
- if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0)
- skb->pkt_type = PACKET_BROADCAST;
+ if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
+ skb->pkt_type=PACKET_BROADCAST;
else
- skb->pkt_type = PACKET_MULTICAST;
+ skb->pkt_type=PACKET_MULTICAST;
}
-
+
if (ntohs(eth->h_proto) >= 1536)
return eth->h_proto;
-
+
rawp = skb->data;
-
+
/**
* This is a magic hack to spot IPX packets. Older Novell breaks
* the protocol design and runs IPX over 802.3 without an 802.2 LLC
* layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
* won't work for fault tolerant netware but does for the rest.
*/
- if (*(unsigned short *) rawp == 0xFFFF)
+ if (*(unsigned short *)rawp == 0xFFFF)
return htons(ETH_P_802_3);
-
+
/**
* Real 802.2 LLC
*/
@@ -111,8 +110,8 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb,
static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
{
- u8 *eth;
- struct sk_buff *skb;
+ u8 *eth;
+ struct sk_buff *skb;
/* note: pkt_len includes a 32bit checksum */
if (pkt_len < 16) {
@@ -130,9 +129,9 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
}
if (pkt[5] & 0x02) {
//FIXME: handle LLC/SNAP
- ((struct dvb_net_priv *) dev->priv)->stats.rx_dropped++;
- return;
- }
+ ((struct dvb_net_priv *)dev->priv)->stats.rx_dropped++;
+ return;
+ }
if (pkt[7]) {
/* FIXME: assemble datagram from multiple sections */
((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
@@ -156,31 +155,31 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
memcpy(eth + 14, pkt + 12, pkt_len - 12 - 4);
/* create ethernet header: */
- eth[0] = pkt[0x0b];
- eth[1] = pkt[0x0a];
- eth[2] = pkt[0x09];
- eth[3] = pkt[0x08];
- eth[4] = pkt[0x04];
- eth[5] = pkt[0x03];
+ eth[0]=pkt[0x0b];
+ eth[1]=pkt[0x0a];
+ eth[2]=pkt[0x09];
+ eth[3]=pkt[0x08];
+ eth[4]=pkt[0x04];
+ eth[5]=pkt[0x03];
- eth[6] = eth[7] = eth[8] = eth[9] = eth[10] = eth[11] = 0;
+ eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
eth[12] = 0x08; /* ETH_P_IP */
eth[13] = 0x00;
skb->protocol = dvb_net_eth_type_trans(skb, dev);
-
- ((struct dvb_net_priv *) dev->priv)->stats.rx_packets++;
- ((struct dvb_net_priv *) dev->priv)->stats.rx_bytes += skb->len;
- netif_rx(skb);
+
+ ((struct dvb_net_priv *)dev->priv)->stats.rx_packets++;
+ ((struct dvb_net_priv *)dev->priv)->stats.rx_bytes+=skb->len;
+ netif_rx(skb);
}
-
-static int dvb_net_callback (const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_section_filter *filter,
- enum dmx_success success)
+
+static int dvb_net_callback(const u8 *buffer1, size_t buffer1_len,
+ const u8 *buffer2, size_t buffer2_len,
+ struct dmx_section_filter *filter,
+ enum dmx_success success)
{
- struct net_device *dev=(struct net_device *) filter->priv;
+ struct net_device *dev=(struct net_device *) filter->priv;
/**
* we rely on the DVB API definition where exactly one complete
@@ -190,29 +189,25 @@ static int dvb_net_callback (const u8 *buffer1, size_t buffer1_len,
return 0;
}
-
-static int dvb_net_tx (struct sk_buff *skb, struct net_device *dev)
+static int dvb_net_tx(struct sk_buff *skb, struct net_device *dev)
{
return 0;
}
+static u8 mask_normal[6]={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+static u8 mask_allmulti[6]={0xff, 0xff, 0xff, 0x00, 0x00, 0x00};
+static u8 mac_allmulti[6]={0x01, 0x00, 0x5e, 0x00, 0x00, 0x00};
+static u8 mask_promisc[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static u8 mask_normal [6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-static u8 mask_allmulti [6] = {0xff, 0xff, 0xff, 0x00, 0x00, 0x00};
-static u8 mac_allmulti [6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0x00};
-static u8 mask_promisc [6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-static int dvb_net_filter_set (struct net_device *dev,
- struct dmx_section_filter **secfilter,
- u8 *mac, u8 *mac_mask)
+static int dvb_net_filter_set(struct net_device *dev,
+ struct dmx_section_filter **secfilter,
+ u8 *mac, u8 *mac_mask)
{
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
int ret;
*secfilter=0;
-
ret = priv->secfeed->allocate_filter(priv->secfeed, secfilter);
-
if (ret<0) {
printk("%s: could not get filter\n", dev->name);
return ret;
@@ -224,13 +219,13 @@ static int dvb_net_filter_set (struct net_device *dev,
memset((*secfilter)->filter_mask, 0x00, DMX_MAX_FILTER_SIZE);
memset((*secfilter)->filter_mode, 0xff, DMX_MAX_FILTER_SIZE);
- (*secfilter)->filter_value[0] = 0x3e;
- (*secfilter)->filter_value[3] = mac[5];
- (*secfilter)->filter_value[4] = mac[4];
- (*secfilter)->filter_value[8] = mac[3];
- (*secfilter)->filter_value[9] = mac[2];
- (*secfilter)->filter_value[10] = mac[1];
- (*secfilter)->filter_value[11] = mac[0];
+ (*secfilter)->filter_value[0]=0x3e;
+ (*secfilter)->filter_value[3]=mac[5];
+ (*secfilter)->filter_value[4]=mac[4];
+ (*secfilter)->filter_value[8]=mac[3];
+ (*secfilter)->filter_value[9]=mac[2];
+ (*secfilter)->filter_value[10]=mac[1];
+ (*secfilter)->filter_value[11]=mac[0];
(*secfilter)->filter_mask[0] = 0xff;
(*secfilter)->filter_mask[3] = mac_mask[5];
@@ -238,7 +233,7 @@ static int dvb_net_filter_set (struct net_device *dev,
(*secfilter)->filter_mask[8] = mac_mask[3];
(*secfilter)->filter_mask[9] = mac_mask[2];
(*secfilter)->filter_mask[10] = mac_mask[1];
- (*secfilter)->filter_mask[11] = mac_mask[0];
+ (*secfilter)->filter_mask[11]=mac_mask[0];
dprintk("%s: filter mac=%02x %02x %02x %02x %02x %02x\n",
dev->name, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
@@ -249,34 +244,34 @@ static int dvb_net_filter_set (struct net_device *dev,
return 0;
}
-static int dvb_net_feed_start (struct net_device *dev)
+static int dvb_net_feed_start(struct net_device *dev)
{
int ret, i;
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
- struct dmx_demux *demux = priv->demux;
- unsigned char *mac = (unsigned char *) dev->dev_addr;
-
+ struct dmx_demux *demux = priv->demux;
+ unsigned char *mac = (unsigned char *) dev->dev_addr;
+
dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
if (priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
- priv->secfeed = 0;
- priv->secfilter = 0;
+ priv->secfeed=0;
+ priv->secfilter=0;
dprintk("%s: alloc secfeed\n", __FUNCTION__);
- ret = demux->allocate_section_feed(demux, &priv->secfeed,
- dvb_net_callback);
- if (ret < 0) {
+ ret=demux->allocate_section_feed(demux, &priv->secfeed,
+ dvb_net_callback);
+ if (ret<0) {
printk("%s: could not allocate section feed\n", dev->name);
return ret;
}
ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1);
- if (ret < 0) {
+ if (ret<0) {
printk("%s: could not set section feed\n", dev->name);
priv->demux->release_section_feed(priv->demux, priv->secfeed);
- priv->secfeed = 0;
+ priv->secfeed=0;
return ret;
}
@@ -294,54 +289,53 @@ static int dvb_net_feed_start (struct net_device *dev)
}
break;
case RX_MODE_ALL_MULTI:
- priv->multi_num = 1;
+ priv->multi_num=1;
dprintk("%s: set multi_secfilter[0]\n", __FUNCTION__);
dvb_net_filter_set(dev, &priv->multi_secfilter[0],
mac_allmulti, mask_allmulti);
break;
case RX_MODE_PROMISC:
- priv->multi_num = 0;
+ priv->multi_num=0;
dprintk("%s: set secfilter\n", __FUNCTION__);
dvb_net_filter_set(dev, &priv->secfilter, mac, mask_promisc);
break;
}
-
+
dprintk("%s: start filtering\n", __FUNCTION__);
priv->secfeed->start_filtering(priv->secfeed);
return 0;
}
-
-static void dvb_net_feed_stop (struct net_device *dev)
+static void dvb_net_feed_stop(struct net_device *dev)
{
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
int i;
dprintk("%s\n", __FUNCTION__);
- if (priv->secfeed) {
+ if (priv->secfeed) {
if (priv->secfeed->is_filtering) {
dprintk("%s: stop secfeed\n", __FUNCTION__);
- priv->secfeed->stop_filtering(priv->secfeed);
+ priv->secfeed->stop_filtering(priv->secfeed);
}
if (priv->secfilter) {
dprintk("%s: release secfilter\n", __FUNCTION__);
priv->secfeed->release_filter(priv->secfeed,
- priv->secfilter);
- priv->secfilter = 0;
+ priv->secfilter);
+ priv->secfilter=0;
}
- for (i = 0; i < priv->multi_num; i++) {
+ for (i=0; i<priv->multi_num; i++) {
if (priv->multi_secfilter[i]) {
dprintk("%s: release multi_filter[%d]\n", __FUNCTION__, i);
priv->secfeed->release_filter(priv->secfeed,
- priv->multi_secfilter[i]);
- priv->multi_secfilter[i] = 0;
- }
+ priv->multi_secfilter[i]);
+ priv->multi_secfilter[i]=0;
+ }
}
priv->demux->release_section_feed(priv->demux, priv->secfeed);
- priv->secfeed = 0;
+ priv->secfeed=0;
} else
printk("%s: no feed to stop\n", dev->name);
}
@@ -369,8 +363,8 @@ static void wq_set_multicast_list (void *data)
dvb_net_feed_stop(dev);
priv->rx_mode = RX_MODE_UNI;
-
- if (dev->flags & IFF_PROMISC) {
+
+ if(dev->flags & IFF_PROMISC) {
dprintk("%s: promiscuous mode\n", dev->name);
priv->rx_mode = RX_MODE_PROMISC;
} else if ((dev->flags & IFF_ALLMULTI)) {
@@ -386,15 +380,15 @@ static void wq_set_multicast_list (void *data)
priv->rx_mode = RX_MODE_MULTI;
priv->multi_num = 0;
- for (mci = 0, mc = dev->mc_list;
+ for (mci = 0, mc=dev->mc_list;
mci < dev->mc_count;
mc = mc->next, mci++) {
dvb_set_mc_filter(dev, mc);
}
}
- dvb_net_feed_start(dev);
-}
+ dvb_net_feed_start(dev);
+ }
static void dvb_net_set_multicast_list (struct net_device *dev)
@@ -404,7 +398,7 @@ static void dvb_net_set_multicast_list (struct net_device *dev)
}
-static int dvb_net_set_config (struct net_device *dev, struct ifmap *map)
+static int dvb_net_set_config(struct net_device *dev, struct ifmap *map)
{
if (netif_running(dev))
return -EBUSY;
@@ -437,7 +431,7 @@ static int dvb_net_set_mac (struct net_device *dev, void *p)
}
-static int dvb_net_open (struct net_device *dev)
+static int dvb_net_open(struct net_device *dev)
{
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
@@ -447,19 +441,18 @@ static int dvb_net_open (struct net_device *dev)
}
-static int dvb_net_stop (struct net_device *dev)
+static int dvb_net_stop(struct net_device *dev)
{
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
priv->in_use--;
- dvb_net_feed_stop(dev);
+ dvb_net_feed_stop(dev);
return 0;
}
-
-static struct net_device_stats* dvb_net_get_stats (struct net_device *dev)
+static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
{
- return &((struct dvb_net_priv*) dev->priv)->stats;
+ return &((struct dvb_net_priv*) dev->priv)->stats;
}
@@ -472,10 +465,10 @@ static int dvb_net_init_dev (struct net_device *dev)
dev->hard_start_xmit = dvb_net_tx;
dev->get_stats = dvb_net_get_stats;
dev->set_multicast_list = dvb_net_set_multicast_list;
- dev->set_config = dvb_net_set_config;
+ dev->set_config = dvb_net_set_config;
dev->set_mac_address = dvb_net_set_mac;
dev->mtu = 4096;
- dev->mc_count = 0;
+ dev->mc_count = 0;
dev->hard_header_cache = NULL;
dev->flags |= IFF_NOARP;
@@ -484,7 +477,7 @@ static int dvb_net_init_dev (struct net_device *dev)
}
-static int get_if (struct dvb_net *dvbnet)
+static int get_if(struct dvb_net *dvbnet)
{
int i;
@@ -495,54 +488,54 @@ static int get_if (struct dvb_net *dvbnet)
if (i == DVB_NET_DEVICES_MAX)
return -1;
- dvbnet->state[i] = 1;
+ dvbnet->state[i]=1;
return i;
}
static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
{
- struct net_device *net;
+ struct net_device *net;
struct dmx_demux *demux;
struct dvb_net_priv *priv;
int result;
int if_num;
-
+
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;
net = &dvbnet->device[if_num];
demux = dvbnet->demux;
-
+
memset(net, 0, sizeof(struct net_device));
memcpy(net->name, "dvb0_0", 7);
net->name[3] = dvbnet->dvbdev->adapter->num + '0';
net->name[5] = if_num + '0';
- net->addr_len = 6;
+ net->addr_len = 6;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
net->next = NULL;
net->init = dvb_net_init_dev;
if (!(net->priv = kmalloc(sizeof(struct dvb_net_priv), GFP_KERNEL)))
return -ENOMEM;
-
+
priv = net->priv;
memset(priv, 0, sizeof(struct dvb_net_priv));
priv->demux = demux;
- priv->pid = pid;
+ 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;
-
+ net->base_addr = pid;
+
if ((result = register_netdev(net)) < 0) {
return result;
}
- return if_num;
+ return if_num;
}
@@ -570,36 +563,36 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
struct dvb_net *dvbnet = (struct dvb_net *) dvbdev->priv;
- if (((file->f_flags&O_ACCMODE) == O_RDONLY))
+ if (((file->f_flags&O_ACCMODE)==O_RDONLY))
return -EPERM;
-
+
switch (cmd) {
case NET_ADD_IF:
{
- struct dvb_net_if *dvbnetif = (struct dvb_net_if *)parg;
+ struct dvb_net_if *dvbnetif=(struct dvb_net_if *)parg;
int result;
-
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- result = dvb_net_add_if(dvbnet, dvbnetif->pid);
+ result=dvb_net_add_if(dvbnet, dvbnetif->pid);
if (result<0)
return result;
- dvbnetif->if_num = result;
+ dvbnetif->if_num=result;
break;
}
case NET_GET_IF:
{
struct net_device *netdev;
struct dvb_net_priv *priv_data;
- struct dvb_net_if *dvbnetif = (struct dvb_net_if *)parg;
+ struct dvb_net_if *dvbnetif=(struct dvb_net_if *)parg;
if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
!dvbnet->state[dvbnetif->if_num])
return -EFAULT;
- netdev = (struct net_device*)&dvbnet->device[dvbnetif->if_num];
- priv_data = (struct dvb_net_priv*)netdev->priv;
- dvbnetif->pid = priv_data->pid;
+ netdev=(struct net_device*)&dvbnet->device[dvbnetif->if_num];
+ priv_data=(struct dvb_net_priv*)netdev->priv;
+ dvbnetif->pid=priv_data->pid;
break;
}
case NET_REMOVE_IF:
@@ -609,21 +602,18 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
default:
return -EINVAL;
}
-
return 0;
}
-
static int dvb_net_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl);
}
-
static struct file_operations dvb_net_fops = {
.owner = THIS_MODULE,
- .read = 0,
+ .read = 0,
.write = 0,
.ioctl = dvb_net_ioctl,
.open = dvb_generic_open,
@@ -631,12 +621,11 @@ static struct file_operations dvb_net_fops = {
.poll = 0,
};
-
static struct dvb_device dvbdev_net = {
- .priv = 0,
- .users = 1,
- .writers = 1,
- .fops = &dvb_net_fops,
+ .priv = 0,
+ .users = 1,
+ .writers = 1,
+ .fops = &dvb_net_fops,
};
@@ -658,7 +647,7 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
struct dmx_demux *dmx)
{
int i;
-
+
dvbnet->demux = dmx;
for (i=0; i<DVB_NET_DEVICES_MAX; i++)
@@ -669,3 +658,4 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
return 0;
}
+