From: Andrew Morton Attempt to salvage the coding style a bit. This driver is a disaster. Cc: Christian Praehauser Cc: Mauro Carvalho Chehab Signed-off-by: Andrew Morton --- drivers/media/dvb/dvb-core/dvb_net.c | 91 ++++++++++++++----------- 1 files changed, 52 insertions(+), 39 deletions(-) diff -puN drivers/media/dvb/dvb-core/dvb_net.c~dvb-core-ule-fixes-and-rfc4326-additions-kernel-2616-tidy drivers/media/dvb/dvb-core/dvb_net.c --- devel/drivers/media/dvb/dvb-core/dvb_net.c~dvb-core-ule-fixes-and-rfc4326-additions-kernel-2616-tidy 2006-04-20 03:21:01.000000000 -0700 +++ devel-akpm/drivers/media/dvb/dvb-core/dvb_net.c 2006-04-20 03:24:48.000000000 -0700 @@ -244,7 +244,7 @@ static int ule_bridged_sndu( struct dvb_ return 0; } -static int ule_exthdr_padding( struct dvb_net_priv *p ) +static int ule_exthdr_padding(struct dvb_net_priv *p) { return 0; } @@ -275,11 +275,11 @@ static int handle_one_ule_extension( str ext_len = ule_mandatory_ext_handlers[htype]( p ); if(ext_len >= 0) { p->ule_next_hdr += ext_len; - if (! p->ule_bridged) { - p->ule_sndu_type = ntohs( *(unsigned short *)p->ule_next_hdr ); + if (!p->ule_bridged) { + p->ule_sndu_type = ntohs(*(unsigned short *)p->ule_next_hdr); p->ule_next_hdr += 2; } else { - p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)) ); + p->ule_sndu_type = ntohs(*(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN))); /* This assures the extension handling loop will terminate. */ } } @@ -294,7 +294,10 @@ static int handle_one_ule_extension( str (void)ule_optional_ext_handlers[htype]( p ); p->ule_next_hdr += ext_len; p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr-2) ); - /* note: the length of the next header type is included in the length of THIS optional extension header */ + /* + * note: the length of the next header type is included in the + * length of THIS optional extension header + */ } return ext_len; @@ -307,10 +310,13 @@ static int handle_ule_extensions( struct p->ule_next_hdr = p->ule_skb->data; do { l = handle_one_ule_extension( p ); - if (l < 0) return l; /* Stop extension header processing and discard SNDU. */ + if (l < 0) + return l; /* Stop extension header processing and discard SNDU. */ total_ext_len += l; #ifdef ULE_DEBUG - dprintk("handle_ule_extensions: ule_next_hdr=%p, ule_sndu_type=%i, l=%i, total_ext_len=%i\n", p->ule_next_hdr, (int) p->ule_sndu_type, l, total_ext_len); + dprintk("handle_ule_extensions: ule_next_hdr=%p, ule_sndu_type=%i, " + "l=%i, total_ext_len=%i\n", p->ule_next_hdr, + (int) p->ule_sndu_type, l, total_ext_len); #endif } while (p->ule_sndu_type < 1536); @@ -638,88 +644,95 @@ static void dvb_net_ule( struct net_devi } else { /* CRC32 verified OK. */ u8 dest_addr[ETH_ALEN]; - static const u8 bc_addr[ETH_ALEN] = { [ 0 ... ETH_ALEN-1] = 0xFF}; + static const u8 bc_addr[ETH_ALEN] = + { [ 0 ... ETH_ALEN-1] = 0xff }; /* CRC32 was OK. Remove it from skb. */ priv->ule_skb->tail -= 4; priv->ule_skb->len -= 4; if (!priv->ule_dbit) { - /* The destination MAC address is the next data in the skb. - * It comes before any extension headers. + /* + * The destination MAC address is the + * next data in the skb. It comes + * before any extension headers. * - * Check, if the payload of this SNDU should be passed up the stack. + * Check if the payload of this SNDU + * should be passed up the stack. */ register int drop = 0; - if(priv->rx_mode != RX_MODE_PROMISC) { - if(priv->ule_skb->data[0] & 0x01) { + if (priv->rx_mode != RX_MODE_PROMISC) { + if (priv->ule_skb->data[0] & 0x01) { /* multicast or broadcast */ - if(memcmp( priv->ule_skb->data, bc_addr, ETH_ALEN )) { + if (memcmp(priv->ule_skb->data, bc_addr, ETH_ALEN)) { /* multicast */ - if(priv->rx_mode == RX_MODE_MULTI) { + if (priv->rx_mode == RX_MODE_MULTI) { int i; - for(i=0; imulti_num && memcmp( priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN ); i++); - if(i == priv->multi_num) + for(i = 0; i < priv->multi_num && memcmp(priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN); i++) + ; + if (i == priv->multi_num) drop = 1; - } - else if(priv->rx_mode != RX_MODE_ALL_MULTI) + } else if (priv->rx_mode != RX_MODE_ALL_MULTI) drop = 1; /* no broadcast; */ /* else: all multicast mode: accept all multicast packets */ } /* else: broadcast */ } - else if(memcmp( priv->ule_skb->data, dev->dev_addr, ETH_ALEN )) + else if (memcmp(priv->ule_skb->data, dev->dev_addr, ETH_ALEN)) drop = 1; /* else: destination address matches the MAC address of our receiver device */ } /* else: promiscious mode; pass everything up the stack */ - if(drop) - { + if (drop) { #ifdef ULE_DEBUG - dprintk( "Dropping SNDU: MAC destination address does not match: dest addr: "MAC_ADDR_PRINTFMT", dev addr: "MAC_ADDR_PRINTFMT"\n", + dprintk("Dropping SNDU: MAC destination address does not match: dest addr: "MAC_ADDR_PRINTFMT", dev addr: "MAC_ADDR_PRINTFMT"\n", MAX_ADDR_PRINTFMT_ARGS(priv->ule_skb->data), MAX_ADDR_PRINTFMT_ARGS(dev->dev_addr)); #endif - dev_kfree_skb( priv->ule_skb ); + dev_kfree_skb(priv->ule_skb); goto sndu_done; } else { memcpy(dest_addr, priv->ule_skb->data, ETH_ALEN); - skb_pull( priv->ule_skb, ETH_ALEN ); + skb_pull(priv->ule_skb, ETH_ALEN); } } /* Handle ULE Extension Headers. */ if (priv->ule_sndu_type < 1536) { /* There is an extension header. Handle it accordingly. */ - int l = handle_ule_extensions( priv ); + int l = handle_ule_extensions(priv); if (l < 0) { /* Mandatory extension header unknown or TEST SNDU. Drop it. */ // printk( KERN_WARNING "Dropping SNDU, extension headers.\n" ); - dev_kfree_skb( priv->ule_skb ); + dev_kfree_skb(priv->ule_skb); goto sndu_done; } - skb_pull( priv->ule_skb, l ); + skb_pull(priv->ule_skb, l); } - /* Construct/assure correct ethernet header. - * Note: in bridged mode (priv->ule_bridged != 0) we already have the (original) ethernet header - * at the start of the payload (after optional dest. address and any extension headers). - * */ + /* + * Construct/assure correct ethernet header. + * Note: in bridged mode (priv->ule_bridged != + * 0) we already have the (original) ethernet + * header at the start of the payload (after + * optional dest. address and any extension + * headers). + */ - if (! priv->ule_bridged) { - skb_push( priv->ule_skb, ETH_HLEN); + if (!priv->ule_bridged) { + skb_push(priv->ule_skb, ETH_HLEN); ethh = (struct ethhdr *)priv->ule_skb->data; - if(!priv->ule_dbit) /* dest_addr buffer is only valid if priv->ule_dbit == 0 */ - { - memcpy( ethh->h_dest, dest_addr, ETH_ALEN ); - memset( ethh->h_source, 0, ETH_ALEN ); + if (!priv->ule_dbit) { + /* dest_addr buffer is only valid if priv->ule_dbit == 0 */ + memcpy(ethh->h_dest, dest_addr, ETH_ALEN); + memset(ethh->h_source, 0, ETH_ALEN); } else /* zeroize source and dest */ memset( ethh, 0, ETH_ALEN*2 ); - ethh->h_proto = htons( priv->ule_sndu_type ); + ethh->h_proto = htons(priv->ule_sndu_type); } /* else: skb is in correct state; nothing to do. */ priv->ule_bridged = 0; _