net/atm neatening cleanups
Subsystems (4)
cover net/atm neatening cleanups
Miscellaneous cleanups to net/atm
Joe Perches (21):
net/atm: Convert printk to pr_<level> net/atm/addr.c: Convert include <asm to include <linux net/atm/atm_misc.c: checkpatch cleanups net/atm/atm_sysfs.c: checkpatch cleanups net/atm/br2684.c: checkpatch cleanups net/atm/clip.c: checkpatch cleanups net/atm/common.c: checkpatch cleanups net/atm/ioctl.c: checkpatch cleanups net/atm/lec.c: checkpatch cleanups
net/atm/mpc.c: checkpatch cleanups net/atm/mpoa_caches.c: checkpatch cleanups net/atm/mpoa_proc.c: checkpatch cleanups net/atm/pppoatm.c: checkpatch cleanups net/atm/proc.c: checkpatch cleanups
net/atm/pvc.c: checkpatch cleanups
net/atm/raw.c: checkpatch cleanups net/atm/resources.c: checkpatch cleanups net/atm/signaling.c: checkpatch cleanups net/atm/svc.c: checkpatch cleanups
net/atm/lec.c: Add __lec_arp_check_expire and other cleanups net/atm: Cleanup dprint/ddprintk #defines and uses
net/atm/addr.c | 2 +- net/atm/atm_misc.c | 40 ++-- net/atm/atm_sysfs.c | 27 ++- net/atm/br2684.c | 90 ++++---- net/atm/clip.c | 86 ++++---- net/atm/common.c | 386 ++++++++++++++++--------------- net/atm/ioctl.c | 196 ++++++++-------- net/atm/lec.c | 599 +++++++++++++++++++++++-------------------------- net/atm/mpc.c | 540 +++++++++++++++++++++++++-------------------- net/atm/mpoa_caches.c | 190 +++++++++------- net/atm/mpoa_proc.c | 89 ++++---- net/atm/pppoatm.c | 28 ++- net/atm/proc.c | 81 ++++--- net/atm/pvc.c | 43 ++-- net/atm/raw.c | 26 +-- net/atm/resources.c | 402 ++++++++++++++++----------------- net/atm/signaling.c | 219 +++++++++--------- net/atm/svc.c | 258 +++++++++++----------- 18 files changed, 1675 insertions(+), 1627 deletions(-)
PATCH 1/21 net/atm: Convert printk to pr_<level>
Add #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ Remove function names from output
Use single line pr_debug instead of broken multiple uses without newline
--- net/atm/br2684.c | 18 +++--- net/atm/clip.c | 60 ++++++++-------- net/atm/common.c | 52 ++++++++------ net/atm/ioctl.c | 7 +- net/atm/lec.c | 192 ++++++++++++++++++++++----------------------------- net/atm/mpc.c | 4 +- net/atm/mpoa_proc.c | 3 +- net/atm/pppoatm.c | 17 +++-- net/atm/raw.c | 5 +- net/atm/resources.c | 12 +-- net/atm/signaling.c | 19 +++--- net/atm/svc.c | 13 ++-- 12 files changed, 190 insertions(+), 212 deletions(-)
net/atm/br2684.c +9 -9
@@ -6,6 +6,8 @@* Eric Kinzie, 2006-2007, US Naval Research Laboratory */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__ +#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h>
@@ -148,7 +150,7 @@ static void br2684_pop(struct atm_vcc *vcc, struct sk_buff *skb)struct br2684_vcc *brvcc =BR2684_VCC (vcc);struct net_device *net_dev = skb->dev; -pr_debug ("br2684_pop(vcc %p ; net_dev %p )\n" , vcc, net_dev); +pr_debug ("(vcc %p ; net_dev %p )\n" , vcc, net_dev); brvcc->old_pop (vcc, skb);if (!net_dev)
@@ -244,7 +246,7 @@ static netdev_tx_t br2684_start_xmit(struct sk_buff *skb,struct br2684_dev *brdev =BRPRIV (dev);struct br2684_vcc *brvcc; -pr_debug ("br2684_start_xmit, skb_dst(skb)=%p\n" ,skb_dst (skb)); +pr_debug ("skb_dst(skb)=%p\n" ,skb_dst (skb));read_lock (&devs_lock); brvcc =pick_outgoing_vcc (skb, brdev);if (brvcc ==NULL ) {
@@ -352,7 +354,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)struct net_device *net_dev = brvcc->device;struct br2684_dev *brdev =BRPRIV (net_dev); -pr_debug ("br2684_push\n" ); +pr_debug ("\n" );if (unlikely (skb ==NULL )) {/* skb==NULL means VCC is being destroyed */
@@ -479,8 +481,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)write_lock_irq (&devs_lock); net_dev =br2684_find_dev (&be.ifspec);if (net_dev ==NULL ) { -printk (KERN_ERR -"br2684: tried to attach to non-existant device\n" ); +pr_err ("tried to attach to non-existant device\n" ); err = -ENXIO ; goto error; }
@@ -503,8 +504,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) err = -EINVAL ; goto error; } -pr_debug ("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n" , atmvcc, - be.encaps, brvcc); +pr_debug ("vcc=%p, encaps=%d, brvcc=%p\n" , atmvcc, be.encaps, brvcc);if (list_empty (&brdev->brvccs) && !brdev->mac_was_set) {unsigned char *esi = atmvcc->dev->esi;if (esi[0 ] | esi[1 ] | esi[2 ] | esi[3 ] | esi[4 ] | esi[5 ])
@@ -595,7 +595,7 @@ static int br2684_create(void __user * arg)struct atm_newif_br2684 ni;enum br2684_payload payload; -pr_debug ("br2684_create\n" ); +pr_debug ("\n" );if (copy_from_user (&ni, arg,sizeof ni)) {return -EFAULT ;
@@ -624,7 +624,7 @@ static int br2684_create(void __user * arg)/* open, stop, do_ioctl ? */ err =register_netdev (netdev);if (err <0 ) { -printk (KERN_ERR "br2684_create: register_netdev failed\n" ); +pr_err ("register_netdev failed\n" );free_netdev (netdev);return err; }
net/atm/clip.c +29 -31
204 lines not on this page · raw message
net/atm/common.c +29 -23
109 lines not on this page · raw message
net/atm/ioctl.c +4 -3
@@ -3,6 +3,7 @@/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ /* 2003 John Levon <[email protected]> */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#include <linux/module.h> #include <linux/kmod.h>
@@ -97,8 +98,8 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg goto done;case ATM_SETSC :if (net_ratelimit ()) -printk (KERN_WARNING "ATM_SETSC is obsolete; used by %s:%d\n" , - current->comm,task_pid_nr (current)); +pr_warning ("ATM_SETSC is obsolete; used by %s:%d\n" , + current->comm,task_pid_nr (current)); error =0 ; goto done;case ATMSIGD_CTRL :
@@ -123,7 +124,7 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long argto think about it at all. dwmw2. */ if (compat) {if (net_ratelimit ()) -printk (KERN_WARNING "32-bit task cannot be atmsigd\n" ); +pr_warning ("32-bit task cannot be atmsigd\n" ); error = -EINVAL ; goto done; }
net/atm/lec.c +82 -110
400 lines not on this page · raw message
net/atm/mpc.c +3 -1
@@ -1,3 +1,5 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__ +#include <linux/kernel.h> #include <linux/string.h> #include <linux/timer.h>
@@ -1447,7 +1449,7 @@ static __init int atm_mpoa_init(void)register_atm_ioctl (&atm_ioctl_ops);if (mpc_proc_init () !=0 ) -printk (KERN_INFO "mpoa: failed to initialize /proc/mpoa\n" ); +pr_info ("failed to initialize /proc/mpoa\n" );printk ("mpc.c: " __DATE__" " __TIME__" initialized\n" );
net/atm/mpoa_proc.c +2 -1
@@ -1,3 +1,4 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#ifdef CONFIG_PROC_FS #include <linux/errno.h>
@@ -278,7 +279,7 @@ int mpc_proc_init(void) p =proc_create (STAT_FILE_NAME ,0 , atm_proc_root, &mpc_file_operations);if (!p) { -printk (KERN_ERR "Unable to initialize /proc/atm/%s\n" ,STAT_FILE_NAME ); +pr_err ("Unable to initialize /proc/atm/%s\n" ,STAT_FILE_NAME );return -ENOMEM ; }return 0 ;
net/atm/pppoatm.c +9 -8
@@ -33,6 +33,8 @@* These hooks are not yet available in ppp_generic */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__ +#include <linux/module.h> #include <linux/init.h> #include <linux/skbuff.h>
@@ -132,7 +134,7 @@ static void pppoatm_unassign_vcc(struct atm_vcc *atmvcc)static void pppoatm_push (struct atm_vcc *atmvcc,struct sk_buff *skb) {struct pppoatm_vcc *pvcc =atmvcc_to_pvcc (atmvcc); -pr_debug ("pppoatm push\n" ); +pr_debug ("\n" );if (skb ==NULL ) {/* VCC was closed */ pr_debug ("removing ATMPPP VCC %p\n" , pvcc);pppoatm_unassign_vcc (atmvcc);
@@ -165,10 +167,9 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb) pvcc->chan.mtu +=LLC_LEN ;break ; } -pr_debug ("Couldn't autodetect yet " -"(skb: %02X %02X %02X %02X %02X %02X)\n" , - skb->data[0 ], skb->data[1 ], skb->data[2 ], - skb->data[3 ], skb->data[4 ], skb->data[5 ]); +pr_debug ("Couldn't autodetect yet (skb: %02X %02X %02X %02X %02X %02X)\n" , + skb->data[0 ], skb->data[1 ], skb->data[2 ], + skb->data[3 ], skb->data[4 ], skb->data[5 ]); goto error;case e_vc:break ;
@@ -194,7 +195,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) {struct pppoatm_vcc *pvcc =chan_to_pvcc (chan);ATM_SKB (skb)->vcc = pvcc->atmvcc; -pr_debug ("pppoatm_send (skb=0x%p, vcc=0x%p)\n" , skb, pvcc->atmvcc); +pr_debug ("(skb=0x%p, vcc=0x%p)\n" , skb, pvcc->atmvcc);if (skb->data[0 ] =='\0' && (pvcc->flags &SC_COMP_PROT )) (void )skb_pull (skb,1 );switch (pvcc->encaps) {/* LLC encapsulation needed */
@@ -226,8 +227,8 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb)atomic_add (skb->truesize, &sk_atm (ATM_SKB (skb)->vcc)->sk_wmem_alloc);ATM_SKB (skb)->atm_options =ATM_SKB (skb)->vcc->atm_options; -pr_debug ("atm_skb(%p)->vcc(%p)->dev(%p)\n" , skb,ATM_SKB (skb)->vcc, -ATM_SKB (skb)->vcc->dev); +pr_debug ("atm_skb(%p)->vcc(%p)->dev(%p)\n" , + skb,ATM_SKB (skb)->vcc,ATM_SKB (skb)->vcc->dev);return ATM_SKB (skb)->vcc->send (ATM_SKB (skb)->vcc, skb) ?DROP_PACKET :1 ; nospace:
net/atm/raw.c +3 -2
@@ -2,6 +2,7 @@/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#include <linux/module.h> #include <linux/atmdev.h>
@@ -32,8 +33,8 @@ static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb) {struct sock *sk =sk_atm (vcc); -pr_debug ("APopR (%d) %d -= %d\n" , vcc->vci, -sk_wmem_alloc_get (sk), skb->truesize); +pr_debug ("(%d) %d -= %d\n" , + vcc->vci,sk_wmem_alloc_get (sk), skb->truesize);atomic_sub (skb->truesize, &sk->sk_wmem_alloc);dev_kfree_skb_any (skb); sk->sk_write_space (sk);
net/atm/resources.c +4 -8
@@ -7,6 +7,7 @@* 2002/01 - don't free the whole struct sock on sk->destruct time, * use the default destruct function initialized by sock_init_data */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#include <linux/ctype.h> #include <linux/string.h>
@@ -79,8 +80,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, dev =__alloc_atm_dev (type);if (!dev) { -printk (KERN_ERR "atm_dev_register: no space for dev %s\n" , - type); +pr_err ("no space for dev %s\n" , type);return NULL ; }mutex_lock (&atm_dev_mutex);
@@ -109,16 +109,12 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,atomic_set (&dev->refcnt,1 );if (atm_proc_dev_register (dev) <0 ) { -printk (KERN_ERR "atm_dev_register: " -"atm_proc_dev_register failed for dev %s\n" , - type); +pr_err ("atm_proc_dev_register failed for dev %s\n" , type); goto out_fail; }if (atm_register_sysfs (dev) <0 ) { -printk (KERN_ERR "atm_dev_register: " -"atm_register_sysfs failed for dev %s\n" , - type); +pr_err ("atm_register_sysfs failed for dev %s\n" , type);atm_proc_dev_deregister (dev); goto out_fail; }
net/atm/signaling.c +9 -10
@@ -2,6 +2,7 @@/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#include <linux/errno.h> /* error codes */ #include <linux/kernel.h> /* printk */
@@ -37,14 +38,14 @@ static void sigd_put_skb(struct sk_buff *skb)add_wait_queue (&sigd_sleep,&wait);while (!sigd) {set_current_state (TASK_UNINTERRUPTIBLE ); -pr_debug ("atmsvc: waiting for signaling demon...\n" ); +pr_debug ("atmsvc: waiting for signaling daemon...\n" );schedule (); } current->state =TASK_RUNNING ;remove_wait_queue (&sigd_sleep,&wait);#else if (!sigd) { -pr_debug ("atmsvc: no signaling demon\n" ); +pr_debug ("atmsvc: no signaling daemon\n" );kfree_skb (skb);return ; }
@@ -90,8 +91,7 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) msg = (struct atmsvc_msg *) skb->data;atomic_sub (skb->truesize, &sk_atm (vcc)->sk_wmem_alloc); vcc = *(struct atm_vcc **) &msg->vcc; -pr_debug ("sigd_send %d (0x%lx)\n" ,(int ) msg->type, - (unsigned long ) vcc); +pr_debug ("%d (0x%lx)\n" , (int )msg->type, (unsigned long )vcc); sk =sk_atm (vcc);switch (msg->type) {
@@ -150,8 +150,7 @@ as_indicate_complete:clear_bit (ATM_VF_WAITING , &vcc->flags);break ;default : -printk (KERN_ALERT "sigd_send: bad message type %d\n" , - (int ) msg->type); +pr_alert ("bad message type %d\n" , (int )msg->type);return -EINVAL ; } sk->sk_state_change (sk);
@@ -169,7 +168,7 @@ void sigd_enq2(struct atm_vcc *vcc,enum atmsvc_msg_type type,struct atmsvc_msg *msg;static unsigned session =0 ; -pr_debug ("sigd_enq %d (0x%p)\n" ,(int ) type,vcc); +pr_debug ("%d (0x%p)\n" , (int )type, vcc);while (!(skb =alloc_skb (sizeof (struct atmsvc_msg ),GFP_KERNEL )))schedule (); msg = (struct atmsvc_msg *)skb_put (skb,sizeof (struct atmsvc_msg ));
@@ -219,10 +218,10 @@ static void sigd_close(struct atm_vcc *vcc)struct sock *s;int i; -pr_debug ("sigd_close\n" ); +pr_debug ("\n" ); sigd =NULL ;if (skb_peek (&sk_atm (vcc)->sk_receive_queue)) -printk (KERN_ERR "sigd_close: closing with requests pending\n" ); +pr_err ("closing with requests pending\n" );skb_queue_purge (&sk_atm (vcc)->sk_receive_queue);read_lock (&vcc_sklist_lock);
@@ -256,7 +255,7 @@ static struct atm_dev sigd_dev = {int sigd_attach (struct atm_vcc *vcc) {if (sigd)return -EADDRINUSE ; -pr_debug ("sigd_attach\n" ); +pr_debug ("\n" ); sigd = vcc; vcc->dev = &sigd_dev;vcc_insert_socket (sk_atm (vcc));
net/atm/svc.c +7 -6
@@ -2,6 +2,7 @@/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ +#define pr_fmt (fmt) KBUILD_MODNAME ":%s: " fmt, __func__#include <linux/string.h> #include <linux/net.h> /* struct socket, struct proto_ops */
@@ -46,7 +47,7 @@ static void svc_disconnect(struct atm_vcc *vcc)struct sk_buff *skb;struct sock *sk =sk_atm (vcc); -pr_debug ("svc_disconnect %p\n" ,vcc); +pr_debug ("%p\n" ,vcc);if (test_bit (ATM_VF_REGIS ,&vcc->flags)) {prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE );sigd_enq (vcc,as_close,NULL ,NULL ,NULL );
@@ -76,7 +77,7 @@ static int svc_release(struct socket *sock)if (sk) { vcc =ATM_SD (sock); -pr_debug ("svc_release %p\n" , vcc); +pr_debug ("%p\n" , vcc);clear_bit (ATM_VF_READY , &vcc->flags);/* VCC pointer is used as a reference, so we must not free it (thereby subjecting it to re-use) before all pending connections
@@ -153,7 +154,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,struct atm_vcc *vcc =ATM_SD (sock);int error; -pr_debug ("svc_connect %p\n" ,vcc); +pr_debug ("%p\n" ,vcc);lock_sock (sk);if (sockaddr_len !=sizeof (struct sockaddr_atmsvc )) { error = -EINVAL ;
@@ -286,7 +287,7 @@ static int svc_listen(struct socket *sock,int backlog)struct atm_vcc *vcc =ATM_SD (sock);int error; -pr_debug ("svc_listen %p\n" ,vcc); +pr_debug ("%p\n" , vcc);lock_sock (sk);/* let server handle listen on unbound sockets */ if (test_bit (ATM_VF_SESSION ,&vcc->flags)) {
@@ -336,7 +337,7 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) new_vcc =ATM_SD (newsock); -pr_debug ("svc_accept %p -> %p\n" ,old_vcc,new_vcc); +pr_debug ("%p -> %p\n" , old_vcc, new_vcc);while (1 ) {DEFINE_WAIT (wait);
@@ -540,7 +541,7 @@ static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr, error = -EINPROGRESS ; goto out; } -pr_debug ("svc_addparty added wait queue\n" ); +pr_debug ("added wait queue\n" );while (test_bit (ATM_VF_WAITING , &vcc->flags) && sigd) {schedule ();prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE );
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 2/21 net/atm/addr.c: Convert include <asm to include <linux
In reply to Joe Perches--- net/atm/addr.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/atm/addr.c +1 -1
@@ -4,7 +4,7 @@#include <linux/atm.h> #include <linux/atmdev.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include "signaling.h" #include "addr.h"
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 3/21 net/atm/atm_misc.c: checkpatch cleanups
In reply to Joe PerchesMoved EXPORT_SYMBOL to follow definition
Add space after commas
--- net/atm/atm_misc.c | 40 ++++++++++++++++------------------------ 1 files changed, 16 insertions(+), 24 deletions(-)
net/atm/atm_misc.c +16 -24
@@ -2,37 +2,35 @@/* Written 1995-2000 by Werner Almesberger, EPFL ICA */ -#include <linux/module.h> #include <linux/atm.h> #include <linux/atmdev.h> #include <linux/skbuff.h> #include <linux/sonet.h> #include <linux/bitops.h> +#include <linux/errno.h> #include <asm/atomic.h> -#include <asm/errno.h> - -int atm_charge (struct atm_vcc *vcc,int truesize) +int atm_charge (struct atm_vcc *vcc,int truesize) { -atm_force_charge (vcc,truesize); +atm_force_charge (vcc, truesize);if (atomic_read (&sk_atm (vcc)->sk_rmem_alloc) <=sk_atm (vcc)->sk_rcvbuf)return 1 ; -atm_return (vcc,truesize); +atm_return (vcc, truesize);atomic_inc (&vcc->stats->rx_drop);return 0 ; } +EXPORT_SYMBOL (atm_charge); - -struct sk_buff *atm_alloc_charge (struct atm_vcc *vcc,int pdu_size, -gfp_t gfp_flags) +struct sk_buff *atm_alloc_charge (struct atm_vcc *vcc,int pdu_size, +gfp_t gfp_flags) {struct sock *sk =sk_atm (vcc);int guess =atm_guess_pdu2truesize (pdu_size); -atm_force_charge (vcc,guess); +atm_force_charge (vcc, guess);if (atomic_read (&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) { -struct sk_buff *skb =alloc_skb (pdu_size,gfp_flags); +struct sk_buff *skb =alloc_skb (pdu_size, gfp_flags);if (skb) { atomic_add(skb->truesize-guess,
@@ -40,10 +38,11 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,return skb; } } -atm_return (vcc,guess); +atm_return (vcc, guess);atomic_inc (&vcc->stats->rx_drop);return NULL ; } +EXPORT_SYMBOL (atm_alloc_charge);/*
@@ -73,7 +72,6 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,* else * */ -int atm_pcr_goal (const struct atm_trafprm *tp) {if (tp->pcr && tp->pcr !=ATM_MAX_PCR )
@@ -84,26 +82,20 @@ int atm_pcr_goal(const struct atm_trafprm *tp)return -tp->max_pcr;return 0 ; } +EXPORT_SYMBOL (atm_pcr_goal); - -void sonet_copy_stats (struct k_sonet_stats *from,struct sonet_stats *to) +void sonet_copy_stats (struct k_sonet_stats *from,struct sonet_stats *to) {#define __HANDLE_ITEM (i) to->i = atomic_read(&from->i) __SONET_ITEMS#undef __HANDLE_ITEM } +EXPORT_SYMBOL (sonet_copy_stats); - -void sonet_subtract_stats (struct k_sonet_stats *from,struct sonet_stats *to) +void sonet_subtract_stats (struct k_sonet_stats *from,struct sonet_stats *to) { -#define __HANDLE_ITEM (i) atomic_sub(to->i,&from->i) +#define __HANDLE_ITEM (i) atomic_sub(to->i, &from->i) __SONET_ITEMS#undef __HANDLE_ITEM } - - -EXPORT_SYMBOL (atm_charge); -EXPORT_SYMBOL (atm_alloc_charge); -EXPORT_SYMBOL (atm_pcr_goal); -EXPORT_SYMBOL (sonet_copy_stats);EXPORT_SYMBOL (sonet_subtract_stats);
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 4/21 net/atm/atm_sysfs.c: checkpatch cleanups
In reply to Joe PerchesAdd space after for
Indent switch/case statements
80 column wrapping
--- net/atm/atm_sysfs.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-)
net/atm/atm_sysfs.c +14 -13
@@ -42,13 +42,14 @@ static ssize_t show_atmaddress(struct device *cdev,spin_lock_irqsave (&adev->lock, flags);list_for_each_entry (aaddr, &adev->local, entry) { -for (i =0 , j =0 ; i <ATM_ESA_LEN ; ++i, ++j) { +for (i =0 , j =0 ; i <ATM_ESA_LEN ; ++i, ++j) {if (j == *fmt) { pos +=sprintf (pos,"." ); ++fmt; j =0 ; } - pos +=sprintf (pos,"%02x" , aaddr->addr.sas_addr.prv[i]); + pos +=sprintf (pos,"%02x" , + aaddr->addr.sas_addr.prv[i]); } pos +=sprintf (pos,"\n" ); }
@@ -78,17 +79,17 @@ static ssize_t show_link_rate(struct device *cdev,/* show the link rate, not the data rate */ switch (adev->link_rate) { -case ATM_OC3_PCR : - link_rate =155520000 ; -break ; -case ATM_OC12_PCR : - link_rate =622080000 ; -break ; -case ATM_25_PCR : - link_rate =25600000 ; -break ; -default : - link_rate = adev->link_rate *8 *53 ; +case ATM_OC3_PCR : + link_rate =155520000 ; +break ; +case ATM_OC12_PCR : + link_rate =622080000 ; +break ; +case ATM_25_PCR : + link_rate =25600000 ; +break ; +default : + link_rate = adev->link_rate *8 *53 ; } pos +=sprintf (pos,"%d\n" , link_rate);
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 5/21 net/atm/br2684.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux... Use print_hex_dump
Spacing cleanups
Move logical continuation tests to end of previous line 80 column wrapping
Move goto branch label to column 1
Remove unnecessary single statement braces
--- net/atm/br2684.c | 72 +++++++++++++++++++++++------------------------------ 1 files changed, 31 insertions(+), 41 deletions(-)
net/atm/br2684.c +31 -41
@@ -17,7 +17,7 @@#include <linux/etherdevice.h> #include <linux/rtnetlink.h> #include <linux/ip.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <net/arp.h> #include <linux/atm.h> #include <linux/atmdev.h>
@@ -28,20 +28,14 @@#include "common.h" -#ifdef SKB_DEBUG static void skb_debug (const struct sk_buff *skb) { +#ifdef SKB_DEBUG #define NUM2PRINT 50 -char buf[NUM2PRINT *3 +1 ];/* 3 chars per byte */ -int i =0 ; -for (i =0 ; i < skb->len && i <NUM2PRINT ; i++) { -sprintf (buf + i *3 ,"%2.2x " ,0xff & skb->data[i]); - } -printk (KERN_DEBUG "br2684: skb: %s\n" , buf); -} -#else -#define skb_debug (skb) do {} while (0) +print_hex_dump (KERN_DEBUG ,"br2684: skb: " ,DUMP_OFFSET , + 16, 1, skb->data, min(NUM2PRINT, skb->len, true);#endif +}#define BR2684_ETHERTYPE_LEN 2#define BR2684_PAD_LEN 2
@@ -70,7 +64,7 @@ struct br2684_vcc {struct atm_vcc *atmvcc;struct net_device *device;/* keep old push, pop functions for chaining */ -void (*old_push) (struct atm_vcc * vcc,struct sk_buff * skb); +void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb);void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb);enum br2684_encaps encaps;struct list_head brvccs;
@@ -302,7 +296,8 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg)struct br2684_dev *brdev;read_lock (&devs_lock); brdev =BRPRIV (br2684_find_dev (&fs.ifspec)); -if (brdev ==NULL ||list_empty (&brdev->brvccs) || brdev->brvccs.next != brdev->brvccs.prev)/* >1 VCC */ +if (brdev ==NULL ||list_empty (&brdev->brvccs) || + brdev->brvccs.next != brdev->brvccs.prev)/* >1 VCC */ brvcc =NULL ;else brvcc =list_entry_brvcc (brdev->brvccs.next);
@@ -378,29 +373,25 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)__skb_trim (skb, skb->len -4 );/* accept packets that have "ipv[46]" in the snap header */ -if ((skb->len >= (sizeof (llc_oui_ipv4))) - && - (memcmp - (skb->data, llc_oui_ipv4, -sizeof (llc_oui_ipv4) -BR2684_ETHERTYPE_LEN ) ==0 )) { -if (memcmp - (skb->data +6 , ethertype_ipv6, -sizeof (ethertype_ipv6)) ==0 ) +if ((skb->len >= (sizeof (llc_oui_ipv4))) && + (memcmp (skb->data, llc_oui_ipv4, +sizeof (llc_oui_ipv4) -BR2684_ETHERTYPE_LEN ) ==0 )) { +if (memcmp (skb->data +6 , ethertype_ipv6, +sizeof (ethertype_ipv6)) ==0 ) skb->protocol =htons (ETH_P_IPV6 ); -else if (memcmp - (skb->data +6 , ethertype_ipv4, -sizeof (ethertype_ipv4)) ==0 ) +else if (memcmp (skb->data +6 , ethertype_ipv4, +sizeof (ethertype_ipv4)) ==0 ) skb->protocol =htons (ETH_P_IP );else goto error;skb_pull (skb,sizeof (llc_oui_ipv4));skb_reset_network_header (skb); skb->pkt_type =PACKET_HOST ; -/* -* Let us waste some time for checking the encapsulation. -* Note, that only 7 char is checked so frames with a valid FCS -* are also accepted (but FCS is not checked of course). -*/ +/* +* Let us waste some time for checking the encapsulation. +* Note, that only 7 char is checked so frames with a valid FCS +* are also accepted (but FCS is not checked of course). +*/ }else if ((skb->len >=sizeof (llc_oui_pid_pad)) && (memcmp (skb->data, llc_oui_pid_pad,7 ) ==0 )) {skb_pull (skb,sizeof (llc_oui_pid_pad));
@@ -495,12 +486,12 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) err = -EEXIST ; goto error; } -if (be.fcs_in !=BR2684_FCSIN_NO || be.fcs_out !=BR2684_FCSOUT_NO || - be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps != -BR2684_ENCAPS_VC - && be.encaps != -BR2684_ENCAPS_LLC ) - || be.min_size !=0 ) { +if (be.fcs_in !=BR2684_FCSIN_NO || + be.fcs_out !=BR2684_FCSOUT_NO || + be.fcs_auto || be.has_vpiid || be.send_padding || + (be.encaps !=BR2684_ENCAPS_VC && + be.encaps !=BR2684_ENCAPS_LLC ) || + be.min_size !=0 ) { err = -EINVAL ; goto error; }
@@ -541,7 +532,8 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) }__module_get (THIS_MODULE );return 0 ; - error: + +error:write_unlock_irq (&devs_lock);kfree (brvcc);return err;
@@ -587,7 +579,7 @@ static void br2684_setup_routed(struct net_device *netdev)INIT_LIST_HEAD (&brdev->brvccs); } -static int br2684_create (void __user * arg) +static int br2684_create (void __user *arg) {int err;struct net_device *netdev;
@@ -597,9 +589,8 @@ static int br2684_create(void __user * arg)pr_debug ("\n" ); -if (copy_from_user (&ni, arg,sizeof ni)) { +if (copy_from_user (&ni, arg,sizeof ni))return -EFAULT ; - }if (ni.media &BR2684_FLAG_ROUTED ) payload = p_routed;
@@ -607,9 +598,8 @@ static int br2684_create(void __user * arg) payload = p_bridged; ni.media &=0xffff ;/* strip flags */ -if (ni.media !=BR2684_MEDIA_ETHERNET || ni.mtu !=1500 ) { +if (ni.media !=BR2684_MEDIA_ETHERNET || ni.mtu !=1500 )return -EINVAL ; - } netdev = alloc_netdev(sizeof(struct br2684_dev), ni.ifname[0] ? ni.ifname : "nas%d",
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 6/21 net/atm/clip.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux... Spacing cleanups
Move labels to column 1
Move logical continuation tests to end of previous line
--- net/atm/clip.c | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-)
net/atm/clip.c +12 -14
@@ -32,10 +32,10 @@#include <linux/jhash.h> #include <net/route.h> /* for struct rtable and routing */ #include <net/icmp.h> /* icmp_send */ -#include <asm/param.h> /* for HZ */ +#include <linux/param.h> /* for HZ */ +#include <linux/uaccess.h> #include <asm/byteorder.h> /* for htons etc. */ #include <asm/system.h> /* save/restore_flags */ -#include <asm/uaccess.h> #include <asm/atomic.h> #include "common.h"
@@ -56,10 +56,10 @@ static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)pr_debug ("(%d)\n" , type);if (!atmarpd)return -EUNATCH ; - skb =alloc_skb (sizeof (struct atmarp_ctrl ),GFP_ATOMIC ); + skb =alloc_skb (sizeof (struct atmarp_ctrl ),GFP_ATOMIC );if (!skb)return -ENOMEM ; - ctrl = (struct atmarp_ctrl *)skb_put (skb,sizeof (struct atmarp_ctrl )); + ctrl = (struct atmarp_ctrl *)skb_put (skb,sizeof (struct atmarp_ctrl )); ctrl->type = type; ctrl->itf_num = itf; ctrl->ip = ip;
@@ -111,7 +111,7 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc) goto out; }pr_crit ("ATMARP: failed (entry %p, vcc 0x%p)\n" , entry, clip_vcc); - out: +out:netif_tx_unlock_bh (entry->neigh->dev); }
@@ -205,12 +205,12 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb) }ATM_SKB (skb)->vcc = vcc;skb_reset_mac_header (skb); -if (!clip_vcc->encap - || skb->len <RFC1483LLC_LEN - ||memcmp (skb->data, llc_oui,sizeof (llc_oui))) +if (!clip_vcc->encap || + skb->len <RFC1483LLC_LEN || +memcmp (skb->data, llc_oui,sizeof (llc_oui))) skb->protocol =htons (ETH_P_IP );else { - skb->protocol = ((__be16 *) skb->data)[3 ]; + skb->protocol = ((__be16 *)skb->data)[3 ];skb_pull (skb,RFC1483LLC_LEN );if (skb->protocol ==htons (ETH_P_ARP )) { skb->dev->stats.rx_packets++;
@@ -644,7 +644,6 @@ static int clip_inet_event(struct notifier_block *this, unsigned long event,return clip_device_event (this,NETDEV_CHANGE , in_dev->dev); } -static struct notifier_block clip_dev_notifier = { .notifier_call = clip_device_event, };
@@ -670,7 +669,6 @@ static void atmarpd_close(struct atm_vcc *vcc)module_put (THIS_MODULE ); } -static struct atmdev_ops atmarpd_dev_ops = { .close = atmarpd_close };
@@ -692,11 +690,11 @@ static int atm_init_atmarp(struct atm_vcc *vcc)return -EADDRINUSE ; } -mod_timer (&idle_timer, jiffies+CLIP_CHECK_INTERVAL *HZ ); +mod_timer (&idle_timer, jiffies +CLIP_CHECK_INTERVAL *HZ ); atmarpd = vcc; -set_bit (ATM_VF_META ,&vcc->flags); -set_bit (ATM_VF_READY ,&vcc->flags); +set_bit (ATM_VF_META , &vcc->flags); +set_bit (ATM_VF_READY , &vcc->flags);/* allow replies and avoid getting closed if signaling dies */ vcc->dev = &atmarpd_dev;vcc_insert_socket (sk_atm (vcc));
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 7/21 net/atm/common.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux...
Move EXPORT_SYMBOL
Spacing cleanups
Use __func__ in printks
Indent switch/case statements
Move trailing statements to new line
Hoist assigns from if tests
--- net/atm/common.c | 338 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 173 insertions(+), 165 deletions(-)
net/atm/common.c +173 -165
@@ -19,11 +19,10 @@#include <linux/bitops.h> #include <linux/init.h> #include <net/sock.h> /* struct sock */ +#include <linux/uaccess.h> +#include <linux/poll.h> -#include <asm/uaccess.h> #include <asm/atomic.h> -#include <asm/poll.h> -#include "resources.h" /* atm_find_dev */ #include "common.h" /* prototypes */
@@ -32,13 +31,15 @@#include "signaling.h" /* for WAITING and sigd_attach */ struct hlist_head vcc_hash[VCC_HTABLE_SIZE ]; +EXPORT_SYMBOL (vcc_hash); +DEFINE_RWLOCK (vcc_sklist_lock); +EXPORT_SYMBOL (vcc_sklist_lock);static void __vcc_insert_socket (struct sock *sk) {struct atm_vcc *vcc =atm_sk (sk); -struct hlist_head *head = &vcc_hash[vcc->vci & - (VCC_HTABLE_SIZE -1 )]; +struct hlist_head *head = &vcc_hash[vcc->vci & (VCC_HTABLE_SIZE -1 )]; sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE -1 );sk_add_node (sk, head); }
@@ -49,6 +50,7 @@ void vcc_insert_socket(struct sock *sk)__vcc_insert_socket (sk);write_unlock_irq (&vcc_sklist_lock); } +EXPORT_SYMBOL (vcc_insert_socket);static void vcc_remove_socket (struct sock *sk) {
@@ -57,8 +59,7 @@ static void vcc_remove_socket(struct sock *sk)write_unlock_irq (&vcc_sklist_lock); } - -static struct sk_buff *alloc_tx (struct atm_vcc *vcc,unsigned int size) +static struct sk_buff *alloc_tx (struct atm_vcc *vcc,unsigned int size) {struct sk_buff *skb;struct sock *sk =sk_atm (vcc);
@@ -70,23 +71,20 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size) }while (!(skb =alloc_skb (size,GFP_KERNEL )))schedule (); -pr_debug ("AlTx %d += %d\n" ,sk_wmem_alloc_get (sk), skb->truesize); +pr_debug ("%d += %d\n" ,sk_wmem_alloc_get (sk), skb->truesize);atomic_add (skb->truesize, &sk->sk_wmem_alloc);return skb; } - -EXPORT_SYMBOL (vcc_hash); -EXPORT_SYMBOL (vcc_sklist_lock); -EXPORT_SYMBOL (vcc_insert_socket); -static void vcc_sock_destruct (struct sock *sk) {if (atomic_read (&sk->sk_rmem_alloc)) -printk (KERN_DEBUG "vcc_sock_destruct: rmem leakage (%d bytes) detected.\n" ,atomic_read (&sk->sk_rmem_alloc)); +printk (KERN_DEBUG "%s: rmem leakage (%d bytes) detected.\n" , + __func__,atomic_read (&sk->sk_rmem_alloc));if (atomic_read (&sk->sk_wmem_alloc)) -printk (KERN_DEBUG "vcc_sock_destruct: wmem leakage (%d bytes) detected.\n" ,atomic_read (&sk->sk_wmem_alloc)); +printk (KERN_DEBUG "%s: wmem leakage (%d bytes) detected.\n" , + __func__,atomic_read (&sk->sk_wmem_alloc)); }static void vcc_def_wakeup (struct sock *sk)
@@ -142,8 +140,8 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family) vcc =atm_sk (sk); vcc->dev =NULL ; -memset (&vcc->local,0 ,sizeof (struct sockaddr_atmsvc )); -memset (&vcc->remote,0 ,sizeof (struct sockaddr_atmsvc )); +memset (&vcc->local,0 ,sizeof (struct sockaddr_atmsvc )); +memset (&vcc->remote,0 ,sizeof (struct sockaddr_atmsvc )); vcc->qos.txtp.max_sdu =1 <<16 ;/* for meta VCs */ atomic_set (&sk->sk_wmem_alloc,1 );atomic_set (&sk->sk_rmem_alloc,0 );
@@ -156,7 +154,6 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family)return 0 ; } -static void vcc_destroy_socket (struct sock *sk) {struct atm_vcc *vcc =atm_sk (sk);
@@ -171,7 +168,7 @@ static void vcc_destroy_socket(struct sock *sk) vcc->push (vcc,NULL );/* atmarpd has no push */ while ((skb =skb_dequeue (&sk->sk_receive_queue)) !=NULL ) { -atm_return (vcc,skb->truesize); +atm_return (vcc, skb->truesize);kfree_skb (skb); }
@@ -182,7 +179,6 @@ static void vcc_destroy_socket(struct sock *sk)vcc_remove_socket (sk); } -int vcc_release (struct socket *sock) {struct sock *sk = sock->sk;
@@ -197,7 +193,6 @@ int vcc_release(struct socket *sock)return 0 ; } -void vcc_release_async (struct atm_vcc *vcc,int reply) {struct sock *sk =sk_atm (vcc);
@@ -208,8 +203,6 @@ void vcc_release_async(struct atm_vcc *vcc, int reply)clear_bit (ATM_VF_WAITING , &vcc->flags); sk->sk_state_change (sk); } - -EXPORT_SYMBOL (vcc_release_async);
@@ -235,36 +228,37 @@ void atm_dev_release_vccs(struct atm_dev *dev)write_unlock_irq (&vcc_sklist_lock); } - -static int adjust_tp (struct atm_trafprm *tp,unsigned char aal) +static int adjust_tp (struct atm_trafprm *tp,unsigned char aal) {int max_sdu; -if (!tp->traffic_class)return 0 ; +if (!tp->traffic_class) +return 0 ;switch (aal) { -case ATM_AAL0 : - max_sdu =ATM_CELL_SIZE -1 ; -break ; -case ATM_AAL34 : - max_sdu =ATM_MAX_AAL34_PDU ; -break ; -default : -pr_warning ("AAL problems ... (%d)\n" , aal); -/* fall through */ -case ATM_AAL5 : - max_sdu =ATM_MAX_AAL5_PDU ; +case ATM_AAL0 : + max_sdu =ATM_CELL_SIZE -1 ; +break ; +case ATM_AAL34 : + max_sdu =ATM_MAX_AAL34_PDU ; +break ; +default : +pr_warning ("AAL problems ... (%d)\n" , aal); +/* fall through */ +case ATM_AAL5 : + max_sdu =ATM_MAX_AAL5_PDU ; } -if (!tp->max_sdu) tp->max_sdu = max_sdu; -else if (tp->max_sdu > max_sdu)return -EINVAL ; -if (!tp->max_cdv) tp->max_cdv =ATM_MAX_CDV ; +if (!tp->max_sdu) + tp->max_sdu = max_sdu; +else if (tp->max_sdu > max_sdu) +return -EINVAL ; +if (!tp->max_cdv) + tp->max_cdv =ATM_MAX_CDV ;return 0 ; } -static int check_ci (const struct atm_vcc *vcc,short vpi,int vci) { -struct hlist_head *head = &vcc_hash[vci & - (VCC_HTABLE_SIZE -1 )]; +struct hlist_head *head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1 )];struct hlist_node *node;struct sock *s;struct atm_vcc *walk;
@@ -288,7 +282,6 @@ static int check_ci(const struct atm_vcc *vcc, short vpi, int vci)return 0 ; } -static int find_ci (const struct atm_vcc *vcc,short *vpi,int *vci) {static short p;/* poor man's per-device cache */
@@ -326,14 +319,13 @@ static int find_ci(const struct atm_vcc *vcc, short *vpi, int *vci)if ((c ==ATM_NOT_RSV_VCI || *vci !=ATM_VCI_ANY ) && *vpi ==ATM_VPI_ANY ) { p++; -if (p >=1 << vcc->dev->ci_range.vpi_bits) p =0 ; +if (p >=1 << vcc->dev->ci_range.vpi_bits) + p =0 ; } - } -while (old_p != p || old_c != c); + }while (old_p != p || old_c != c);return -EADDRINUSE ; } -static int __vcc_connect (struct atm_vcc *vcc,struct atm_dev *dev,short vpi,int vci) {
@@ -361,27 +353,29 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi,__vcc_insert_socket (sk);write_unlock_irq (&vcc_sklist_lock);switch (vcc->qos.aal) { -case ATM_AAL0 : - error =atm_init_aal0 (vcc); - vcc->stats = &dev->stats.aal0; -break ; -case ATM_AAL34 : - error =atm_init_aal34 (vcc); - vcc->stats = &dev->stats.aal34; -break ; -case ATM_NO_AAL : -/* ATM_AAL5 is also used in the "0 for default" case */ - vcc->qos.aal =ATM_AAL5 ; -/* fall through */ -case ATM_AAL5 : - error =atm_init_aal5 (vcc); - vcc->stats = &dev->stats.aal5; -break ; -default : - error = -EPROTOTYPE ; +case ATM_AAL0 : + error =atm_init_aal0 (vcc); + vcc->stats = &dev->stats.aal0; +break ; +case ATM_AAL34 : + error =atm_init_aal34 (vcc); + vcc->stats = &dev->stats.aal34; +break ; +case ATM_NO_AAL : +/* ATM_AAL5 is also used in the "0 for default" case */ + vcc->qos.aal =ATM_AAL5 ; +/* fall through */ +case ATM_AAL5 : + error =atm_init_aal5 (vcc); + vcc->stats = &dev->stats.aal5; +break ; +default : + error = -EPROTOTYPE ; } -if (!error) error =adjust_tp (&vcc->qos.txtp,vcc->qos.aal); -if (!error) error =adjust_tp (&vcc->qos.rxtp,vcc->qos.aal); +if (!error) + error =adjust_tp (&vcc->qos.txtp, vcc->qos.aal); +if (!error) + error =adjust_tp (&vcc->qos.rxtp, vcc->qos.aal);if (error) goto fail;pr_debug ("VCC %d.%d, AAL %d\n" , vpi, vci, vcc->qos.aal);
@@ -397,7 +391,8 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi, vcc->qos.rxtp.max_sdu);if (dev->ops->open) { -if ((error = dev->ops->open (vcc))) + error = dev->ops->open (vcc); +if (error) goto fail; }return 0 ;
@@ -411,7 +406,6 @@ fail_module_put:return error; } -int vcc_connect (struct socket *sock,int itf,short vpi,int vci) {struct atm_dev *dev;
@@ -427,16 +421,16 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)return -EINVAL ;if (vpi !=ATM_VPI_UNSPEC && vci !=ATM_VCI_UNSPEC ) -clear_bit (ATM_VF_PARTIAL ,&vcc->flags); +clear_bit (ATM_VF_PARTIAL , &vcc->flags);else -if (test_bit (ATM_VF_PARTIAL ,&vcc->flags)) +if (test_bit (ATM_VF_PARTIAL , &vcc->flags))return -EINVAL ;pr_debug ("(TX: cl %d,bw %d-%d,sdu %d; " "RX: cl %d,bw %d-%d,sdu %d,AAL %s%d)\n" , vcc->qos.txtp.traffic_class, vcc->qos.txtp.min_pcr, vcc->qos.txtp.max_pcr, vcc->qos.txtp.max_sdu, vcc->qos.rxtp.traffic_class, vcc->qos.rxtp.min_pcr, - vcc->qos.rxtp.max_pcr,vcc->qos.rxtp.max_sdu, + vcc->qos.rxtp.max_pcr, vcc->qos.rxtp.max_sdu, vcc->qos.aal ==ATM_AAL5 ?"" : vcc->qos.aal ==ATM_AAL0 ?"" :" ??? code " , vcc->qos.aal ==ATM_AAL0 ?0 : vcc->qos.aal);
@@ -446,12 +440,14 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) vcc->qos.rxtp.traffic_class == ATM_ANYCLASS)return -EINVAL ;if (likely (itf !=ATM_ITF_ANY )) { - dev =try_then_request_module (atm_dev_lookup (itf),"atm-device-%d" , itf); + dev =try_then_request_module (atm_dev_lookup (itf), +"atm-device-%d" , itf); }else { dev =NULL ;mutex_lock (&atm_dev_mutex);if (!list_empty (&atm_devs)) { - dev = list_entry(atm_devs.next, struct atm_dev, dev_list); + dev =list_entry (atm_devs.next, + struct atm_dev, dev_list);atm_dev_hold (dev); }mutex_unlock (&atm_dev_mutex);
@@ -464,13 +460,12 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)return error; }if (vpi ==ATM_VPI_UNSPEC || vci ==ATM_VCI_UNSPEC ) -set_bit (ATM_VF_PARTIAL ,&vcc->flags); -if (test_bit (ATM_VF_READY ,&ATM_SD (sock)->flags)) +set_bit (ATM_VF_PARTIAL , &vcc->flags); +if (test_bit (ATM_VF_READY , &ATM_SD (sock)->flags)) sock->state =SS_CONNECTED ;return 0 ; } -int vcc_recvmsg (struct kiocb *iocb,struct socket *sock,struct msghdr *msg,size_t size,int flags) {
@@ -484,8 +479,8 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,if (flags & ~MSG_DONTWAIT )/* only handle MSG_DONTWAIT */ return -EOPNOTSUPP ; vcc =ATM_SD (sock); -if (test_bit (ATM_VF_RELEASED ,&vcc->flags) || -test_bit (ATM_VF_CLOSE ,&vcc->flags) || +if (test_bit (ATM_VF_RELEASED , &vcc->flags) || +test_bit (ATM_VF_CLOSE , &vcc->flags) || !test_bit (ATM_VF_READY , &vcc->flags))return 0 ;
@@ -509,7 +504,6 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,return copied; } -int vcc_sendmsg (struct kiocb *iocb,struct socket *sock,struct msghdr *m,size_t total_len) {
@@ -517,7 +511,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,DEFINE_WAIT (wait);struct atm_vcc *vcc;struct sk_buff *skb; -int eff,error; +int eff, error;const void __user *buff;int size;
@@ -556,7 +550,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, eff = (size+3 ) & ~3 ;/* align to word boundary */ prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); error =0 ; -while (!(skb =alloc_tx (vcc,eff))) { +while (!(skb =alloc_tx (vcc, eff))) {if (m->msg_flags &MSG_DONTWAIT ) { error = -EAGAIN ;break ;
@@ -566,9 +560,9 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, error = -ERESTARTSYS ;break ; } -if (test_bit (ATM_VF_RELEASED ,&vcc->flags) || -test_bit (ATM_VF_CLOSE ,&vcc->flags) || - !test_bit (ATM_VF_READY ,&vcc->flags)) { +if (test_bit (ATM_VF_RELEASED , &vcc->flags) || +test_bit (ATM_VF_CLOSE , &vcc->flags) || + !test_bit (ATM_VF_READY , &vcc->flags)) { error = -EPIPE ;send_sig (SIGPIPE , current,0 );break ;
@@ -580,20 +574,20 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, goto out; skb->dev =NULL ;/* for paths shared with net_device interfaces */ ATM_SKB (skb)->atm_options = vcc->atm_options; -if (copy_from_user (skb_put (skb,size),buff,size)) { +if (copy_from_user (skb_put (skb, size), buff, size)) {kfree_skb (skb); error = -EFAULT ; goto out; } -if (eff != size)memset (skb->data+size,0 ,eff-size); - error = vcc->dev->ops->send (vcc,skb); +if (eff != size) +memset (skb->data + size,0 , eff-size); + error = vcc->dev->ops->send (vcc, skb); error = error ? error : size; out:release_sock (sk);return error; } -unsigned int vcc_poll (struct file *file,struct socket *sock,poll_table *wait) {struct sock *sk = sock->sk;
@@ -629,8 +623,7 @@ unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait)return mask; } - -static int atm_change_qos (struct atm_vcc *vcc,struct atm_qos *qos) +static int atm_change_qos (struct atm_vcc *vcc,struct atm_qos *qos) {int error;
@@ -642,25 +635,31 @@ static int atm_change_qos(struct atm_vcc *vcc,struct atm_qos *qos) qos->rxtp.traffic_class != vcc->qos.rxtp.traffic_class || qos->txtp.traffic_class != vcc->qos.txtp.traffic_class) return -EINVAL; - error =adjust_tp (&qos->txtp,qos->aal); -if (!error) error =adjust_tp (&qos->rxtp,qos->aal); -if (error)return error; -if (!vcc->dev->ops->change_qos)return -EOPNOTSUPP ; + error =adjust_tp (&qos->txtp, qos->aal); +if (!error) + error =adjust_tp (&qos->rxtp, qos->aal); +if (error) +return error; +if (!vcc->dev->ops->change_qos) +return -EOPNOTSUPP ;if (sk_atm (vcc)->sk_family ==AF_ATMPVC ) -return vcc->dev->ops->change_qos (vcc,qos,ATM_MF_SET ); -return svc_change_qos (vcc,qos); +return vcc->dev->ops->change_qos (vcc, qos,ATM_MF_SET ); +return svc_change_qos (vcc, qos); } -static int check_tp (const struct atm_trafprm *tp) {/* @@@ Should be merged with adjust_tp */ -if (!tp->traffic_class || tp->traffic_class ==ATM_ANYCLASS )return 0 ; +if (!tp->traffic_class || tp->traffic_class ==ATM_ANYCLASS ) +return 0 ;if (tp->traffic_class !=ATM_UBR && !tp->min_pcr && !tp->pcr && - !tp->max_pcr)return -EINVAL ; -if (tp->min_pcr ==ATM_MAX_PCR )return -EINVAL ; + !tp->max_pcr) +return -EINVAL ; +if (tp->min_pcr ==ATM_MAX_PCR ) +return -EINVAL ;if (tp->min_pcr && tp->max_pcr && tp->max_pcr !=ATM_MAX_PCR && - tp->min_pcr > tp->max_pcr)return -EINVAL ; + tp->min_pcr > tp->max_pcr) +return -EINVAL ;/* * We allow pcr to be outside [min_pcr,max_pcr], because later * adjustment may still push it in the valid range.
@@ -668,7 +667,6 @@ static int check_tp(const struct atm_trafprm *tp)return 0 ; } -static int check_qos (const struct atm_qos *qos) {int error;
@@ -678,9 +676,11 @@ static int check_qos(const struct atm_qos *qos)if (qos->txtp.traffic_class != qos->rxtp.traffic_class && qos->txtp.traffic_class && qos->rxtp.traffic_class && qos->txtp.traffic_class !=ATM_ANYCLASS && - qos->rxtp.traffic_class !=ATM_ANYCLASS )return -EINVAL ; + qos->rxtp.traffic_class !=ATM_ANYCLASS ) +return -EINVAL ; error =check_tp (&qos->txtp); -if (error)return error; +if (error) +return error;return check_tp (&qos->rxtp); }
@@ -696,37 +696,41 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, vcc =ATM_SD (sock);switch (optname) { -case SO_ATMQOS : - { -struct atm_qos qos; - -if (copy_from_user (&qos,optval,sizeof (qos))) -return -EFAULT ; - error =check_qos (&qos); -if (error)return error; -if (sock->state ==SS_CONNECTED ) -return atm_change_qos (vcc,&qos); -if (sock->state !=SS_UNCONNECTED ) -return -EBADFD ; - vcc->qos = qos; -set_bit (ATM_VF_HASQOS ,&vcc->flags); -return 0 ; - } -case SO_SETCLP : -if (get_user (value,(unsigned long __user *)optval)) -return -EFAULT ; -if (value) vcc->atm_options |=ATM_ATMOPT_CLP ; -else vcc->atm_options &= ~ATM_ATMOPT_CLP ; -return 0 ; -default : -if (level ==SOL_SOCKET )return -EINVAL ; -break ; +case SO_ATMQOS : + { +struct atm_qos qos; + +if (copy_from_user (&qos, optval,sizeof (qos))) +return -EFAULT ; + error =check_qos (&qos); +if (error) +return error; +if (sock->state ==SS_CONNECTED ) +return atm_change_qos (vcc, &qos); +if (sock->state !=SS_UNCONNECTED ) +return -EBADFD ; + vcc->qos = qos; +set_bit (ATM_VF_HASQOS , &vcc->flags); +return 0 ; } -if (!vcc->dev || !vcc->dev->ops->setsockopt)return -EINVAL ; -return vcc->dev->ops->setsockopt (vcc,level,optname,optval,optlen); +case SO_SETCLP : +if (get_user (value, (unsigned long __user *)optval)) +return -EFAULT ; +if (value) + vcc->atm_options |=ATM_ATMOPT_CLP ; +else + vcc->atm_options &= ~ATM_ATMOPT_CLP ; +return 0 ; +default : +if (level ==SOL_SOCKET ) +return -EINVAL ; +break ; + } +if (!vcc->dev || !vcc->dev->ops->setsockopt) +return -EINVAL ; +return vcc->dev->ops->setsockopt (vcc, level, optname, optval, optlen); } -int vcc_getsockopt (struct socket *sock,int level,int optname,char __user *optval,int __user *optlen) {
@@ -740,33 +744,33 @@ int vcc_getsockopt(struct socket *sock, int level, int optname, vcc =ATM_SD (sock);switch (optname) { -case SO_ATMQOS : -if (!test_bit (ATM_VF_HASQOS ,&vcc->flags)) -return -EINVAL ; -return copy_to_user (optval,&vcc->qos,sizeof (vcc->qos)) ? - -EFAULT :0 ; -case SO_SETCLP : -return put_user (vcc->atm_options &ATM_ATMOPT_CLP ?1 : -0 ,(unsigned long __user *)optval) ? -EFAULT :0 ; -case SO_ATMPVC : - { -struct sockaddr_atmpvc pvc; - -if (!vcc->dev || - !test_bit (ATM_VF_ADDR ,&vcc->flags)) -return -ENOTCONN ; - pvc.sap_family =AF_ATMPVC ; - pvc.sap_addr.itf = vcc->dev->number; - pvc.sap_addr.vpi = vcc->vpi; - pvc.sap_addr.vci = vcc->vci; -return copy_to_user (optval,&pvc,sizeof (pvc)) ? - -EFAULT :0 ; - } -default : -if (level ==SOL_SOCKET )return -EINVAL ; +case SO_ATMQOS : +if (!test_bit (ATM_VF_HASQOS , &vcc->flags)) +return -EINVAL ; +return copy_to_user (optval, &vcc->qos,sizeof (vcc->qos)) + ? -EFAULT :0 ; +case SO_SETCLP : +return put_user (vcc->atm_options &ATM_ATMOPT_CLP ?1 :0 , + (unsigned long __user *)optval) ? -EFAULT :0 ; +case SO_ATMPVC : + { +struct sockaddr_atmpvc pvc; + +if (!vcc->dev || !test_bit (ATM_VF_ADDR , &vcc->flags)) +return -ENOTCONN ; + pvc.sap_family =AF_ATMPVC ; + pvc.sap_addr.itf = vcc->dev->number; + pvc.sap_addr.vpi = vcc->vpi; + pvc.sap_addr.vci = vcc->vci; +return copy_to_user (optval, &pvc,sizeof (pvc)) ? -EFAULT :0 ; + } +default : +if (level ==SOL_SOCKET ) +return -EINVAL ;break ; } -if (!vcc->dev || !vcc->dev->ops->getsockopt)return -EINVAL ; +if (!vcc->dev || !vcc->dev->ops->getsockopt) +return -EINVAL ;return vcc->dev->ops->getsockopt (vcc, level, optname, optval, len); }
@@ -774,22 +778,26 @@ static int __init atm_init(void) {int error; -if ((error =proto_register (&vcc_proto,0 )) <0 ) + error =proto_register (&vcc_proto,0 ); +if (error <0 ) goto out; - -if ((error =atmpvc_init ()) <0 ) { + error =atmpvc_init (); +if (error <0 ) {pr_err ("atmpvc_init() failed with %d\n" , error); goto out_unregister_vcc_proto; } -if ((error =atmsvc_init ()) <0 ) { + error =atmsvc_init (); +if (error <0 ) {pr_err ("atmsvc_init() failed with %d\n" , error); goto out_atmpvc_exit; } -if ((error =atm_proc_init ()) <0 ) { + error =atm_proc_init (); +if (error <0 ) {pr_err ("atm_proc_init() failed with %d\n" , error); goto out_atmsvc_exit; } -if ((error =atm_sysfs_init ()) <0 ) { + error =atm_sysfs_init (); +if (error <0 ) {pr_err ("atm_sysfs_init() failed with %d\n" , error); goto out_atmproc_exit; }
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 8/21 net/atm/ioctl.c: checkpatch cleanups
In reply to Joe PerchesSpacing cleanups
Moved EXPORT_SYMBOL
Mostly 80 column wrapped.
switch/case cleanups
--- net/atm/ioctl.c | 195 +++++++++++++++++++++++++++---------------------------- 1 files changed, 97 insertions(+), 98 deletions(-)
net/atm/ioctl.c +97 -98
@@ -37,6 +37,7 @@ void register_atm_ioctl(struct atm_ioctl *ioctl)list_add_tail (&ioctl->list, &ioctl_list);mutex_unlock (&ioctl_mutex); } +EXPORT_SYMBOL (register_atm_ioctl);void deregister_atm_ioctl (struct atm_ioctl *ioctl) {
@@ -44,129 +45,128 @@ void deregister_atm_ioctl(struct atm_ioctl *ioctl)list_del (&ioctl->list);mutex_unlock (&ioctl_mutex); } - -EXPORT_SYMBOL (register_atm_ioctl);EXPORT_SYMBOL (deregister_atm_ioctl); -static int do_vcc_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg,int compat) +static int do_vcc_ioctl (struct socket *sock,unsigned int cmd, +unsigned long arg,int compat) {struct sock *sk = sock->sk;struct atm_vcc *vcc;int error; -struct list_head * pos; +struct list_head *pos;void __user *argp = (void __user *)arg; vcc =ATM_SD (sock);switch (cmd) { -case SIOCOUTQ : -if (sock->state !=SS_CONNECTED || - !test_bit (ATM_VF_READY , &vcc->flags)) { - error = -EINVAL ; - goto done; - } - error =put_user (sk->sk_sndbuf -sk_wmem_alloc_get (sk), - (int __user *) argp) ? -EFAULT :0 ; +case SIOCOUTQ : +if (sock->state !=SS_CONNECTED || + !test_bit (ATM_VF_READY , &vcc->flags)) { + error = -EINVAL ; + goto done; + } + error =put_user (sk->sk_sndbuf -sk_wmem_alloc_get (sk), + (int __user *)argp) ? -EFAULT :0 ; + goto done; +case SIOCINQ : + { +struct sk_buff *skb; + +if (sock->state !=SS_CONNECTED ) { + error = -EINVAL ; goto done; -case SIOCINQ : - { -struct sk_buff *skb; - -if (sock->state !=SS_CONNECTED ) { - error = -EINVAL ; - goto done; - } - skb =skb_peek (&sk->sk_receive_queue); - error =put_user (skb ? skb->len :0 , - (int __user *)argp) ? -EFAULT :0 ; - goto done; - } -case SIOCGSTAMP :/* borrowed from IP */ + } + skb =skb_peek (&sk->sk_receive_queue); + error =put_user (skb ? skb->len :0 , + (int __user *)argp) ? -EFAULT :0 ; + goto done; + } +case SIOCGSTAMP :/* borrowed from IP */ #ifdef CONFIG_COMPAT -if (compat) - error =compat_sock_get_timestamp (sk, argp); - else +if (compat) + error =compat_sock_get_timestamp (sk, argp); + else#endif - error =sock_get_timestamp (sk, argp); - goto done; -case SIOCGSTAMPNS :/* borrowed from IP */ + error =sock_get_timestamp (sk, argp); + goto done; +case SIOCGSTAMPNS :/* borrowed from IP */ #ifdef CONFIG_COMPAT -if (compat) - error =compat_sock_get_timestampns (sk, argp); - else +if (compat) + error =compat_sock_get_timestampns (sk, argp); + else#endif - error =sock_get_timestampns (sk, argp); + error =sock_get_timestampns (sk, argp); + goto done; +case ATM_SETSC : +if (net_ratelimit ()) +pr_warning ("ATM_SETSC is obsolete; used by %s:%d\n" , + current->comm,task_pid_nr (current)); + error =0 ; + goto done; +case ATMSIGD_CTRL : +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; goto done; -case ATM_SETSC : -if (net_ratelimit ()) -pr_warning ("ATM_SETSC is obsolete; used by %s:%d\n" , - current->comm,task_pid_nr (current)); - error =0 ; + } +/* +* The user/kernel protocol for exchanging signalling +* info uses kernel pointers as opaque references, +* so the holder of the file descriptor can scribble +* on the kernel... so we should make sure that we +* have the same privileges that /proc/kcore needs +*/ +if (!capable (CAP_SYS_RAWIO )) { + error = -EPERM ; goto done; -case ATMSIGD_CTRL : -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } -/* -* The user/kernel protocol for exchanging signalling -* info uses kernel pointers as opaque references, -* so the holder of the file descriptor can scribble -* on the kernel... so we should make sure that we -* have the same privileges that /proc/kcore needs -*/ -if (!capable (CAP_SYS_RAWIO )) { - error = -EPERM ; - goto done; - } + }#ifdef CONFIG_COMPAT -/* WTF? I don't even want to _think_ about making this -work for 32-bit userspace. TBH I don't really want -to think about it at all. dwmw2. */ -if (compat) { -if (net_ratelimit ()) -pr_warning ("32-bit task cannot be atmsigd\n" ); - error = -EINVAL ; - goto done; - } +/* WTF? I don't even want to _think_ about making this +work for 32-bit userspace. TBH I don't really want +to think about it at all. dwmw2. */ +if (compat) { +if (net_ratelimit ()) +pr_warning ("32-bit task cannot be atmsigd\n" ); + error = -EINVAL ; + goto done; + }#endif - error =sigd_attach (vcc); -if (!error) - sock->state =SS_CONNECTED ; + error =sigd_attach (vcc); +if (!error) + sock->state =SS_CONNECTED ; + goto done; +case ATM_SETBACKEND : +case ATM_NEWBACKENDIF : + { +atm_backend_t backend; + error =get_user (backend, (atm_backend_t __user *)argp); +if (error) goto done; -case ATM_SETBACKEND : -case ATM_NEWBACKENDIF : - { -atm_backend_t backend; - error =get_user (backend, (atm_backend_t __user *) argp); -if (error) - goto done; -switch (backend) { -case ATM_BACKEND_PPP : -request_module ("pppoatm" ); -break ; -case ATM_BACKEND_BR2684 : -request_module ("br2684" ); -break ; - } - } -break ; -case ATMMPC_CTRL : -case ATMMPC_DATA : -request_module ("mpoa" ); -break ; -case ATMARPD_CTRL : -request_module ("clip" ); +switch (backend) { +case ATM_BACKEND_PPP : +request_module ("pppoatm" );break ; -case ATMLEC_CTRL : -request_module ("lec" ); +case ATM_BACKEND_BR2684 : +request_module ("br2684" );break ; + } +break ; + } +case ATMMPC_CTRL : +case ATMMPC_DATA : +request_module ("mpoa" ); +break ; +case ATMARPD_CTRL : +request_module ("clip" ); +break ; +case ATMLEC_CTRL : +request_module ("lec" ); +break ; } error = -ENOIOCTLCMD ;mutex_lock (&ioctl_mutex);list_for_each (pos, &ioctl_list) { - struct atm_ioctl * ic = list_entry(pos, struct atm_ioctl, list); + struct atm_ioctl *ic = list_entry(pos, struct atm_ioctl, list);if (try_module_get (ic->owner)) { error = ic->ioctl (sock, cmd, arg);module_put (ic->owner);
@@ -185,7 +185,6 @@ done:return error; } -int vcc_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {return do_vcc_ioctl (sock, cmd, arg,0 );
@@ -288,8 +287,8 @@ static int do_atmif_sioc(struct socket *sock, unsigned int cmd, sioc =compat_alloc_user_space (sizeof (*sioc)); sioc32 =compat_ptr (arg); -if (copy_in_user (&sioc->number, &sioc32->number,2 *sizeof (int )) - ||get_user (data, &sioc32->arg)) +if (copy_in_user (&sioc->number, &sioc32->number,2 *sizeof (int )) || +get_user (data, &sioc32->arg))return -EFAULT ; datap =compat_ptr (data);if (put_user (datap, &sioc->arg))
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 9/21 net/atm/lec.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux...
Mostly 80 column wrapped.
Spacing cleanups
Convert printks to pr_<level>
Use print_hex_dump
Move embedded assigns out of tests
Move trailing statements to new lines
Remove unnecessary braces around single line statements switch/case cleanups
Removed paren around returns
Use %pM
Moved leading continuation logical tests to end of previous line
--- net/atm/lec.c | 284 +++++++++++++++++++++++++++------------------------------ 1 files changed, 136 insertions(+), 148 deletions(-)
net/atm/lec.c +136 -148
@@ -18,7 +18,7 @@#include <linux/skbuff.h> #include <linux/ip.h> #include <asm/byteorder.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <net/arp.h> #include <net/dst.h> #include <linux/proc_fs.h>
@@ -87,17 +87,19 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,int is_rdesc, struct lec_arp_table **ret_entry);static void lec_arp_update (struct lec_priv *priv,const unsigned char *mac_addr, -const unsigned char *atm_addr,unsigned long remoteflag, +const unsigned char *atm_addr, +unsigned long remoteflag,unsigned int targetless_le_arp);static void lec_flush_complete (struct lec_priv *priv,unsigned long tran_id);static int lec_mcast_make (struct lec_priv *priv,struct atm_vcc *vcc);static void lec_set_flush_tran_id (struct lec_priv *priv,const unsigned char *atm_addr,unsigned long tran_id); -static void lec_vcc_added (struct lec_priv *priv,const struct atmlec_ioc *ioc_data, +static void lec_vcc_added (struct lec_priv *priv, +const struct atmlec_ioc *ioc_data,struct atm_vcc *vcc, -void (*old_push) (struct atm_vcc *vcc, -struct sk_buff *skb)); +void (*old_push)(struct atm_vcc *vcc, +struct sk_buff *skb));static void lec_vcc_close (struct lec_priv *priv,struct atm_vcc *vcc);/* must be done under lec_arp_lock */
@@ -112,7 +114,6 @@ static inline void lec_arp_put(struct lec_arp_table *entry)kfree (entry); } -static struct lane2_ops lane2_ops = { lane2_resolve,/* resolve, spec 3.1.3 */ lane2_associate_req,/* associate_req, spec 3.1.4 */
@@ -150,7 +151,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) mesg = (struct atmlec_msg *)skb2->data; mesg->type = l_topology_change; buff +=4 ; - mesg->content.normal.flag = *buff &0x01 ;/* 0x01 is topology change */ + mesg->content.normal.flag = *buff &0x01 ; +/* 0x01 is topology change */ priv =netdev_priv (dev);atm_force_charge (priv->lecd, skb2->truesize);
@@ -263,14 +265,10 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,unsigned char rdesc[ETH_ALEN ];/* Token Ring route descriptor */ #endif int is_rdesc; -#if DUMP_PACKETS >0 -char buf[300 ]; -int i =0 ; -#endif /* DUMP_PACKETS >0 */ pr_debug ("called\n" );if (!priv->lecd) { -printk ("%s:No lecd attached\n" , dev->name); +pr_info ("%s:No lecd attached\n" , dev->name); dev->stats.tx_errors++;netif_stop_queue (dev);kfree_skb (skb);
@@ -315,23 +313,17 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, }#endif -#if DUMP_PACKETS >0 -printk ("%s: send datalen:%ld lecid:%4.4x\n" , dev->name, - skb->len, priv->lecid);#if DUMP_PACKETS >=2 -for (i =0 ; i < skb->len && i <99 ; i++) { -sprintf (buf + i *3 ,"%2.2x " ,0xff & skb->data[i]); - } +#define MAX_DUMP_SKB 99#elif DUMP_PACKETS >=1 -for (i =0 ; i < skb->len && i <30 ; i++) { -sprintf (buf + i *3 ,"%2.2x " ,0xff & skb->data[i]); - } +#define MAX_DUMP_SKB 30 +#endif +#if DUMP_PACKETS >=1 +printk (KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n" , + dev->name, skb->len, priv->lecid); +print_hex_dump (KERN_DEBUG ,"" ,DUMP_OFFSET ,16 ,1 , + skb->data,min (skb->len,MAX_DUMP_SKB ), true);#endif /* DUMP_PACKETS >= 1 */ -if (i == skb->len) -printk ("%s\n" , buf); -else -printk ("%s...\n" , buf); -#endif /* DUMP_PACKETS > 0 */ /* Minimum ethernet-frame size */ #ifdef CONFIG_TR
@@ -385,7 +377,8 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, goto out; }#if DUMP_PACKETS >0 -printk ("%s:sending to vpi:%d vci:%d\n" , dev->name, vcc->vpi, vcc->vci); +printk (KERN_DEBUG "%s:sending to vpi:%d vci:%d\n" , + dev->name, vcc->vpi, vcc->vci);#endif /* DUMP_PACKETS > 0 */ while (entry && (skb2 =skb_dequeue (&entry->tx_wait))) {
@@ -442,14 +435,12 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)pr_debug ("%s: msg from zeppelin:%d\n" , dev->name, mesg->type);switch (mesg->type) {case l_set_mac_addr: -for (i =0 ; i <6 ; i++) { +for (i =0 ; i <6 ; i++) dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; - }break ;case l_del_mac_addr: -for (i =0 ; i <6 ; i++) { +for (i =0 ; i <6 ; i++) dev->dev_addr[i] =0 ; - }break ;case l_addr_delete: lec_addr_delete(priv, mesg->content.normal.atm_addr,
@@ -497,13 +488,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) priv->flush_timeout = (mesg->content.config.flush_timeout *HZ ); priv->path_switching_delay = (mesg->content.config.path_switching_delay *HZ ); - priv->lane_version = mesg->content.config.lane_version;/* LANE2 */ + priv->lane_version = mesg->content.config.lane_version; +/* LANE2 */ priv->lane2_ops =NULL ;if (priv->lane_version >1 ) priv->lane2_ops = &lane2_ops;if (dev_set_mtu (dev, mesg->content.config.mtu)) -printk ("%s: change_mtu to %d failed\n" , dev->name, - mesg->content.config.mtu); +pr_info ("%s: change_mtu to %d failed\n" , + dev->name, mesg->content.config.mtu); priv->is_proxy = mesg->content.config.is_proxy;break ;case l_flush_tran_id:
@@ -524,16 +516,15 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)break ;if (br_fdb_test_addr_hook (dev, - mesg->content.proxy.mac_addr)) { + mesg->content.proxy.mac_addr)) {/* hit from bridge table, send LE_ARP_RESPONSE */ struct sk_buff *skb2;struct sock *sk;pr_debug ("%s: entry found, responding to zeppelin\n" , dev->name); - skb2 = -alloc_skb (sizeof (struct atmlec_msg ), -GFP_ATOMIC ); + skb2 =alloc_skb (sizeof (struct atmlec_msg ), +GFP_ATOMIC );if (skb2 ==NULL )break ; skb2->len =sizeof (struct atmlec_msg );
@@ -548,7 +539,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ break ;default : -printk ("%s: Unknown message type %d\n" , dev->name, mesg->type); +pr_info ("%s: Unknown message type %d\n" , dev->name, mesg->type);dev_kfree_skb (skb);return -EINVAL ; }
@@ -569,14 +560,13 @@ static void lec_atm_close(struct atm_vcc *vcc)lec_arp_destroy (priv);if (skb_peek (&sk_atm (vcc)->sk_receive_queue)) -printk ("%s lec_atm_close: closing with messages pending\n" , - dev->name); +pr_info ("%s closing with messages pending\n" , dev->name);while ((skb =skb_dequeue (&sk_atm (vcc)->sk_receive_queue)) !=NULL ) {atm_return (vcc, skb->truesize);dev_kfree_skb (skb); } -printk ("%s: Shut down!\n" , dev->name); +pr_info ("%s: Shut down!\n" , dev->name);module_put (THIS_MODULE ); }
@@ -605,9 +595,8 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,struct sk_buff *skb;struct atmlec_msg *mesg; -if (!priv || !priv->lecd) { +if (!priv || !priv->lecd)return -1 ; - } skb =alloc_skb (sizeof (struct atmlec_msg ),GFP_ATOMIC );if (!skb)return -1 ;
@@ -688,7 +677,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)struct net_device *dev = (struct net_device *)vcc->proto_data;struct lec_priv *priv =netdev_priv (dev); -#if DUMP_PACKETS >0 +#if DUMP_PACKETS >0 printk (KERN_DEBUG "%s: vcc vpi:%d vci:%d\n" , dev->name, vcc->vpi, vcc->vci);#endif
@@ -767,9 +756,8 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)dev_kfree_skb (skb);return ; } -if (!hlist_empty (&priv->lec_arp_empty_ones)) { +if (!hlist_empty (&priv->lec_arp_empty_ones))lec_arp_check_empties (priv, vcc, skb); - }skb_pull (skb,2 );/* skip lec_id */ #ifdef CONFIG_TR if (priv->is_trdev)
@@ -816,7 +804,8 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)if (ioc_data.dev_num <0 || ioc_data.dev_num >=MAX_LEC_ITF || !dev_lec[ioc_data.dev_num])return -EINVAL ; -if (!(vpriv =kmalloc (sizeof (struct lec_vcc_priv ),GFP_KERNEL ))) + vpriv =kmalloc (sizeof (struct lec_vcc_priv ),GFP_KERNEL ); +if (!vpriv)return -ENOMEM ; vpriv->xoff =0 ; vpriv->old_pop = vcc->pop;
@@ -907,9 +896,8 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) priv->flush_timeout = (4 *HZ ); priv->path_switching_delay = (6 *HZ ); -if (dev_lec[i]->flags &IFF_UP ) { +if (dev_lec[i]->flags &IFF_UP )netif_start_queue (dev_lec[i]); - }__module_get (THIS_MODULE );return i; }
@@ -1111,7 +1099,9 @@ static int lec_seq_show(struct seq_file *seq, void *v)else {struct lec_state *state = seq->private;struct net_device *dev = state->dev; - struct lec_arp_table *entry = hlist_entry(state->node, struct lec_arp_table, next); +struct lec_arp_table *entry =hlist_entry (state->node, + struct lec_arp_table, + next);seq_printf (seq,"%s " , dev->name);lec_info (seq, entry);
@@ -1191,7 +1181,7 @@ static int __init lane_module_init(void)#endif register_atm_ioctl (&lane_ioctl_ops); -printk ("lec.c: " __DATE__" " __TIME__" initialized\n" ); +pr_info ("lec.c: " __DATE__" " __TIME__" initialized\n" );return 0 ; }
@@ -1280,13 +1270,13 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,struct lec_priv *priv =netdev_priv (dev);if (compare_ether_addr (lan_dst, dev->dev_addr)) -return (0 );/* not our mac address */ +return 0 ;/* not our mac address */ kfree (priv->tlvs);/* NULL if there was no previous association */ priv->tlvs =kmemdup (tlvs, sizeoftlvs,GFP_KERNEL );if (priv->tlvs ==NULL ) -return (0 ); +return 0 ; priv->sizeoftlvs = sizeoftlvs; skb =alloc_skb (sizeoftlvs,GFP_ATOMIC );
@@ -1296,12 +1286,12 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,skb_copy_to_linear_data (skb, tlvs, sizeoftlvs); retval =send_to_lecd (priv, l_associate_req,NULL ,NULL , skb);if (retval !=0 ) -printk ("lec.c: lane2_associate_req() failed\n" ); +pr_info ("lec.c: lane2_associate_req() failed\n" );/* * If the previous association has changed we must * somehow notify other LANE entities about the change */ -return (1 ); +return 1 ; }/*
@@ -1334,12 +1324,12 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr, entry->sizeoftlvs = sizeoftlvs;#endif #if 0 -printk ("lec.c: lane2_associate_ind()\n" ); -printk ("dump of tlvs, sizeoftlvs=%d\n" , sizeoftlvs); +pr_info ("\n" ); +pr_info ("dump of tlvs, sizeoftlvs=%d\n" , sizeoftlvs);while (i < sizeoftlvs) -printk ("%02x " , tlvs[i++]); +pr_cont ("%02x " , tlvs[i++]); -printk ("\n" ); +pr_cont ("\n" );#endif /* tell MPOA about the TLVs we saw */
@@ -1359,13 +1349,13 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,#include <linux/types.h> #include <linux/timer.h> -#include <asm/param.h> +#include <linux/param.h> #include <asm/atomic.h> #include <linux/inetdevice.h> #include <net/route.h> #if 0 -#define pr_debug(format,args...) +#define pr_debug(format, args...)/* #define pr_debug printk */
@@ -1381,7 +1371,7 @@ static void lec_arp_expire_arp(unsigned long data);* Arp table funcs */ -#define HASH (ch) (ch & (LEC_ARP_TABLE_SIZE -1)) +#define HASH (ch) (ch & (LEC_ARP_TABLE_SIZE - 1))/* * Initialization of arp-cache
@@ -1390,9 +1380,8 @@ static void lec_arp_init(struct lec_priv *priv) {unsigned short i; -for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { +for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++)INIT_HLIST_HEAD (&priv->lec_arp_tables[i]); - }INIT_HLIST_HEAD (&priv->lec_arp_empty_ones);INIT_HLIST_HEAD (&priv->lec_no_forward);INIT_HLIST_HEAD (&priv->mcast_fwds);
@@ -1449,20 +1438,23 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)struct lec_arp_table *entry;int i, remove_vcc =1 ; -if (!to_remove) { +if (!to_remove)return -1 ; - }hlist_del (&to_remove->next);del_timer (&to_remove->timer); -/* If this is the only MAC connected to this VCC, also tear down the VCC */ +/* +* If this is the only MAC connected to this VCC, +* also tear down the VCC +*/ if (to_remove->status >=ESI_FLUSH_PENDING ) {/* * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT */ for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry (entry, node, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry (entry, node, + &priv->lec_arp_tables[i], next) {if (memcmp (to_remove->atm_addr, entry->atm_addr,ATM_ESA_LEN ) ==0 ) { remove_vcc =0 ;
@@ -1493,9 +1485,8 @@ static const char *get_status_string(unsigned char st)return "ESI_FLUSH_PENDING" ;case ESI_FORWARD_DIRECT :return "ESI_FORWARD_DIRECT" ; -default : -return "<UNKNOWN>" ; } +return "<UNKNOWN>" ; }static void dump_arp_table (struct lec_priv *priv)
@@ -1505,18 +1496,15 @@ static void dump_arp_table(struct lec_priv *priv)char buf[256 ];int i, j, offset; -printk ("Dump %p:\n" , priv); +pr_info ("Dump %p:\n" , priv);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry (rulla, node, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry (rulla, node, + &priv->lec_arp_tables[i], next) { offset =0 ; offset +=sprintf (buf,"%d: %p\n" , i, rulla); - offset +=sprintf (buf + offset,"Mac:" ); -for (j =0 ; j <ETH_ALEN ; j++) { - offset +=sprintf (buf + offset, -"%2.2x " , - rulla->mac_addr[j] &0xff ); - } - offset +=sprintf (buf + offset,"Atm:" ); + offset +=sprintf (buf + offset,"Mac: %pM" , + rulla->mac_addr); + offset +=sprintf (buf + offset," Atm:" );for (j =0 ; j <ATM_ESA_LEN ; j++) { offset += sprintf(buf + offset, "%2.2x ",
@@ -1536,20 +1524,16 @@ static void dump_arp_table(struct lec_priv *priv)"Flags:%x, Packets_flooded:%x, Status: %s " , rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); -printk ("%s\n" , buf); +pr_info ("%s\n" , buf); } }if (!hlist_empty (&priv->lec_no_forward)) -printk ("No forward\n" ); +pr_info ("No forward\n" );hlist_for_each_entry (rulla, node, &priv->lec_no_forward, next) { offset =0 ; - offset +=sprintf (buf + offset,"Mac:" ); -for (j =0 ; j <ETH_ALEN ; j++) { - offset +=sprintf (buf + offset,"%2.2x " , - rulla->mac_addr[j] &0xff ); - } - offset +=sprintf (buf + offset,"Atm:" ); + offset +=sprintf (buf + offset,"Mac: %pM" , rulla->mac_addr); + offset +=sprintf (buf + offset," Atm:" );for (j =0 ; j <ATM_ESA_LEN ; j++) { offset +=sprintf (buf + offset,"%2.2x " , rulla->atm_addr[j] &0xff );
@@ -1566,19 +1550,15 @@ static void dump_arp_table(struct lec_priv *priv)"Flags:%x, Packets_flooded:%x, Status: %s " , rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); -printk ("%s\n" , buf); +pr_info ("%s\n" , buf); }if (!hlist_empty (&priv->lec_arp_empty_ones)) -printk ("Empty ones\n" ); +pr_info ("Empty ones\n" );hlist_for_each_entry (rulla, node, &priv->lec_arp_empty_ones, next) { offset =0 ; - offset +=sprintf (buf + offset,"Mac:" ); -for (j =0 ; j <ETH_ALEN ; j++) { - offset +=sprintf (buf + offset,"%2.2x " , - rulla->mac_addr[j] &0xff ); - } - offset +=sprintf (buf + offset,"Atm:" ); + offset +=sprintf (buf + offset,"Mac: %pM" , rulla->mac_addr); + offset +=sprintf (buf + offset," Atm:" );for (j =0 ; j <ATM_ESA_LEN ; j++) { offset +=sprintf (buf + offset,"%2.2x " , rulla->atm_addr[j] &0xff );
@@ -1595,19 +1575,15 @@ static void dump_arp_table(struct lec_priv *priv)"Flags:%x, Packets_flooded:%x, Status: %s " , rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); -printk ("%s" , buf); +pr_info ("%s" , buf); }if (!hlist_empty (&priv->mcast_fwds)) -printk ("Multicast Forward VCCs\n" ); +pr_info ("Multicast Forward VCCs\n" );hlist_for_each_entry (rulla, node, &priv->mcast_fwds, next) { offset =0 ; - offset +=sprintf (buf + offset,"Mac:" ); -for (j =0 ; j <ETH_ALEN ; j++) { - offset +=sprintf (buf + offset,"%2.2x " , - rulla->mac_addr[j] &0xff ); - } - offset +=sprintf (buf + offset,"Atm:" ); + offset +=sprintf (buf + offset,"Mac: %pM" , rulla->mac_addr); + offset +=sprintf (buf + offset," Atm:" );for (j =0 ; j <ATM_ESA_LEN ; j++) { offset +=sprintf (buf + offset,"%2.2x " , rulla->atm_addr[j] &0xff );
@@ -1624,7 +1600,7 @@ static void dump_arp_table(struct lec_priv *priv)"Flags:%x, Packets_flooded:%x, Status: %s " , rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); -printk ("%s\n" , buf); +pr_info ("%s\n" , buf); } }
@@ -1650,14 +1626,16 @@ static void lec_arp_destroy(struct lec_priv *priv)spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_tables[i], next) {lec_arp_remove (priv, entry);lec_arp_put (entry); }INIT_HLIST_HEAD (&priv->lec_arp_tables[i]); } -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_empty_ones, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_empty_ones, next) {del_timer_sync (&entry->timer);lec_arp_clear_vccs (entry);hlist_del (&entry->next);
@@ -1665,7 +1643,8 @@ static void lec_arp_destroy(struct lec_priv *priv) }INIT_HLIST_HEAD (&priv->lec_arp_empty_ones); -hlist_for_each_entry_safe (entry, node, next, &priv->lec_no_forward, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_no_forward, next) {del_timer_sync (&entry->timer);lec_arp_clear_vccs (entry);hlist_del (&entry->next);
@@ -1698,9 +1677,8 @@ static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, head = &priv->lec_arp_tables[HASH (mac_addr[ETH_ALEN -1 ])];hlist_for_each_entry (entry, node, head, next) { -if (!compare_ether_addr (mac_addr, entry->mac_addr)) { +if (!compare_ether_addr (mac_addr, entry->mac_addr))return entry; - } }return NULL ; }
@@ -1712,7 +1690,7 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv, to_return =kzalloc (sizeof (struct lec_arp_table ),GFP_ATOMIC );if (!to_return) { -printk ("LEC: Arp entry kmalloc failed\n" ); +pr_info ("LEC: Arp entry kmalloc failed\n" );return NULL ; }memcpy (to_return->mac_addr, mac_addr,ETH_ALEN );
@@ -1802,7 +1780,8 @@ static void lec_arp_check_expire(struct work_struct *work) restart:spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_tables[i], next) {if ((entry->flags) &LEC_REMOTE_FLAG && priv->topology_change) time_to_check = priv->forward_delay_time;
@@ -1811,9 +1790,9 @@ restart:pr_debug ("About to expire: %lx - %lx > %lx\n" , now, entry->last_used, time_to_check); -if (time_after (now, entry->last_used + time_to_check) - && !(entry->flags &LEC_PERMANENT_FLAG ) - && !(entry->mac_addr[0 ] &0x01 )) {/* LANE2: 7.1.20 */ +if (time_after (now, entry->last_used + time_to_check) && + !(entry->flags &LEC_PERMANENT_FLAG ) && + !(entry->mac_addr[0 ] &0x01 )) {/* LANE2: 7.1.20 */ /* Remove entry */ pr_debug ("Entry timed out\n" );lec_arp_remove (priv, entry);
@@ -1821,11 +1800,10 @@ restart: }else {/* Something else */ if ((entry->status ==ESI_VC_PENDING || - entry->status ==ESI_ARP_PENDING ) - &&time_after_eq (now, - entry->timestamp + - priv-> - max_unknown_frame_time)) { + entry->status ==ESI_ARP_PENDING ) && +time_after_eq (now, + entry->timestamp + + priv->max_unknown_frame_time)) { entry->timestamp = jiffies; entry->packets_flooded =0 ;if (entry->status ==ESI_VC_PENDING )
@@ -1834,8 +1812,7 @@ restart: entry->atm_addr, NULL); } -if (entry->status ==ESI_FLUSH_PENDING - && +if (entry->status ==ESI_FLUSH_PENDING &&time_after_eq (now, entry->timestamp + priv->path_switching_delay)) {struct sk_buff *skb;
@@ -1863,7 +1840,8 @@ restart:* */ static struct atm_vcc *lec_arp_resolve (struct lec_priv *priv, -const unsigned char *mac_to_find,int is_rdesc, +const unsigned char *mac_to_find, +int is_rdesc,struct lec_arp_table **ret_entry) {unsigned long flags;
@@ -1899,9 +1877,8 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,* If the LE_ARP cache entry is still pending, reset count to 0 * so another LE_ARP request can be made for this frame. */ -if (entry->status ==ESI_ARP_PENDING ) { +if (entry->status ==ESI_ARP_PENDING ) entry->no_tries =0 ; - }/* * Data direct VC not yet set up, check to see if the unknown * frame count is greater than the limit. If the limit has
@@ -1969,10 +1946,11 @@ lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,pr_debug ("\n" );spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_tables[i], next) { -if (!memcmp (atm_addr, entry->atm_addr,ATM_ESA_LEN ) - && (permanent || - !(entry->flags &LEC_PERMANENT_FLAG ))) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_tables[i], next) { +if (!memcmp (atm_addr, entry->atm_addr,ATM_ESA_LEN ) && + (permanent || + !(entry->flags &LEC_PERMANENT_FLAG ))) {lec_arp_remove (priv, entry);lec_arp_put (entry); }
@@ -2008,7 +1986,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,* we have no entry in the cache. 7.1.30 */ if (!hlist_empty (&priv->lec_arp_empty_ones)) { -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_empty_ones, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_empty_ones, next) {if (memcmp (entry->atm_addr, atm_addr,ATM_ESA_LEN ) ==0 ) {hlist_del (&entry->next);del_timer (&entry->timer);
@@ -2052,7 +2031,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,memcpy (entry->atm_addr, atm_addr,ATM_ESA_LEN );del_timer (&entry->timer);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry (tmp, node, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry (tmp, node, + &priv->lec_arp_tables[i], next) {if (entry != tmp && !memcmp (tmp->atm_addr, atm_addr,ATM_ESA_LEN )) {/* Vcc to this host exists */
@@ -2097,14 +2077,13 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,int i, found_entry =0 ;spin_lock_irqsave (&priv->lec_arp_lock, flags); +/* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ if (ioc_data->receive ==2 ) { -/* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ -pr_debug ("LEC_ARP: Attaching mcast forward\n" );#if 0 entry =lec_arp_find (priv, bus_mac);if (!entry) { -printk ("LEC_ARP: Multicast entry not found!\n" ); +pr_info ("LEC_ARP: Multicast entry not found!\n" ); goto out; }memcpy (entry->atm_addr, ioc_data->atm_addr,ATM_ESA_LEN );
@@ -2163,7 +2142,8 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, ioc_data->atm_addr[16 ], ioc_data->atm_addr[17 ], ioc_data->atm_addr[18], ioc_data->atm_addr[19]);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry (entry, node, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry (entry, node, + &priv->lec_arp_tables[i], next) {if (memcmp (ioc_data->atm_addr, entry->atm_addr,ATM_ESA_LEN ) ==0 ) {
@@ -2247,14 +2227,16 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) restart:spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry (entry, node, &priv->lec_arp_tables[i], next) { -if (entry->flush_tran_id == tran_id - && entry->status ==ESI_FLUSH_PENDING ) { +hlist_for_each_entry (entry, node, + &priv->lec_arp_tables[i], next) { +if (entry->flush_tran_id == tran_id && + entry->status ==ESI_FLUSH_PENDING ) {struct sk_buff *skb;struct atm_vcc *vcc = entry->vcc;lec_arp_hold (entry); -spin_unlock_irqrestore (&priv->lec_arp_lock, flags); +spin_unlock_irqrestore (&priv->lec_arp_lock, + flags);while ((skb =skb_dequeue (&entry->tx_wait)) !=NULL )lec_send (vcc, skb); entry->last_used = jiffies;
@@ -2280,7 +2262,8 @@ lec_set_flush_tran_id(struct lec_priv *priv,spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) -hlist_for_each_entry (entry, node, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry (entry, node, + &priv->lec_arp_tables[i], next) {if (!memcmp (atm_addr, entry->atm_addr,ATM_ESA_LEN )) { entry->flush_tran_id = tran_id; pr_debug("Set flush transaction id to %lx for %p\n",
@@ -2300,7 +2283,8 @@ static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)struct lec_vcc_priv *vpriv;int err =0 ; -if (!(vpriv =kmalloc (sizeof (struct lec_vcc_priv ),GFP_KERNEL ))) + vpriv =kmalloc (sizeof (struct lec_vcc_priv ),GFP_KERNEL ); +if (!vpriv)return -ENOMEM ; vpriv->xoff =0 ; vpriv->old_pop = vcc->pop;
@@ -2340,18 +2324,19 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)spin_lock_irqsave (&priv->lec_arp_lock, flags);for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) { -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_tables[i], next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_tables[i], next) {if (vcc == entry->vcc) {lec_arp_remove (priv, entry);lec_arp_put (entry); -if (priv->mcast_vcc == vcc) { +if (priv->mcast_vcc == vcc) priv->mcast_vcc =NULL ; - } } } } -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_empty_ones, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_empty_ones, next) {if (entry->vcc == vcc) {lec_arp_clear_vccs (entry);del_timer (&entry->timer);
@@ -2360,7 +2345,8 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) } } -hlist_for_each_entry_safe (entry, node, next, &priv->lec_no_forward, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_no_forward, next) {if (entry->recv_vcc == vcc) {lec_arp_clear_vccs (entry);del_timer (&entry->timer);
@@ -2401,14 +2387,16 @@ lec_arp_check_empties(struct lec_priv *priv, src = hdr->h_source;spin_lock_irqsave (&priv->lec_arp_lock, flags); -hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_empty_ones, next) { +hlist_for_each_entry_safe (entry, node, next, + &priv->lec_arp_empty_ones, next) {if (vcc == entry->vcc) {del_timer (&entry->timer);memcpy (entry->mac_addr, src,ETH_ALEN ); entry->status =ESI_FORWARD_DIRECT ; entry->last_used = jiffies;/* We might have got an entry */ -if ((tmp =lec_arp_find (priv, src))) { + tmp =lec_arp_find (priv, src); +if (tmp) {lec_arp_remove (priv, tmp);lec_arp_put (tmp); }
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 10/21 net/atm/mpc.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux... Add printk argument verification to dprintk and ddprintk Spacing cleanups
Mostly 80 column wrapped.printk->pr_info and pr_cont
Moved labels to column 1
Move trailing statements to new lines switch/case cleanups
remove unnecessary breaks after returns
Remove unnecessary braces around single line statements
--- net/atm/mpc.c | 445 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 252 insertions(+), 193 deletions(-)
net/atm/mpc.c +252 -193
@@ -15,8 +15,8 @@#include <net/sock.h> #include <linux/skbuff.h> #include <linux/ip.h> +#include <linux/uaccess.h> #include <asm/byteorder.h> -#include <asm/uaccess.h> #include <net/checksum.h> /* for ip_fast_csum() */ #include <net/arp.h> #include <net/dst.h>
@@ -38,15 +38,17 @@*/ #if 0 -#define dprintk printk/* debug */ +#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) /* debug */#else -#define dprintk(format,args...) +#define dprintk(format, args...) \ + do { if (0) printk(KERN_DEBUG format, ##args); } while (0)#endif #if 0 -#define ddprintk printk/* more debug */ +#define ddprintk printk(KERN_DEBUG format, ##args)/* more debug */ #else -#define ddprintk(format,args...) +#define ddprintk(format, args...) \ + do { if (0) printk(KERN_DEBUG format, ##args); } while (0)#endif
@@ -54,15 +56,19 @@#define MPOA_TAG_LEN 4/* mpc_daemon -> kernel */ -static void MPOA_trigger_rcvd (struct k_message *msg,struct mpoa_client *mpc); +static void MPOA_trigger_rcvd (struct k_message *msg,struct mpoa_client *mpc);static void MPOA_res_reply_rcvd (struct k_message *msg,struct mpoa_client *mpc);static void ingress_purge_rcvd (struct k_message *msg,struct mpoa_client *mpc);static void egress_purge_rcvd (struct k_message *msg,struct mpoa_client *mpc);static void mps_death (struct k_message *msg,struct mpoa_client *mpc); -static void clean_up (struct k_message *msg,struct mpoa_client *mpc,int action); -static void MPOA_cache_impos_rcvd (struct k_message *msg,struct mpoa_client *mpc); -static void set_mpc_ctrl_addr_rcvd (struct k_message *mesg,struct mpoa_client *mpc); -static void set_mps_mac_addr_rcvd (struct k_message *mesg,struct mpoa_client *mpc); +static void clean_up (struct k_message *msg,struct mpoa_client *mpc, +int action); +static void MPOA_cache_impos_rcvd (struct k_message *msg, +struct mpoa_client *mpc); +static void set_mpc_ctrl_addr_rcvd (struct k_message *mesg, +struct mpoa_client *mpc); +static void set_mps_mac_addr_rcvd (struct k_message *mesg, +struct mpoa_client *mpc); static const uint8_t *copy_macs(struct mpoa_client *mpc, const uint8_t *router_mac,
@@ -76,10 +82,11 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb);static void mpc_push (struct atm_vcc *vcc,struct sk_buff *skb);static netdev_tx_t mpc_send_packet (struct sk_buff *skb, -struct net_device *dev); -static int mpoa_event_listener (struct notifier_block *mpoa_notifier,unsigned long event,void *dev); +struct net_device *dev); +static int mpoa_event_listener (struct notifier_block *mpoa_notifier, +unsigned long event,void *dev);static void mpc_timer_refresh (void ); -static void mpc_cache_check (unsigned long checking_time ); +static void mpc_cache_check (unsigned long checking_time);static struct llc_snap_hdr llc_snap_mpoa_ctrl = {0xaa ,0xaa ,0x03 ,
@@ -169,7 +176,7 @@ struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos) entry =kmalloc (sizeof (struct atm_mpoa_qos ),GFP_KERNEL );if (entry ==NULL ) { -printk ("mpoa: atm_mpoa_add_qos: out of memory\n" ); +pr_info ("mpoa: out of memory\n" );return entry; }
@@ -187,10 +194,9 @@ struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip)struct atm_mpoa_qos *qos; qos = qos_head; -while ( qos !=NULL ){ -if (qos->ipaddr == dst_ip) { +while (qos) { +if (qos->ipaddr == dst_ip)break ; - } qos = qos->next; }
@@ -202,10 +208,10 @@ struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip)*/ int atm_mpoa_delete_qos (struct atm_mpoa_qos *entry) { -struct atm_mpoa_qos *curr; -if (entry ==NULL )return 0 ; +if (entry ==NULL ) +return 0 ;if (entry == qos_head) { qos_head = qos_head->next;kfree (entry);
@@ -236,9 +242,17 @@ void atm_mpoa_disp_qos(struct seq_file *m)while (qos !=NULL ) {seq_printf (m,"%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n" , - &qos->ipaddr, - qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, - qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); + &qos->ipaddr, + qos->qos.txtp.max_pcr, + qos->qos.txtp.pcr, + qos->qos.txtp.min_pcr, + qos->qos.txtp.max_cdv, + qos->qos.txtp.max_sdu, + qos->qos.rxtp.max_pcr, + qos->qos.rxtp.pcr, + qos->qos.rxtp.min_pcr, + qos->qos.rxtp.max_cdv, + qos->qos.rxtp.max_sdu); qos = qos->next; } }
@@ -258,7 +272,7 @@ static struct mpoa_client *alloc_mpc(void) {struct mpoa_client *mpc; - mpc =kzalloc (sizeof (struct mpoa_client ),GFP_KERNEL ); + mpc =kzalloc (sizeof (struct mpoa_client ),GFP_KERNEL );if (mpc ==NULL )return NULL ;rwlock_init (&mpc->ingress_lock);
@@ -268,7 +282,7 @@ static struct mpoa_client *alloc_mpc(void) mpc->parameters.mpc_p1 =MPC_P1 ; mpc->parameters.mpc_p2 =MPC_P2 ; -memset (mpc->parameters.mpc_p3,0 ,sizeof (mpc->parameters.mpc_p3)); +memset (mpc->parameters.mpc_p3,0 ,sizeof (mpc->parameters.mpc_p3)); mpc->parameters.mpc_p4 =MPC_P4 ; mpc->parameters.mpc_p5 =MPC_P5 ; mpc->parameters.mpc_p6 =MPC_P6 ;
@@ -290,7 +304,7 @@ static void start_mpc(struct mpoa_client *mpc, struct net_device *dev)dprintk ("mpoa: (%s) start_mpc:\n" , mpc->dev->name);if (!dev->netdev_ops) -printk ("mpoa: (%s) start_mpc not starting\n" , dev->name); +pr_info ("(%s) not starting\n" , dev->name);else { mpc->old_ops = dev->netdev_ops; mpc->new_ops = *mpc->old_ops;
@@ -321,25 +335,18 @@ static const char *mpoa_device_type_string(char type) __attribute__ ((unused));static const char *mpoa_device_type_string (char type) { -switch (type) { +switch (type) {case NON_MPOA :return "non-MPOA device" ; -break ;case MPS :return "MPS" ; -break ;case MPC :return "MPC" ; -break ;case MPS_AND_MPC :return "both MPS and MPC" ; -break ; -default : -return "unspecified (non-MPOA) device" ; -break ; } -return "" ;/* not reached */ +return "unspecified (non-MPOA) device" ; }/*
@@ -368,22 +375,24 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr,dprintk ("total length of all TLVs %d\n" , sizeoftlvs); mpc =find_mpc_by_lec (dev);/* Sampo-Fix: moved here from below */ if (mpc ==NULL ) { -printk ("mpoa: (%s) lane2_assoc_ind: no mpc\n" , dev->name); +pr_info ("(%s) no mpc\n" , dev->name);return ; } end_of_tlvs = tlvs + sizeoftlvs;while (end_of_tlvs - tlvs >=5 ) { - type = (tlvs[0 ] <<24 ) | (tlvs[1 ] <<16 ) | (tlvs[2 ] <<8 ) | tlvs[3 ]; + type = ((tlvs[0 ] <<24 ) | (tlvs[1 ] <<16 ) | + (tlvs[2 ] <<8 ) | tlvs[3 ]); length = tlvs[4 ]; tlvs +=5 ;dprintk (" type 0x%x length %02x\n" , type, length);if (tlvs + length > end_of_tlvs) { -printk ("TLV value extends past its buffer, aborting parse\n" ); +pr_info ("TLV value extends past its buffer, aborting parse\n" );return ; }if (type ==0 ) { -printk ("mpoa: (%s) lane2_assoc_ind: TLV type was 0, returning\n" , dev->name); +pr_info ("mpoa: (%s) TLV type was 0, returning\n" , + dev->name);return ; }
@@ -393,39 +402,47 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, } mpoa_device_type = *tlvs++; number_of_mps_macs = *tlvs++; -dprintk ("mpoa: (%s) MPOA device type '%s', " , dev->name,mpoa_device_type_string (mpoa_device_type)); +dprintk ("mpoa: (%s) MPOA device type '%s', " , + dev->name,mpoa_device_type_string (mpoa_device_type));if (mpoa_device_type ==MPS_AND_MPC && length < (42 + number_of_mps_macs*ETH_ALEN )) {/* :) */ -printk ("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n" , - dev->name); +pr_info ("(%s) short MPOA Device Type TLV\n" , + dev->name);continue ; } -if ((mpoa_device_type ==MPS || mpoa_device_type ==MPC ) - && length <22 + number_of_mps_macs*ETH_ALEN ) { -printk ("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n" , - dev->name); +if ((mpoa_device_type ==MPS || mpoa_device_type ==MPC ) && + length <22 + number_of_mps_macs*ETH_ALEN ) { +pr_info ("(%s) short MPOA Device Type TLV\n" , dev->name);continue ; } -if (mpoa_device_type !=MPS && mpoa_device_type !=MPS_AND_MPC ) { +if (mpoa_device_type !=MPS && + mpoa_device_type !=MPS_AND_MPC ) {dprintk ("ignoring non-MPS device\n" ); -if (mpoa_device_type ==MPC ) tlvs +=20 ; +if (mpoa_device_type ==MPC ) + tlvs +=20 ;continue ;/* we are only interested in MPSs */ } -if (number_of_mps_macs ==0 && mpoa_device_type ==MPS_AND_MPC ) { -printk ("\nmpoa: (%s) lane2_assoc_ind: MPS_AND_MPC has zero MACs\n" , dev->name); +if (number_of_mps_macs ==0 && + mpoa_device_type ==MPS_AND_MPC ) { +pr_info ("(%s) MPS_AND_MPC has zero MACs\n" , dev->name);continue ;/* someone should read the spec */ }dprintk ("this MPS has %d MAC addresses\n" , number_of_mps_macs); -/* ok, now we can go and tell our daemon the control address of MPS */ +/* +* ok, now we can go and tell our daemon +* the control address of MPS +*/ send_set_mps_ctrl_addr (tlvs, mpc); - tlvs =copy_macs (mpc, mac_addr, tlvs, number_of_mps_macs, mpoa_device_type); -if (tlvs ==NULL )return ; + tlvs =copy_macs (mpc, mac_addr, tlvs, + number_of_mps_macs, mpoa_device_type); +if (tlvs ==NULL ) +return ; }if (end_of_tlvs - tlvs !=0 ) -printk ("mpoa: (%s) lane2_assoc_ind: ignoring %Zd bytes of trailing TLV carbage\n" , - dev->name, end_of_tlvs - tlvs); +pr_info ("(%s) ignoring %Zd bytes of trailing TLV garbage\n" , + dev->name, end_of_tlvs - tlvs);return ; }
@@ -443,11 +460,12 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc, num_macs = (mps_macs >1 ) ? mps_macs :1 ;if (mpc->number_of_mps_macs != num_macs) {/* need to reallocate? */ -if (mpc->number_of_mps_macs !=0 )kfree (mpc->mps_macs); +if (mpc->number_of_mps_macs !=0 ) +kfree (mpc->mps_macs); mpc->number_of_mps_macs =0 ; - mpc->mps_macs =kmalloc (num_macs*ETH_ALEN ,GFP_KERNEL ); + mpc->mps_macs =kmalloc (num_macs *ETH_ALEN ,GFP_KERNEL );if (mpc->mps_macs ==NULL ) { -printk ("mpoa: (%s) copy_macs: out of mem\n" , mpc->dev->name); +pr_info ("(%s) out of mem\n" , mpc->dev->name);return NULL ; } }
@@ -480,24 +498,30 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) iph = (struct iphdr *)buff; ipaddr = iph->daddr; -ddprintk ("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n" , mpc->dev->name, ipaddr); +ddprintk ("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n" , + mpc->dev->name, ipaddr); entry = mpc->in_ops->get (ipaddr, mpc);if (entry ==NULL ) { entry = mpc->in_ops->add_entry (ipaddr, mpc); -if (entry !=NULL ) mpc->in_ops->put (entry); +if (entry !=NULL ) + mpc->in_ops->put (entry);return 1 ; } -if (mpc->in_ops->cache_hit (entry, mpc) !=OPEN ){/* threshold not exceeded or VCC not ready */ -ddprintk ("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n" , mpc->dev->name); +/* threshold not exceeded or VCC not ready */ +if (mpc->in_ops->cache_hit (entry, mpc) !=OPEN ) { +ddprintk ("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n" , + mpc->dev->name); mpc->in_ops->put (entry);return 1 ; } -ddprintk ("mpoa: (%s) send_via_shortcut: using shortcut\n" , mpc->dev->name); +ddprintk ("mpoa: (%s) send_via_shortcut: using shortcut\n" , + mpc->dev->name);/* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ if (iph->ttl <=1 ) { -ddprintk ("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n" , mpc->dev->name, iph->ttl); +ddprintk ("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n" , + mpc->dev->name, iph->ttl); mpc->in_ops->put (entry);return 1 ; }
@@ -506,15 +530,18 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) iph->check =ip_fast_csum ((unsigned char *)iph, iph->ihl);if (entry->ctrl_info.tag !=0 ) { -ddprintk ("mpoa: (%s) send_via_shortcut: adding tag 0x%x\n" , mpc->dev->name, entry->ctrl_info.tag); +ddprintk ("mpoa: (%s) send_via_shortcut: adding tag 0x%x\n" , + mpc->dev->name, entry->ctrl_info.tag); tagged_llc_snap_hdr.tag = entry->ctrl_info.tag; -skb_pull (skb,ETH_HLEN );/* get rid of Eth header */ -skb_push (skb,sizeof (tagged_llc_snap_hdr));/* add LLC/SNAP header */ +skb_pull (skb,ETH_HLEN );/* get rid of Eth header */ +skb_push (skb,sizeof (tagged_llc_snap_hdr)); +/* add LLC/SNAP header */ skb_copy_to_linear_data (skb, &tagged_llc_snap_hdr,sizeof (tagged_llc_snap_hdr)); }else { -skb_pull (skb,ETH_HLEN );/* get rid of Eth header */ -skb_push (skb,sizeof (struct llc_snap_hdr ));/* add LLC/SNAP header + tag */ +skb_pull (skb,ETH_HLEN );/* get rid of Eth header */ +skb_push (skb,sizeof (struct llc_snap_hdr )); +/* add LLC/SNAP header + tag */ skb_copy_to_linear_data (skb, &llc_snap_mpoa_data,sizeof (struct llc_snap_hdr )); }
@@ -539,8 +566,8 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb,int i =0 ; mpc =find_mpc_by_lec (dev);/* this should NEVER fail */ -if (mpc ==NULL ) { -printk ("mpoa: (%s) mpc_send_packet: no MPC found\n" , dev->name); +if (mpc ==NULL ) { +pr_info ("(%s) no MPC found\n" , dev->name); goto non_ip; }
@@ -556,14 +583,15 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb, goto non_ip;while (i < mpc->number_of_mps_macs) { -if (!compare_ether_addr (eth->h_dest, (mpc->mps_macs + i*ETH_ALEN ))) -if (send_via_shortcut (skb, mpc) ==0 )/* try shortcut */ -return NETDEV_TX_OK ;/* success! */ +if (!compare_ether_addr (eth->h_dest, + (mpc->mps_macs + i*ETH_ALEN ))) +if (send_via_shortcut (skb, mpc) ==0 )/* try shortcut */ +return NETDEV_TX_OK ; i++; } - non_ip: -return mpc->old_ops->ndo_start_xmit (skb,dev); +non_ip: +return mpc->old_ops->ndo_start_xmit (skb, dev); }static int atm_mpoa_vcc_attach (struct atm_vcc *vcc,void __user *arg)
@@ -576,7 +604,8 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) bytes_left =copy_from_user (&ioc_data, arg,sizeof (struct atmmpc_ioc ));if (bytes_left !=0 ) { -printk ("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n" , bytes_left); +pr_info ("mpoa:Short read (missed %d bytes) from userland\n" , + bytes_left);return -EFAULT ; } ipaddr = ioc_data.ipaddr;
@@ -589,18 +618,20 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)if (ioc_data.type ==MPC_SOCKET_INGRESS ) { in_entry = mpc->in_ops->get (ipaddr, mpc); -if (in_entry ==NULL || in_entry->entry_state <INGRESS_RESOLVED ) { -printk ("mpoa: (%s) mpc_vcc_attach: did not find RESOLVED entry from ingress cache\n" , +if (in_entry ==NULL || + in_entry->entry_state <INGRESS_RESOLVED ) { +pr_info ("(%s) did not find RESOLVED entry from ingress cache\n" , mpc->dev->name); -if (in_entry !=NULL ) mpc->in_ops->put (in_entry); +if (in_entry !=NULL ) + mpc->in_ops->put (in_entry);return -EINVAL ; } -printk ("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %pI4\n" , - mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); +pr_info ("(%s) attaching ingress SVC, entry = %pI4\n" , + mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); in_entry->shortcut = vcc; mpc->in_ops->put (in_entry); }else { -printk ("mpoa: (%s) mpc_vcc_attach: attaching egress SVC\n" , mpc->dev->name); +pr_info ("(%s) attaching egress SVC\n" , mpc->dev->name); } vcc->proto_data = mpc->dev;
@@ -620,7 +651,7 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev) mpc =find_mpc_by_lec (dev);if (mpc ==NULL ) { -printk ("mpoa: (%s) mpc_vcc_close: close for unknown MPC\n" , dev->name); +pr_info ("(%s) close for unknown MPC\n" , dev->name);return ; }
@@ -628,19 +659,21 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev) in_entry = mpc->in_ops->get_by_vcc (vcc, mpc);if (in_entry) {dprintk ("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %pI4\n" , - mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); + mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); in_entry->shortcut =NULL ; mpc->in_ops->put (in_entry); } eg_entry = mpc->eg_ops->get_by_vcc (vcc, mpc);if (eg_entry) { -dprintk ("mpoa: (%s) mpc_vcc_close: egress SVC closed\n" , mpc->dev->name); +dprintk ("mpoa: (%s) mpc_vcc_close: egress SVC closed\n" , + mpc->dev->name); eg_entry->shortcut =NULL ; mpc->eg_ops->put (eg_entry); }if (in_entry ==NULL && eg_entry ==NULL ) -dprintk ("mpoa: (%s) mpc_vcc_close: unused vcc closed\n" , dev->name); +dprintk ("mpoa: (%s) mpc_vcc_close: unused vcc closed\n" , + dev->name);return ; }
@@ -656,16 +689,19 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)ddprintk ("mpoa: (%s) mpc_push:\n" , dev->name);if (skb ==NULL ) { -dprintk ("mpoa: (%s) mpc_push: null skb, closing VCC\n" , dev->name); +dprintk ("mpoa: (%s) mpc_push: null skb, closing VCC\n" , + dev->name);mpc_vcc_close (vcc, dev);return ; } skb->dev = dev; -if (memcmp (skb->data, &llc_snap_mpoa_ctrl,sizeof (struct llc_snap_hdr )) ==0 ) { +if (memcmp (skb->data, &llc_snap_mpoa_ctrl, +sizeof (struct llc_snap_hdr )) ==0 ) {struct sock *sk =sk_atm (vcc); -dprintk ("mpoa: (%s) mpc_push: control packet arrived\n" , dev->name); +dprintk ("mpoa: (%s) mpc_push: control packet arrived\n" , + dev->name);/* Pass control packets to daemon */ skb_queue_tail (&sk->sk_receive_queue, skb); sk->sk_data_ready (sk, skb->len);
@@ -677,20 +713,23 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) mpc =find_mpc_by_lec (dev);if (mpc ==NULL ) { -printk ("mpoa: (%s) mpc_push: unknown MPC\n" , dev->name); +pr_info ("(%s) unknown MPC\n" , dev->name);return ; } -if (memcmp (skb->data, &llc_snap_mpoa_data_tagged,sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA tagged data */ -ddprintk ("mpoa: (%s) mpc_push: tagged data packet arrived\n" , dev->name); +if (memcmp (skb->data, &llc_snap_mpoa_data_tagged, +sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA tagged data */ +ddprintk ("mpoa: (%s) mpc_push: tagged data packet arrived\n" , + dev->name); - }else if (memcmp (skb->data, &llc_snap_mpoa_data,sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA data */ -printk ("mpoa: (%s) mpc_push: non-tagged data packet arrived\n" , dev->name); -printk (" mpc_push: non-tagged data unsupported, purging\n" ); + }else if (memcmp (skb->data, &llc_snap_mpoa_data, +sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA data */ +pr_info ("(%s) Unsupported non-tagged data packet arrived. Purging\n" , + dev->name);dev_kfree_skb_any (skb);return ; }else { -printk ("mpoa: (%s) mpc_push: garbage arrived, purging\n" , dev->name); +pr_info ("(%s) garbage arrived, purging\n" , dev->name);dev_kfree_skb_any (skb);return ; }
@@ -700,8 +739,8 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) eg = mpc->eg_ops->get_by_tag (tag, mpc);if (eg ==NULL ) { -printk ("mpoa: (%s) mpc_push: Didn't find egress cache entry, tag = %u\n" , - dev->name,tag); +pr_info ("mpoa: (%s) Didn't find egress cache entry, tag = %u\n" , + dev->name, tag);purge_egress_shortcut (vcc,NULL );dev_kfree_skb_any (skb);return ;
@@ -713,13 +752,15 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)*/ if (eg->shortcut ==NULL ) { eg->shortcut = vcc; -printk ("mpoa: (%s) mpc_push: egress SVC in use\n" , dev->name); +pr_info ("(%s) egress SVC in use\n" , dev->name); } -skb_pull (skb,sizeof (struct llc_snap_hdr ) +sizeof (tag));/* get rid of LLC/SNAP header */ - new_skb =skb_realloc_headroom (skb, eg->ctrl_info.DH_length);/* LLC/SNAP is shorter than MAC header :( */ +skb_pull (skb,sizeof (struct llc_snap_hdr ) +sizeof (tag)); +/* get rid of LLC/SNAP header */ + new_skb =skb_realloc_headroom (skb, eg->ctrl_info.DH_length); +/* LLC/SNAP is shorter than MAC header :( */ dev_kfree_skb_any (skb); -if (new_skb ==NULL ){ +if (new_skb ==NULL ) { mpc->eg_ops->put (eg);return ; }
@@ -752,7 +793,7 @@ static struct atm_dev mpc_dev = {/* members not explicitly initialised will be 0 */ }; -static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc,int arg) +static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc,int arg) {struct mpoa_client *mpc;struct lec_priv *priv;
@@ -772,15 +813,17 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) mpc =find_mpc_by_itfnum (arg);if (mpc ==NULL ) { -dprintk ("mpoa: mpoad_attach: allocating new mpc for itf %d\n" , arg); +dprintk ("mpoa: mpoad_attach: allocating new mpc for itf %d\n" , + arg); mpc =alloc_mpc ();if (mpc ==NULL )return -ENOMEM ; mpc->dev_num = arg; - mpc->dev =find_lec_by_itfnum (arg);/* NULL if there was no lec */ + mpc->dev =find_lec_by_itfnum (arg); +/* NULL if there was no lec */ }if (mpc->mpoad_vcc) { -printk ("mpoa: mpoad_attach: mpoad is already present for itf %d\n" , arg); +pr_info ("mpoad is already present for itf %d\n" , arg);return -EADDRINUSE ; }
@@ -796,8 +839,8 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) mpc->mpoad_vcc = vcc; vcc->dev = &mpc_dev;vcc_insert_socket (sk_atm (vcc)); -set_bit (ATM_VF_META ,&vcc->flags); -set_bit (ATM_VF_READY ,&vcc->flags); +set_bit (ATM_VF_META , &vcc->flags); +set_bit (ATM_VF_READY , &vcc->flags);if (mpc->dev) {char empty[ATM_ESA_LEN ];
@@ -807,7 +850,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)/* set address if mpcd e.g. gets killed and restarted. * If we do not do it now we have to wait for the next LE_ARP */ -if (memcmp (mpc->mps_ctrl_addr, empty,ATM_ESA_LEN ) !=0 ) +if (memcmp (mpc->mps_ctrl_addr, empty,ATM_ESA_LEN ) !=0 )send_set_mps_ctrl_addr (mpc->mps_ctrl_addr, mpc); }
@@ -819,7 +862,7 @@ static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc) {struct k_message mesg; -memcpy (mpc->mps_ctrl_addr, addr,ATM_ESA_LEN ); +memcpy (mpc->mps_ctrl_addr, addr,ATM_ESA_LEN ); mesg.type =SET_MPS_CTRL_ADDR ;memcpy (mesg.MPS_ctrl, addr,ATM_ESA_LEN );
@@ -835,11 +878,11 @@ static void mpoad_close(struct atm_vcc *vcc) mpc =find_mpc_by_vcc (vcc);if (mpc ==NULL ) { -printk ("mpoa: mpoad_close: did not find MPC\n" ); +pr_info ("did not find MPC\n" );return ; }if (!mpc->mpoad_vcc) { -printk ("mpoa: mpoad_close: close for non-present mpoad\n" ); +pr_info ("close for non-present mpoad\n" );return ; }
@@ -859,7 +902,7 @@ static void mpoad_close(struct atm_vcc *vcc)kfree_skb (skb); } -printk ("mpoa: (%s) going down\n" , +pr_info ("(%s) going down\n" , (mpc->dev) ? mpc->dev->name :"<unknown>" );module_put (THIS_MODULE );
@@ -873,15 +916,16 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb) {struct mpoa_client *mpc =find_mpc_by_vcc (vcc); -struct k_message *mesg = (struct k_message *)skb->data; +struct k_message *mesg = (struct k_message *)skb->data;atomic_sub (skb->truesize, &sk_atm (vcc)->sk_wmem_alloc);if (mpc ==NULL ) { -printk ("mpoa: msg_from_mpoad: no mpc found\n" ); +pr_info ("no mpc found\n" );return 0 ; } -dprintk ("mpoa: (%s) msg_from_mpoad:" , (mpc->dev) ? mpc->dev->name :"<unknown>" ); -switch (mesg->type) { +dprintk ("mpoa: (%s) msg_from_mpoad:" , + (mpc->dev) ? mpc->dev->name :"<unknown>" ); +switch (mesg->type) {case MPOA_RES_REPLY_RCVD :dprintk (" mpoa_res_reply_rcvd\n" );MPOA_res_reply_rcvd (mesg, mpc);
@@ -942,7 +986,7 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc)struct sock *sk;if (mpc ==NULL || !mpc->mpoad_vcc) { -printk ("mpoa: msg_to_mpoad: mesg %d to a non-existent mpoad\n" , mesg->type); +pr_info ("mesg %d to a non-existent mpoad\n" , mesg->type);return -ENXIO ; }
@@ -960,7 +1004,8 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc)return 0 ; } -static int mpoa_event_listener (struct notifier_block *mpoa_notifier,unsigned long event,void *dev_ptr) +static int mpoa_event_listener (struct notifier_block *mpoa_notifier, +unsigned long event,void *dev_ptr) {struct net_device *dev;struct mpoa_client *mpc;
@@ -983,10 +1028,10 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo mpc =find_mpc_by_itfnum (priv->itfnum);if (mpc ==NULL ) {dprintk ("mpoa: mpoa_event_listener: allocating new mpc for %s\n" , - dev->name); + dev->name); mpc =alloc_mpc ();if (mpc ==NULL ) { -printk ("mpoa: mpoa_event_listener: no new mpc" ); +pr_info ("no new mpc" );break ; } }
@@ -1010,9 +1055,8 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo mpc =find_mpc_by_lec (dev);if (mpc ==NULL )break ; -if (mpc->mpoad_vcc !=NULL ) { +if (mpc->mpoad_vcc !=NULL )start_mpc (mpc, dev); - }break ;case NETDEV_DOWN :/* the dev was ifconfig'ed down */
@@ -1022,9 +1066,8 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo mpc =find_mpc_by_lec (dev);if (mpc ==NULL )break ; -if (mpc->mpoad_vcc !=NULL ) { +if (mpc->mpoad_vcc !=NULL )stop_mpc (mpc); - }break ;case NETDEV_REBOOT :case NETDEV_CHANGE :
@@ -1051,7 +1094,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)in_cache_entry *entry; entry = mpc->in_ops->get (dst_ip, mpc); -if (entry ==NULL ){ +if (entry ==NULL ) { entry = mpc->in_ops->add_entry (dst_ip, mpc); entry->entry_state =INGRESS_RESOLVING ; msg->type =SND_MPOA_RES_RQST ;
@@ -1062,7 +1105,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)return ; } -if (entry->entry_state ==INGRESS_INVALID ){ +if (entry->entry_state ==INGRESS_INVALID ) { entry->entry_state =INGRESS_RESOLVING ; msg->type =SND_MPOA_RES_RQST ; msg->content.in_info = entry->ctrl_info;
@@ -1072,7 +1115,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)return ; } -printk ("mpoa: (%s) MPOA_trigger_rcvd: entry already in resolving state\n" , +pr_info ("(%s) entry already in resolving state\n" , (mpc->dev) ? mpc->dev->name :"<unknown>" ); mpc->in_ops->put (entry);return ;
@@ -1082,22 +1125,24 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)* Things get complicated because we have to check if there's an egress * shortcut with suitable traffic parameters we could use. */ -static void check_qos_and_open_shortcut (struct k_message *msg,struct mpoa_client *client,in_cache_entry *entry) +static void check_qos_and_open_shortcut (struct k_message *msg, +struct mpoa_client *client, +in_cache_entry *entry) {__be32 dst_ip = msg->content.in_info.in_dst_ip;struct atm_mpoa_qos *qos =atm_mpoa_search_qos (dst_ip);eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip (dst_ip, client); -if (eg_entry && eg_entry->shortcut){ -if (eg_entry->shortcut->qos.txtp.traffic_class & - msg->qos.txtp.traffic_class & - (qos ? qos->qos.txtp.traffic_class :ATM_UBR |ATM_CBR )){ -if (eg_entry->shortcut->qos.txtp.traffic_class ==ATM_UBR ) - entry->shortcut = eg_entry->shortcut; -else if (eg_entry->shortcut->qos.txtp.max_pcr >0 ) - entry->shortcut = eg_entry->shortcut; +if (eg_entry && eg_entry->shortcut) { +if (eg_entry->shortcut->qos.txtp.traffic_class & + msg->qos.txtp.traffic_class & + (qos ? qos->qos.txtp.traffic_class :ATM_UBR |ATM_CBR )) { +if (eg_entry->shortcut->qos.txtp.traffic_class ==ATM_UBR ) + entry->shortcut = eg_entry->shortcut; +else if (eg_entry->shortcut->qos.txtp.max_pcr >0 ) + entry->shortcut = eg_entry->shortcut; } -if (entry->shortcut){ +if (entry->shortcut) {dprintk ("mpoa: (%s) using egress SVC to reach %pI4\n" , client->dev->name, &dst_ip); client->eg_ops->put (eg_entry);
@@ -1109,12 +1154,13 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien/* No luck in the egress cache we must open an ingress SVC */ msg->type =OPEN_INGRESS_SVC ; -if (qos && (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) - { +if (qos && + (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) { msg->qos = qos->qos; -printk ("mpoa: (%s) trying to get a CBR shortcut\n" ,client->dev->name); - } -else memset (&msg->qos,0 ,sizeof (struct atm_qos )); +pr_info ("(%s) trying to get a CBR shortcut\n" , + client->dev->name); + }else +memset (&msg->qos,0 ,sizeof (struct atm_qos ));msg_to_mpoad (msg, client);return ; }
@@ -1126,15 +1172,17 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)dprintk ("mpoa: (%s) MPOA_res_reply_rcvd: ip %pI4\n" , mpc->dev->name, &dst_ip); -ddprintk ("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p" , mpc->dev->name, entry); -if (entry ==NULL ){ -printk ("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n" , mpc->dev->name); +ddprintk ("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p" , + mpc->dev->name, entry); +if (entry ==NULL ) { +pr_info ("(%s) ARGH, received res. reply for an entry that doesn't exist.\n" , + mpc->dev->name);return ; }ddprintk (" entry_state = %d " , entry->entry_state);if (entry->entry_state ==INGRESS_RESOLVED ) { -printk ("\nmpoa: (%s) MPOA_res_reply_rcvd for RESOLVED entry!\n" , mpc->dev->name); +pr_info ("(%s) RESOLVED entry!\n" , mpc->dev->name); mpc->in_ops->put (entry);return ; }
@@ -1145,15 +1193,16 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) entry->refresh_time =0 ;ddprintk ("entry->shortcut = %p\n" , entry->shortcut); -if (entry->entry_state ==INGRESS_RESOLVING && entry->shortcut !=NULL ){ +if (entry->entry_state ==INGRESS_RESOLVING && + entry->shortcut !=NULL ) { entry->entry_state =INGRESS_RESOLVED ; mpc->in_ops->put (entry);return ;/* Shortcut already open... */ }if (entry->shortcut !=NULL ) { -printk ("mpoa: (%s) MPOA_res_reply_rcvd: entry->shortcut != NULL, impossible!\n" , - mpc->dev->name); +pr_info ("(%s) entry->shortcut != NULL, impossible!\n" , + mpc->dev->name); mpc->in_ops->put (entry);return ; }
@@ -1172,9 +1221,9 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)__be32 mask = msg->ip_mask;in_cache_entry *entry = mpc->in_ops->get_with_mask (dst_ip, mpc, mask); -if (entry ==NULL ){ -printk ("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ip = %pI4\n" , - mpc->dev->name, &dst_ip); +if (entry ==NULL ) { +pr_info ("(%s) purge for a non-existing entry, ip = %pI4\n" , + mpc->dev->name, &dst_ip);return ; }
@@ -1197,7 +1246,8 @@ static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id (cache_id, mpc);if (entry ==NULL ) { -dprintk ("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n" , mpc->dev->name); +dprintk ("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n" , + mpc->dev->name);return ; }
@@ -1218,13 +1268,13 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry)dprintk ("mpoa: purge_egress_shortcut: entering\n" );if (vcc ==NULL ) { -printk ("mpoa: purge_egress_shortcut: vcc == NULL\n" ); +pr_info ("vcc == NULL\n" );return ; } skb =alloc_skb (sizeof (struct k_message ),GFP_ATOMIC );if (skb ==NULL ) { -printk ("mpoa: purge_egress_shortcut: out of memory\n" ); +pr_info ("out of memory\n" );return ; }
@@ -1249,14 +1299,14 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry)* Our MPS died. Tell our daemon to send NHRP data plane purge to each * of the egress shortcuts we have. */ -static void mps_death (struct k_message * msg,struct mpoa_client * mpc ) +static void mps_death (struct k_message *msg,struct mpoa_client *mpc) {eg_cache_entry *entry;dprintk ("mpoa: (%s) mps_death:\n" , mpc->dev->name); -if (memcmp (msg->MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN )){ -printk ("mpoa: (%s) mps_death: wrong MPS\n" , mpc->dev->name); +if (memcmp (msg->MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN )) { +pr_info ("(%s) wrong MPS\n" , mpc->dev->name);return ; }
@@ -1275,20 +1325,21 @@ static void mps_death( struct k_message * msg, struct mpoa_client * mpc )return ; } -static void MPOA_cache_impos_rcvd (struct k_message * msg,struct mpoa_client * mpc) +static void MPOA_cache_impos_rcvd (struct k_message *msg, +struct mpoa_client *mpc) {uint16_t holding_time;eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id (msg->content.eg_info.cache_id, mpc); holding_time = msg->content.eg_info.holding_time;dprintk ("mpoa: (%s) MPOA_cache_impos_rcvd: entry = %p, holding_time = %u\n" , - mpc->dev->name, entry, holding_time); -if (entry ==NULL && holding_time) { + mpc->dev->name, entry, holding_time); +if (entry ==NULL && holding_time) { entry = mpc->eg_ops->add_entry (msg, mpc); mpc->eg_ops->put (entry);return ; } -if (holding_time){ +if (holding_time) { mpc->eg_ops->update (entry, holding_time);return ; }
@@ -1302,7 +1353,8 @@ static void MPOA_cache_impos_rcvd( struct k_message * msg, struct mpoa_client *return ; } -static void set_mpc_ctrl_addr_rcvd (struct k_message *mesg,struct mpoa_client *mpc) +static void set_mpc_ctrl_addr_rcvd (struct k_message *mesg, +struct mpoa_client *mpc) {struct lec_priv *priv;int i, retval ;
@@ -1318,33 +1370,38 @@ static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mmemcpy (mpc->our_ctrl_addr, mesg->MPS_ctrl,ATM_ESA_LEN );dprintk ("mpoa: (%s) setting MPC ctrl ATM address to " , - (mpc->dev) ? mpc->dev->name :"<unknown>" ); + (mpc->dev) ? mpc->dev->name :"<unknown>" );for (i =7 ; i <sizeof (tlv); i++)dprintk ("%02x " , tlv[i]);dprintk ("\n" );if (mpc->dev) { priv =netdev_priv (mpc->dev); - retval = priv->lane2_ops->associate_req (mpc->dev, mpc->dev->dev_addr, tlv,sizeof (tlv)); + retval = priv->lane2_ops->associate_req (mpc->dev, + mpc->dev->dev_addr, + tlv,sizeof (tlv));if (retval ==0 ) -printk ("mpoa: (%s) MPOA device type TLV association failed\n" , mpc->dev->name); +pr_info ("(%s) MPOA device type TLV association failed\n" , + mpc->dev->name); retval = priv->lane2_ops->resolve (mpc->dev,NULL ,1 ,NULL ,NULL );if (retval <0 ) -printk ("mpoa: (%s) targetless LE_ARP request failed\n" , mpc->dev->name); +pr_info ("(%s) targetless LE_ARP request failed\n" , + mpc->dev->name); }return ; } -static void set_mps_mac_addr_rcvd (struct k_message *msg,struct mpoa_client *client) +static void set_mps_mac_addr_rcvd (struct k_message *msg, +struct mpoa_client *client) { -if (client->number_of_mps_macs) +if (client->number_of_mps_macs)kfree (client->mps_macs); client->number_of_mps_macs =0 ; client->mps_macs =kmemdup (msg->MPS_ctrl,ETH_ALEN ,GFP_KERNEL );if (client->mps_macs ==NULL ) { -printk ("mpoa: set_mps_mac_addr_rcvd: out of memory\n" ); +pr_info ("out of memory\n" );return ; } client->number_of_mps_macs =1 ;
@@ -1365,11 +1422,11 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action)/* FIXME: This knows too much of the cache structure */ read_lock_irq (&mpc->egress_lock); entry = mpc->eg_cache; -while (entry !=NULL ){ - msg->content.eg_info = entry->ctrl_info; -dprintk ("mpoa: cache_id %u\n" , entry->ctrl_info.cache_id); -msg_to_mpoad (msg, mpc); - entry = entry->next; +while (entry !=NULL ) { + msg->content.eg_info = entry->ctrl_info; +dprintk ("mpoa: cache_id %u\n" , entry->ctrl_info.cache_id); +msg_to_mpoad (msg, mpc); + entry = entry->next; }read_unlock_irq (&mpc->egress_lock);
@@ -1388,20 +1445,22 @@ static void mpc_timer_refresh(void)return ; } -static void mpc_cache_check (unsigned long checking_time ) +static void mpc_cache_check (unsigned long checking_time) {struct mpoa_client *mpc = mpcs;static unsigned long previous_resolving_check_time;static unsigned long previous_refresh_time; -while ( mpc !=NULL ){ +while (mpc !=NULL ) { mpc->in_ops->clear_count (mpc); mpc->eg_ops->clear_expired (mpc); -if (checking_time - previous_resolving_check_time > mpc->parameters.mpc_p4 *HZ ){ +if (checking_time - previous_resolving_check_time > + mpc->parameters.mpc_p4 *HZ ) { mpc->in_ops->check_resolving (mpc); previous_resolving_check_time = checking_time; } -if (checking_time - previous_refresh_time > mpc->parameters.mpc_p5 *HZ ){ +if (checking_time - previous_refresh_time > + mpc->parameters.mpc_p5 *HZ ) { mpc->in_ops->refresh (mpc); previous_refresh_time = checking_time; }
@@ -1412,7 +1471,8 @@ static void mpc_cache_check( unsigned long checking_time )return ; } -static int atm_mpoa_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) +static int atm_mpoa_ioctl (struct socket *sock,unsigned int cmd, +unsigned long arg) {int err =0 ;struct atm_vcc *vcc =ATM_SD (sock);
@@ -1424,21 +1484,20 @@ static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long areturn -EPERM ;switch (cmd) { -case ATMMPC_CTRL : - err =atm_mpoa_mpoad_attach (vcc, (int )arg); -if (err >=0 ) - sock->state =SS_CONNECTED ; -break ; -case ATMMPC_DATA : - err =atm_mpoa_vcc_attach (vcc, (void __user *)arg); -break ; -default : -break ; +case ATMMPC_CTRL : + err =atm_mpoa_mpoad_attach (vcc, (int )arg); +if (err >=0 ) + sock->state =SS_CONNECTED ; +break ; +case ATMMPC_DATA : + err =atm_mpoa_vcc_attach (vcc, (void __user *)arg); +break ; +default : +break ; }return err; } -static struct atm_ioctl atm_ioctl_ops = { .owner =THIS_MODULE , .ioctl = atm_mpoa_ioctl,
@@ -1451,7 +1510,7 @@ static __init int atm_mpoa_init(void)if (mpc_proc_init () !=0 )pr_info ("failed to initialize /proc/mpoa\n" ); -printk ("mpc.c: " __DATE__" " __TIME__" initialized\n" ); +pr_info ("mpc.c: " __DATE__" " __TIME__" initialized\n" );return 0 ; }
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 11/21 net/atm/mpoa_caches.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux... Add printk argument verification to dprintk and ddprintk Spacing cleanups
Mostly 80 column wrapped.
--- net/atm/mpoa_caches.c | 160 +++++++++++++++++++++++++++---------------------- 1 files changed, 88 insertions(+), 72 deletions(-)
net/atm/mpoa_caches.c +88 -72
@@ -11,15 +11,17 @@*/ #if 0 -#define dprintk printk/* debug */ +#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) /* debug */#else -#define dprintk(format,args...) +#define dprintk(format, args...) \ + do { if (0) printk(KERN_DEBUG format, ##args); } while (0)#endif #if 0 -#define ddprintk printk/* more debug */ +#define ddprintk printk(KERN_DEBUG format, ##args)/* more debug */ #else -#define ddprintk(format,args...) +#define ddprintk(format, args...) \ + do { if (0) printk(KERN_DEBUG format, ##args); } while (0)#endif static in_cache_entry *in_cache_get(__be32 dst_ip,
@@ -29,8 +31,8 @@ static in_cache_entry *in_cache_get(__be32 dst_ip,read_lock_bh (&client->ingress_lock); entry = client->in_cache; -while (entry !=NULL ){ -if ( entry->ctrl_info.in_dst_ip == dst_ip ){ +while (entry !=NULL ) { +if (entry->ctrl_info.in_dst_ip == dst_ip) {atomic_inc (&entry->use);read_unlock_bh (&client->ingress_lock);return entry;
@@ -50,8 +52,8 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip,read_lock_bh (&client->ingress_lock); entry = client->in_cache; -while (entry !=NULL ){ -if ((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask )){ +while (entry !=NULL ) { +if ((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask)) {atomic_inc (&entry->use);read_unlock_bh (&client->ingress_lock);return entry;
@@ -65,14 +67,14 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip, }static in_cache_entry *in_cache_get_by_vcc (struct atm_vcc *vcc, -struct mpoa_client *client ) +struct mpoa_client *client) {in_cache_entry *entry;read_lock_bh (&client->ingress_lock); entry = client->in_cache; -while (entry !=NULL ){ -if (entry->shortcut == vcc) { +while (entry !=NULL ) { +if (entry->shortcut == vcc) {atomic_inc (&entry->use);read_unlock_bh (&client->ingress_lock);return entry;
@@ -90,11 +92,12 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip,in_cache_entry *entry =kzalloc (sizeof (in_cache_entry),GFP_KERNEL );if (entry ==NULL ) { -printk ("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n" ); +pr_info ("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n" );return NULL ; } -dprintk ("mpoa: mpoa_caches.c: adding an ingress entry, ip = %pI4\n" , &dst_ip); +dprintk ("mpoa: mpoa_caches.c: adding an ingress entry, ip = %pI4\n" , + &dst_ip);atomic_set (&entry->use,1 );dprintk ("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n" );
@@ -126,39 +129,41 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc)struct k_message msg; entry->count++; -if (entry->entry_state ==INGRESS_RESOLVED && entry->shortcut !=NULL ) +if (entry->entry_state ==INGRESS_RESOLVED && entry->shortcut !=NULL )return OPEN ; -if (entry->entry_state ==INGRESS_REFRESHING ){ -if (entry->count > mpc->parameters.mpc_p1){ +if (entry->entry_state ==INGRESS_REFRESHING ) { +if (entry->count > mpc->parameters.mpc_p1) { msg.type =SND_MPOA_RES_RQST ; msg.content.in_info = entry->ctrl_info;memcpy (msg.MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN ); qos =atm_mpoa_search_qos (entry->ctrl_info.in_dst_ip); -if (qos !=NULL ) msg.qos = qos->qos; +if (qos !=NULL ) + msg.qos = qos->qos;msg_to_mpoad (&msg, mpc);do_gettimeofday (&(entry->reply_wait)); entry->entry_state =INGRESS_RESOLVING ; } -if (entry->shortcut !=NULL ) +if (entry->shortcut !=NULL )return OPEN ;return CLOSED ; } -if (entry->entry_state ==INGRESS_RESOLVING && entry->shortcut !=NULL ) +if (entry->entry_state ==INGRESS_RESOLVING && entry->shortcut !=NULL )return OPEN ; -if ( entry->count > mpc->parameters.mpc_p1 && - entry->entry_state ==INGRESS_INVALID ){ +if (entry->count > mpc->parameters.mpc_p1 && + entry->entry_state ==INGRESS_INVALID ) {dprintk ("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %pI4, sending MPOA res req\n" , mpc->dev->name, &entry->ctrl_info.in_dst_ip); entry->entry_state =INGRESS_RESOLVING ; - msg.type =SND_MPOA_RES_RQST ; -memcpy (msg.MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN ); + msg.type =SND_MPOA_RES_RQST ; +memcpy (msg.MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN ); msg.content.in_info = entry->ctrl_info; qos =atm_mpoa_search_qos (entry->ctrl_info.in_dst_ip); -if (qos !=NULL ) msg.qos = qos->qos; -msg_to_mpoad ( &msg, mpc); +if (qos !=NULL ) + msg.qos = qos->qos; +msg_to_mpoad (&msg, mpc);do_gettimeofday (&(entry->reply_wait)); }
@@ -195,14 +200,15 @@ static void in_cache_remove_entry(in_cache_entry *entry,if (entry->next !=NULL ) entry->next->prev = entry->prev; client->in_ops->put (entry); -if (client->in_cache ==NULL && client->eg_cache ==NULL ){ +if (client->in_cache ==NULL && client->eg_cache ==NULL ) { msg.type =STOP_KEEP_ALIVE_SM ; -msg_to_mpoad (&msg,client); +msg_to_mpoad (&msg, client); }/* Check if the egress side still uses this VCC */ if (vcc !=NULL ) { -eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc (vcc, client); +eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc (vcc, + client);if (eg_entry !=NULL ) { client->eg_ops->put (eg_entry);return ;
@@ -213,7 +219,6 @@ static void in_cache_remove_entry(in_cache_entry *entry,return ; } -/* Call this every MPC-p2 seconds... Not exactly correct solution, but an easy one... */ static void clear_count_and_expired (struct mpoa_client *client)
@@ -225,11 +230,11 @@ static void clear_count_and_expired(struct mpoa_client *client)write_lock_bh (&client->ingress_lock); entry = client->in_cache; -while (entry !=NULL ){ - entry->count=0 ; +while (entry !=NULL ) { + entry->count =0 ; next_entry = entry->next; -if ((now.tv_sec - entry->tv.tv_sec) - > entry->ctrl_info.holding_time){ +if ((now.tv_sec - entry->tv.tv_sec) + > entry->ctrl_info.holding_time) {dprintk ("mpoa: mpoa_caches.c: holding time expired, ip = %pI4\n" , &entry->ctrl_info.in_dst_ip); client->in_ops->remove_entry (entry, client);
@@ -250,33 +255,38 @@ static void check_resolving_entries(struct mpoa_client *client)struct timeval now;struct k_message msg; -do_gettimeofday ( &now ); +do_gettimeofday (&now);read_lock_bh (&client->ingress_lock); entry = client->in_cache; -while ( entry !=NULL ){ -if (entry->entry_state ==INGRESS_RESOLVING ){ -if (now.tv_sec - entry->hold_down.tv_sec < client->parameters.mpc_p6){ - entry = entry->next;/* Entry in hold down */ +while (entry !=NULL ) { +if (entry->entry_state ==INGRESS_RESOLVING ) { +if ((now.tv_sec - entry->hold_down.tv_sec) < + client->parameters.mpc_p6) { + entry = entry->next;/* Entry in hold down */ continue ; } -if ( (now.tv_sec - entry->reply_wait.tv_sec) > - entry->retry_time ){ - entry->retry_time =MPC_C1 *( entry->retry_time ); -if (entry->retry_time > client->parameters.mpc_p5){ -/* Retry time maximum exceeded, put entry in hold down. */ +if ((now.tv_sec - entry->reply_wait.tv_sec) > + entry->retry_time) { + entry->retry_time =MPC_C1 * (entry->retry_time); +/* +* Retry time maximum exceeded, +* put entry in hold down. +*/ +if (entry->retry_time > client->parameters.mpc_p5) {do_gettimeofday (&(entry->hold_down)); entry->retry_time = client->parameters.mpc_p4; entry = entry->next;continue ; }/* Ask daemon to send a resolution request. */ -memset (&(entry->hold_down),0 ,sizeof (struct timeval )); +memset (&(entry->hold_down),0 ,sizeof (struct timeval )); msg.type =SND_MPOA_RES_RTRY ;memcpy (msg.MPS_ctrl, client->mps_ctrl_addr,ATM_ESA_LEN ); msg.content.in_info = entry->ctrl_info; qos =atm_mpoa_search_qos (entry->ctrl_info.in_dst_ip); -if (qos !=NULL ) msg.qos = qos->qos; +if (qos !=NULL ) + msg.qos = qos->qos;msg_to_mpoad (&msg, client);do_gettimeofday (&(entry->reply_wait)); }
@@ -296,11 +306,12 @@ static void refresh_entries(struct mpoa_client *client)do_gettimeofday (&now);read_lock_bh (&client->ingress_lock); -while ( entry !=NULL ){ -if ( entry->entry_state ==INGRESS_RESOLVED ){ -if (!(entry->refresh_time)) - entry->refresh_time = (2 *(entry->ctrl_info.holding_time))/3 ; -if ( (now.tv_sec - entry->reply_wait.tv_sec) > entry->refresh_time ){ +while (entry !=NULL ) { +if (entry->entry_state ==INGRESS_RESOLVED ) { +if (!(entry->refresh_time)) + entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3 ; +if ((now.tv_sec - entry->reply_wait.tv_sec) > + entry->refresh_time) {dprintk ("mpoa: mpoa_caches.c: refreshing an entry.\n" ); entry->entry_state =INGRESS_REFRESHING ;
@@ -314,21 +325,22 @@ static void refresh_entries(struct mpoa_client *client)static void in_destroy_cache (struct mpoa_client *mpc) {write_lock_irq (&mpc->ingress_lock); -while (mpc->in_cache !=NULL ) +while (mpc->in_cache !=NULL ) mpc->in_ops->remove_entry (mpc->in_cache, mpc);write_unlock_irq (&mpc->ingress_lock);return ; } -static eg_cache_entry *eg_cache_get_by_cache_id (__be32 cache_id,struct mpoa_client *mpc) +static eg_cache_entry *eg_cache_get_by_cache_id (__be32 cache_id, +struct mpoa_client *mpc) {eg_cache_entry *entry;read_lock_irq (&mpc->egress_lock); entry = mpc->eg_cache; -while (entry !=NULL ){ -if (entry->ctrl_info.cache_id == cache_id){ +while (entry !=NULL ) { +if (entry->ctrl_info.cache_id == cache_id) {atomic_inc (&entry->use);read_unlock_irq (&mpc->egress_lock);return entry;
@@ -348,7 +360,7 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc)read_lock_irqsave (&mpc->egress_lock, flags); entry = mpc->eg_cache; -while (entry !=NULL ){ +while (entry !=NULL ) {if (entry->ctrl_info.tag == tag) {atomic_inc (&entry->use);read_unlock_irqrestore (&mpc->egress_lock, flags);
@@ -362,14 +374,15 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc) }/* This can be called from any context since it saves CPU flags */ -static eg_cache_entry *eg_cache_get_by_vcc (struct atm_vcc *vcc,struct mpoa_client *mpc) +static eg_cache_entry *eg_cache_get_by_vcc (struct atm_vcc *vcc, +struct mpoa_client *mpc) {unsigned long flags;eg_cache_entry *entry;read_lock_irqsave (&mpc->egress_lock, flags); entry = mpc->eg_cache; -while (entry !=NULL ){ +while (entry !=NULL ) {if (entry->shortcut == vcc) {atomic_inc (&entry->use);read_unlock_irqrestore (&mpc->egress_lock, flags);
@@ -382,14 +395,15 @@ static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_cliereturn NULL ; } -static eg_cache_entry *eg_cache_get_by_src_ip (__be32 ipaddr,struct mpoa_client *mpc) +static eg_cache_entry *eg_cache_get_by_src_ip (__be32 ipaddr, +struct mpoa_client *mpc) {eg_cache_entry *entry;read_lock_irq (&mpc->egress_lock); entry = mpc->eg_cache; -while (entry !=NULL ){ -if (entry->latest_ip_addr == ipaddr) { +while (entry !=NULL ) { +if (entry->latest_ip_addr == ipaddr) {atomic_inc (&entry->use);read_unlock_irq (&mpc->egress_lock);return entry;
@@ -429,9 +443,9 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,if (entry->next !=NULL ) entry->next->prev = entry->prev; client->eg_ops->put (entry); -if (client->in_cache ==NULL && client->eg_cache ==NULL ){ +if (client->in_cache ==NULL && client->eg_cache ==NULL ) { msg.type =STOP_KEEP_ALIVE_SM ; -msg_to_mpoad (&msg,client); +msg_to_mpoad (&msg, client); }/* Check if the ingress side still uses this VCC */
@@ -447,12 +461,13 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,return ; } -static eg_cache_entry *eg_cache_add_entry (struct k_message *msg,struct mpoa_client *client) +static eg_cache_entry *eg_cache_add_entry (struct k_message *msg, +struct mpoa_client *client) {eg_cache_entry *entry =kzalloc (sizeof (eg_cache_entry),GFP_KERNEL );if (entry ==NULL ) { -printk ("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n" ); +pr_info ("out of memory\n" );return NULL ; }
@@ -472,7 +487,8 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli entry->ctrl_info = msg->content.eg_info;do_gettimeofday (&(entry->tv)); entry->entry_state =EGRESS_RESOLVED ; -dprintk ("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n" ,ntohl (entry->ctrl_info.cache_id)); +dprintk ("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %u\n" , +ntohl (entry->ctrl_info.cache_id));dprintk ("mpoa: mpoa_caches.c: mps_ip = %pI4\n" , &entry->ctrl_info.mps_ip);atomic_inc (&entry->use);
@@ -483,7 +499,7 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_clireturn entry; } -static void update_eg_cache_entry (eg_cache_entry * entry,uint16_t holding_time) +static void update_eg_cache_entry (eg_cache_entry *entry,uint16_t holding_time) {do_gettimeofday (&(entry->tv)); entry->entry_state =EGRESS_RESOLVED ;
@@ -502,13 +518,14 @@ static void clear_expired(struct mpoa_client *client)write_lock_irq (&client->egress_lock); entry = client->eg_cache; -while (entry !=NULL ){ +while (entry !=NULL ) { next_entry = entry->next; -if ((now.tv_sec - entry->tv.tv_sec) - > entry->ctrl_info.holding_time){ +if ((now.tv_sec - entry->tv.tv_sec) + > entry->ctrl_info.holding_time) { msg.type =SND_EGRESS_PURGE ; msg.content.eg_info = entry->ctrl_info; -dprintk ("mpoa: mpoa_caches.c: egress_cache: holding time expired, cache_id = %lu.\n" ,ntohl (entry->ctrl_info.cache_id)); +dprintk ("mpoa: mpoa_caches.c: egress_cache: holding time expired, cache_id = %u.\n" , +ntohl (entry->ctrl_info.cache_id));msg_to_mpoad (&msg, client); client->eg_ops->remove_entry (entry, client); }
@@ -522,7 +539,7 @@ static void clear_expired(struct mpoa_client *client)static void eg_destroy_cache (struct mpoa_client *mpc) {write_lock_irq (&mpc->egress_lock); -while (mpc->eg_cache !=NULL ) +while (mpc->eg_cache !=NULL ) mpc->eg_ops->remove_entry (mpc->eg_cache, mpc);write_unlock_irq (&mpc->egress_lock);
@@ -530,7 +547,6 @@ static void eg_destroy_cache(struct mpoa_client *mpc) } -static struct in_cache_ops ingress_ops = { in_cache_add_entry,/* add_entry */ in_cache_get,/* get */
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 12/21 net/atm/mpoa_proc.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux... Add printk argument verification to dprintk and ddprintk Spacing cleanups
Mostly 80 column wrapped.
Removed unnecessary breaks after returns
Use %pI4 in seq_printf of IP address
--- net/atm/mpoa_proc.c | 64 ++++++++++++++++++++++++-------------------------- 1 files changed, 31 insertions(+), 33 deletions(-)
net/atm/mpoa_proc.c +31 -33
@@ -9,7 +9,7 @@#include <linux/proc_fs.h> #include <linux/time.h> #include <linux/seq_file.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/atmmpc.h> #include <linux/atm.h> #include "mpc.h"
@@ -21,9 +21,10 @@*/ #if 1 -#define dprintk printk/* debug */ +#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) /* debug */#else -#define dprintk(format,args...) +#define dprintk(format, args...) \ + do { if (0) printk(KERN_DEBUG format, ##args); } while (0)#endif #define STAT_FILE_NAME "mpc"/* Our statistic file's name */
@@ -52,42 +53,37 @@ static const struct file_operations mpc_file_operations = {/* * Returns the state of an ingress cache entry as a string */ -static const char *ingress_state_string (int state){ -switch (state) { +static const char *ingress_state_string (int state) +{ +switch (state) {case INGRESS_RESOLVING :return "resolving " ; -break ;case INGRESS_RESOLVED :return "resolved " ; -break ;case INGRESS_INVALID :return "invalid " ; -break ;case INGRESS_REFRESHING :return "refreshing " ; -break ; -default : -return "" ; } + +return "" ; }/* * Returns the state of an egress cache entry as a string */ -static const char *egress_state_string (int state){ -switch (state) { +static const char *egress_state_string (int state) +{ +switch (state) {case EGRESS_RESOLVED :return "resolved " ; -break ;case EGRESS_PURGE :return "purge " ; -break ;case EGRESS_INVALID :return "invalid " ; -break ; -default : -return "" ; } + +return "" ; }/*
@@ -124,7 +120,6 @@ static void mpc_stop(struct seq_file *m, void *v)static int mpc_show (struct seq_file *m,void *v) {struct mpoa_client *mpc = v; -unsigned char *temp;int i;in_cache_entry *in_entry;eg_cache_entry *eg_entry;
@@ -141,15 +136,17 @@ static int mpc_show(struct seq_file *m, void *v)do_gettimeofday (&now);for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) { - temp = (unsigned char *)&in_entry->ctrl_info.in_dst_ip; -sprintf (ip_string,"%d.%d.%d.%d" , temp[0 ], temp[1 ], temp[2 ], temp[3 ]); +sprintf (ip_string,"%pI4" , &in_entry->ctrl_info.in_dst_ip);seq_printf (m,"%-16s%s%-14lu%-12u" , - ip_string, -ingress_state_string (in_entry->entry_state), - in_entry->ctrl_info.holding_time-(now.tv_sec-in_entry->tv.tv_sec), - in_entry->packets_fwded); + ip_string, +ingress_state_string (in_entry->entry_state), + in_entry->ctrl_info.holding_time - + (now.tv_sec-in_entry->tv.tv_sec), + in_entry->packets_fwded);if (in_entry->shortcut) -seq_printf (m," %-3d %-3d" ,in_entry->shortcut->vpi,in_entry->shortcut->vci); +seq_printf (m," %-3d %-3d" , + in_entry->shortcut->vpi, + in_entry->shortcut->vci);seq_printf (m,"\n" ); }
@@ -157,21 +154,23 @@ static int mpc_show(struct seq_file *m, void *v)seq_printf (m,"Egress Entries:\nIngress MPC ATM addr\nCache-id State Holding time Packets recvd Latest IP addr VPI VCI\n" );for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr; -for (i =0 ; i <ATM_ESA_LEN ; i++) +for (i =0 ; i <ATM_ESA_LEN ; i++)seq_printf (m,"%02x" , p[i]);seq_printf (m,"\n%-16lu%s%-14lu%-15u" , (unsigned long )ntohl (eg_entry->ctrl_info.cache_id),egress_state_string (eg_entry->entry_state), - (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)), + (eg_entry->ctrl_info.holding_time - + (now.tv_sec-eg_entry->tv.tv_sec)), eg_entry->packets_rcvd);/* latest IP address */ - temp = (unsigned char *)&eg_entry->latest_ip_addr; -sprintf (ip_string,"%d.%d.%d.%d" , temp[0 ], temp[1 ], temp[2 ], temp[3 ]); +sprintf (ip_string,"%pI4" , &eg_entry->latest_ip_addr);seq_printf (m,"%-16s" , ip_string);if (eg_entry->shortcut) -seq_printf (m," %-3d %-3d" ,eg_entry->shortcut->vpi,eg_entry->shortcut->vci); +seq_printf (m," %-3d %-3d" , + eg_entry->shortcut->vpi, + eg_entry->shortcut->vci);seq_printf (m,"\n" ); }seq_printf (m,"\n" );
@@ -290,10 +289,9 @@ int mpc_proc_init(void)*/ void mpc_proc_clean (void ) { -remove_proc_entry (STAT_FILE_NAME ,atm_proc_root); +remove_proc_entry (STAT_FILE_NAME , atm_proc_root); } -#endif /* CONFIG_PROC_FS */
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 13/21 net/atm/pppoatm.c: checkpatch cleanups
In reply to Joe PerchesMove embedded assigns out of tests
Move trailing statements to new lines
Move labels to column 1
--- net/atm/pppoatm.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
net/atm/pppoatm.c +7 -4
@@ -176,7 +176,8 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb) }ppp_input (&pvcc->chan, skb);return ; - error: + +error:kfree_skb (skb);ppp_input_error (&pvcc->chan,0 ); }
@@ -209,7 +210,8 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) goto nospace; }kfree_skb (skb); -if ((skb = n) ==NULL ) + skb = n; +if (skb ==NULL )return DROP_PACKET ; }else if (!atm_may_send (pvcc->atmvcc, skb->truesize)) goto nospace;
@@ -231,7 +233,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev);return ATM_SKB (skb)->vcc->send (ATM_SKB (skb)->vcc, skb) ?DROP_PACKET :1 ; - nospace: +nospace:/* * We don't have space to send this SKB now, but we might have * already applied SC_COMP_PROT compression, so may need to undo
@@ -290,7 +292,8 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg) (be.encaps == e_vc ?0 :LLC_LEN ); pvcc->wakeup_tasklet = tasklet_proto; pvcc->wakeup_tasklet.data = (unsigned long ) &pvcc->chan; -if ((err =ppp_register_channel (&pvcc->chan)) !=0 ) { + err =ppp_register_channel (&pvcc->chan); +if (err !=0 ) {kfree (pvcc);return err; }
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 14/21 net/atm/proc.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux...
Mostly 80 column wrapped.
Spacing cleanups
Move trailing statements to new lines
switch/case cleanups
--- net/atm/proc.c | 81 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 44 insertions(+), 37 deletions(-)
net/atm/proc.c +44 -37
@@ -24,15 +24,15 @@#include <linux/init.h> /* for __init */ #include <net/net_namespace.h> #include <net/atmclip.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> +#include <linux/param.h> /* for HZ */ #include <asm/atomic.h> -#include <asm/param.h> /* for HZ */ #include "resources.h" #include "common.h" /* atm_proc_init prototype */ #include "signaling.h" /* to get sigd - ugly too */ -static ssize_t proc_dev_atm_read (struct file *file,char __user *buf,size_t count, -loff_t *pos); +static ssize_t proc_dev_atm_read (struct file *file,char __user *buf, +size_t count,loff_t *pos);static const struct file_operations proc_atm_dev_ops = { .owner =THIS_MODULE ,
@@ -43,9 +43,9 @@ static void add_stats(struct seq_file *seq, const char *aal, const struct k_atm_aal_stats *stats) {seq_printf (seq,"%s ( %d %d %d %d %d )" , aal, -atomic_read (&stats->tx),atomic_read (&stats->tx_err), -atomic_read (&stats->rx),atomic_read (&stats->rx_err), -atomic_read (&stats->rx_drop)); +atomic_read (&stats->tx),atomic_read (&stats->tx_err), +atomic_read (&stats->rx),atomic_read (&stats->rx_err), +atomic_read (&stats->rx_drop)); }static void atm_dev_info (struct seq_file *seq,const struct atm_dev *dev)
@@ -151,8 +151,8 @@ static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)static void pvc_info (struct seq_file *seq,struct atm_vcc *vcc) { -static const char *const class_name[] = - {"off" ,"UBR" ,"CBR" ,"VBR" ,"ABR" }; +static const char *const class_name[] = { +"off" ,"UBR" ,"CBR" ,"VBR" ,"ABR" };static const char *const aal_name[] = {"---" ,"1" ,"2" ,"3/4" ,/* 0- 3 */ "???" ,"5" ,"???" ,"???" ,/* 4- 7 */
@@ -160,11 +160,12 @@ static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) "???", "0", "???", "???"}; /* 12-15 */seq_printf (seq,"%3d %3d %5d %-3s %7d %-5s %7d %-6s" , - vcc->dev->number,vcc->vpi,vcc->vci, - vcc->qos.aal >=ARRAY_SIZE (aal_name) ?"err" : - aal_name[vcc->qos.aal],vcc->qos.rxtp.min_pcr, - class_name[vcc->qos.rxtp.traffic_class],vcc->qos.txtp.min_pcr, - class_name[vcc->qos.txtp.traffic_class]); + vcc->dev->number, vcc->vpi, vcc->vci, + vcc->qos.aal >=ARRAY_SIZE (aal_name) ?"err" : + aal_name[vcc->qos.aal], vcc->qos.rxtp.min_pcr, + class_name[vcc->qos.rxtp.traffic_class], + vcc->qos.txtp.min_pcr, + class_name[vcc->qos.txtp.traffic_class]);if (test_bit (ATM_VF_IS_CLIP , &vcc->flags)) {struct clip_vcc *clip_vcc =CLIP_VCC (vcc);struct net_device *dev;
@@ -195,19 +196,20 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc)seq_printf (seq,"%3d %3d %5d " , vcc->dev->number, vcc->vpi, vcc->vci);switch (sk->sk_family) { -case AF_ATMPVC : -seq_printf (seq,"PVC" ); -break ; -case AF_ATMSVC : -seq_printf (seq,"SVC" ); -break ; -default : -seq_printf (seq,"%3d" , sk->sk_family); +case AF_ATMPVC : +seq_printf (seq,"PVC" ); +break ; +case AF_ATMSVC : +seq_printf (seq,"SVC" ); +break ; +default : +seq_printf (seq,"%3d" , sk->sk_family); } -seq_printf (seq," %04lx %5d %7d/%7d %7d/%7d [%d]\n" , vcc->flags, sk->sk_err, -sk_wmem_alloc_get (sk), sk->sk_sndbuf, -sk_rmem_alloc_get (sk), sk->sk_rcvbuf, -atomic_read (&sk->sk_refcnt)); +seq_printf (seq," %04lx %5d %7d/%7d %7d/%7d [%d]\n" , + vcc->flags, sk->sk_err, +sk_wmem_alloc_get (sk), sk->sk_sndbuf, +sk_rmem_alloc_get (sk), sk->sk_rcvbuf, +atomic_read (&sk->sk_refcnt)); }static void svc_info (struct seq_file *seq,struct atm_vcc *vcc)
@@ -376,32 +378,35 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,unsigned long page;int length; -if (count ==0 )return 0 ; +if (count ==0 ) +return 0 ; page =get_zeroed_page (GFP_KERNEL ); -if (!page)return -ENOMEM ; +if (!page) +return -ENOMEM ; dev =PDE (file->f_path.dentry->d_inode)->data;if (!dev->ops->proc_read) length = -EINVAL ;else { - length = dev->ops->proc_read (dev,pos,(char *) page); -if (length > count) length = -EINVAL ; + length = dev->ops->proc_read (dev, pos, (char *)page); +if (length > count) + length = -EINVAL ; }if (length >=0 ) { -if (copy_to_user (buf,(char *) page,length)) length = -EFAULT ; +if (copy_to_user (buf, (char *)page, length)) + length = -EFAULT ; (*pos)++; }free_page (page);return length; } -struct proc_dir_entry *atm_proc_root;EXPORT_SYMBOL (atm_proc_root);int atm_proc_dev_register (struct atm_dev *dev) { -int digits,num; +int digits, num;int error;/* No proc info */
@@ -410,26 +415,28 @@ int atm_proc_dev_register(struct atm_dev *dev) error = -ENOMEM ; digits =0 ; -for (num = dev->number; num; num /=10 ) digits++; -if (!digits) digits++; +for (num = dev->number; num; num /=10 ) + digits++; +if (!digits) + digits++; dev->proc_name =kmalloc (strlen (dev->type) + digits +2 ,GFP_KERNEL );if (!dev->proc_name) goto err_out; -sprintf (dev->proc_name,"%s:%d" ,dev->type, dev->number); +sprintf (dev->proc_name,"%s:%d" , dev->type, dev->number); dev->proc_entry =proc_create_data (dev->proc_name,0 , atm_proc_root, &proc_atm_dev_ops, dev);if (!dev->proc_entry) goto err_free_name;return 0 ; + err_free_name:kfree (dev->proc_name); err_out:return error; } -void atm_proc_dev_deregister (struct atm_dev *dev) {if (!dev->ops->proc_read)
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 15/21 net/atm/pvc.c: checkpatch cleanups
In reply to Joe PerchesSpacing cleanups
Mostly 80 column wrapped.
Move trailing statements to new lines
--- net/atm/pvc.c | 43 +++++++++++++++++++++---------------------- 1 files changed, 21 insertions(+), 22 deletions(-)
net/atm/pvc.c +21 -22
@@ -17,32 +17,35 @@#include "common.h" /* common for PVCs and SVCs */ -static int pvc_shutdown (struct socket *sock,int how) +static int pvc_shutdown (struct socket *sock,int how) {return 0 ; } - -static int pvc_bind (struct socket *sock,struct sockaddr *sockaddr, -int sockaddr_len) +static int pvc_bind (struct socket *sock,struct sockaddr *sockaddr, +int sockaddr_len) {struct sock *sk = sock->sk;struct sockaddr_atmpvc *addr;struct atm_vcc *vcc;int error; -if (sockaddr_len !=sizeof (struct sockaddr_atmpvc ))return -EINVAL ; - addr = (struct sockaddr_atmpvc *) sockaddr; -if (addr->sap_family !=AF_ATMPVC )return -EAFNOSUPPORT ; +if (sockaddr_len !=sizeof (struct sockaddr_atmpvc )) +return -EINVAL ; + addr = (struct sockaddr_atmpvc *)sockaddr; +if (addr->sap_family !=AF_ATMPVC ) +return -EAFNOSUPPORT ;lock_sock (sk); vcc =ATM_SD (sock);if (!test_bit (ATM_VF_HASQOS , &vcc->flags)) { error = -EBADFD ; goto out; } -if (test_bit (ATM_VF_PARTIAL ,&vcc->flags)) { -if (vcc->vpi !=ATM_VPI_UNSPEC ) addr->sap_addr.vpi = vcc->vpi; -if (vcc->vci !=ATM_VCI_UNSPEC ) addr->sap_addr.vci = vcc->vci; +if (test_bit (ATM_VF_PARTIAL , &vcc->flags)) { +if (vcc->vpi !=ATM_VPI_UNSPEC ) + addr->sap_addr.vpi = vcc->vpi; +if (vcc->vci !=ATM_VCI_UNSPEC ) + addr->sap_addr.vci = vcc->vci; } error =vcc_connect (sock, addr->sap_addr.itf, addr->sap_addr.vpi, addr->sap_addr.vci);
@@ -51,11 +54,10 @@ out:return error; } - -static int pvc_connect (struct socket *sock,struct sockaddr *sockaddr, -int sockaddr_len,int flags) +static int pvc_connect (struct socket *sock,struct sockaddr *sockaddr, +int sockaddr_len,int flags) { -return pvc_bind (sock,sockaddr,sockaddr_len); +return pvc_bind (sock, sockaddr, sockaddr_len); } static int pvc_setsockopt(struct socket *sock, int level, int optname,
@@ -70,7 +72,6 @@ static int pvc_setsockopt(struct socket *sock, int level, int optname,return error; } -static int pvc_getsockopt (struct socket *sock,int level,int optname,char __user *optval,int __user *optlen) {
@@ -83,16 +84,16 @@ static int pvc_getsockopt(struct socket *sock, int level, int optname,return error; } - -static int pvc_getname (struct socket *sock,struct sockaddr *sockaddr, -int *sockaddr_len,int peer) +static int pvc_getname (struct socket *sock,struct sockaddr *sockaddr, +int *sockaddr_len,int peer) {struct sockaddr_atmpvc *addr;struct atm_vcc *vcc =ATM_SD (sock); -if (!vcc->dev || !test_bit (ATM_VF_ADDR ,&vcc->flags))return -ENOTCONN ; +if (!vcc->dev || !test_bit (ATM_VF_ADDR , &vcc->flags)) +return -ENOTCONN ; *sockaddr_len =sizeof (struct sockaddr_atmpvc ); - addr = (struct sockaddr_atmpvc *) sockaddr; + addr = (struct sockaddr_atmpvc *)sockaddr; addr->sap_family =AF_ATMPVC ; addr->sap_addr.itf = vcc->dev->number; addr->sap_addr.vpi = vcc->vpi;
@@ -100,7 +101,6 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,return 0 ; } -static const struct proto_ops pvc_proto_ops = { .family =PF_ATMPVC , .owner =THIS_MODULE ,
@@ -137,7 +137,6 @@ static int pvc_create(struct net *net, struct socket *sock, int protocol,return vcc_create (net, sock, protocol,PF_ATMPVC ); } -static const struct net_proto_family pvc_family_ops = { .family =PF_ATMPVC , .create = pvc_create,
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 16/21 net/atm/raw.c: checkpatch cleanups
In reply to Joe PerchesSpacing cleanups
Mostly 80 column wrapped.
--- net/atm/raw.c | 21 +++++++-------------- 1 files changed, 7 insertions(+), 14 deletions(-)
net/atm/raw.c +7 -14
@@ -18,7 +18,7 @@* SKB == NULL indicates that the link is being closed */ -static void atm_push_raw (struct atm_vcc *vcc,struct sk_buff *skb) +static void atm_push_raw (struct atm_vcc *vcc,struct sk_buff *skb) {if (skb) {struct sock *sk =sk_atm (vcc);
@@ -28,8 +28,7 @@ static void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb) } } - -static void atm_pop_raw (struct atm_vcc *vcc,struct sk_buff *skb) +static void atm_pop_raw (struct atm_vcc *vcc,struct sk_buff *skb) {struct sock *sk =sk_atm (vcc);
@@ -40,24 +39,22 @@ static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb) sk->sk_write_space (sk); } - -static int atm_send_aal0 (struct atm_vcc *vcc,struct sk_buff *skb) +static int atm_send_aal0 (struct atm_vcc *vcc,struct sk_buff *skb) {/* * Note that if vpi/vci are _ANY or _UNSPEC the below will * still work */ if (!capable (CAP_NET_ADMIN ) && - (((u32 *) skb->data)[0 ] & (ATM_HDR_VPI_MASK |ATM_HDR_VCI_MASK )) != - ((vcc->vpi <<ATM_HDR_VPI_SHIFT ) | (vcc->vci <<ATM_HDR_VCI_SHIFT ))) - { + (((u32 *)skb->data)[0 ] & (ATM_HDR_VPI_MASK |ATM_HDR_VCI_MASK )) != + ((vcc->vpi <<ATM_HDR_VPI_SHIFT ) | + (vcc->vci <<ATM_HDR_VCI_SHIFT ))) {kfree_skb (skb);return -EADDRNOTAVAIL ; } -return vcc->dev->ops->send (vcc,skb); +return vcc->dev->ops->send (vcc, skb); } -int atm_init_aal0 (struct atm_vcc *vcc) { vcc->push = atm_push_raw;
@@ -67,7 +64,6 @@ int atm_init_aal0(struct atm_vcc *vcc)return 0 ; } -int atm_init_aal34 (struct atm_vcc *vcc) { vcc->push = atm_push_raw;
@@ -77,7 +73,6 @@ int atm_init_aal34(struct atm_vcc *vcc)return 0 ; } -int atm_init_aal5 (struct atm_vcc *vcc) { vcc->push = atm_push_raw;
@@ -86,6 +81,4 @@ int atm_init_aal5(struct atm_vcc *vcc) vcc->send = vcc->dev->ops->send;return 0 ; } - -EXPORT_SYMBOL (atm_init_aal5);
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 17/21 net/atm/resources.c: checkpatch cleanups
In reply to Joe PerchesSpacing cleanups
Mostly 80 column wrapped.
Move embedded assigns out of tests
Move trailing statements to new lines
switch/case cleanups
--- net/atm/resources.c | 390 +++++++++++++++++++++++++-------------------------- 1 files changed, 192 insertions(+), 198 deletions(-)
net/atm/resources.c +192 -198
@@ -71,7 +71,7 @@ struct atm_dev *atm_dev_lookup(int number)mutex_unlock (&atm_dev_mutex);return dev; } - +EXPORT_SYMBOL (atm_dev_lookup);struct atm_dev *atm_dev_register (const char *type,const struct atmdev_ops *ops,int number,unsigned long *flags)
@@ -85,7 +85,8 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, }mutex_lock (&atm_dev_mutex);if (number !=-1 ) { -if ((inuse =__atm_dev_lookup (number))) { + inuse =__atm_dev_lookup (number); +if (inuse) {atm_dev_put (inuse);mutex_unlock (&atm_dev_mutex);kfree (dev);
@@ -130,7 +131,7 @@ out_fail: dev =NULL ; goto out; } - +EXPORT_SYMBOL (atm_dev_register);void atm_dev_deregister (struct atm_dev *dev) {
@@ -152,7 +153,7 @@ void atm_dev_deregister(struct atm_dev *dev)atm_dev_put (dev); } - +EXPORT_SYMBOL (atm_dev_deregister);static void copy_aal_stats (struct k_atm_aal_stats *from,struct atm_aal_stats *to)
@@ -162,7 +163,6 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,#undef __HANDLE_ITEM } -static void subtract_aal_stats (struct k_atm_aal_stats *from,struct atm_aal_stats *to) {
@@ -171,8 +171,8 @@ static void subtract_aal_stats(struct k_atm_aal_stats *from,#undef __HANDLE_ITEM } - -static int fetch_stats (struct atm_dev *dev,struct atm_dev_stats __user *arg,int zero) +static int fetch_stats (struct atm_dev *dev,struct atm_dev_stats __user *arg, +int zero) {struct atm_dev_stats tmp;int error =0 ;
@@ -190,7 +190,6 @@ static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, inreturn error ? -EFAULT :0 ; } -int atm_dev_ioctl (unsigned int cmd,void __user *arg,int compat) {void __user *buf;
@@ -206,50 +205,49 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)#endif switch (cmd) { -case ATM_GETNAMES : - -if (compat) { +case ATM_GETNAMES : +if (compat) {#ifdef CONFIG_COMPAT -struct compat_atm_iobuf __user *ciobuf = arg; -compat_uptr_t cbuf; - iobuf_len = &ciobuf->length; -if (get_user (cbuf, &ciobuf->buffer)) -return -EFAULT ; - buf =compat_ptr (cbuf); +struct compat_atm_iobuf __user *ciobuf = arg; +compat_uptr_t cbuf; + iobuf_len = &ciobuf->length; +if (get_user (cbuf, &ciobuf->buffer)) +return -EFAULT ; + buf =compat_ptr (cbuf);#endif - }else { -struct atm_iobuf __user *iobuf = arg; - iobuf_len = &iobuf->length; -if (get_user (buf, &iobuf->buffer)) -return -EFAULT ; - } -if (get_user (len, iobuf_len)) + }else { +struct atm_iobuf __user *iobuf = arg; + iobuf_len = &iobuf->length; +if (get_user (buf, &iobuf->buffer))return -EFAULT ; -mutex_lock (&atm_dev_mutex); -list_for_each (p, &atm_devs) - size +=sizeof (int ); -if (size > len) { -mutex_unlock (&atm_dev_mutex); -return -E2BIG ; - } - tmp_buf =kmalloc (size,GFP_ATOMIC ); -if (!tmp_buf) { -mutex_unlock (&atm_dev_mutex); -return -ENOMEM ; - } - tmp_p = tmp_buf; -list_for_each (p, &atm_devs) { - dev = list_entry(p, struct atm_dev, dev_list); - *tmp_p++ = dev->number; - } + } +if (get_user (len, iobuf_len)) +return -EFAULT ; +mutex_lock (&atm_dev_mutex); +list_for_each (p, &atm_devs) + size +=sizeof (int ); +if (size > len) {mutex_unlock (&atm_dev_mutex); - error = ((copy_to_user (buf, tmp_buf, size)) || -put_user (size, iobuf_len)) - ? -EFAULT :0 ; -kfree (tmp_buf); -return error; -default : -break ; +return -E2BIG ; + } + tmp_buf =kmalloc (size,GFP_ATOMIC ); +if (!tmp_buf) { +mutex_unlock (&atm_dev_mutex); +return -ENOMEM ; + } + tmp_p = tmp_buf; +list_for_each (p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); + *tmp_p++ = dev->number; + } +mutex_unlock (&atm_dev_mutex); + error = ((copy_to_user (buf, tmp_buf, size)) || +put_user (size, iobuf_len)) + ? -EFAULT :0 ; +kfree (tmp_buf); +return error; +default : +break ; }if (compat) {
@@ -278,166 +276,167 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)if (get_user (number, &sioc->number))return -EFAULT ; } -if (!(dev =try_then_request_module (atm_dev_lookup (number), -"atm-device-%d" , number))) + + dev =try_then_request_module (atm_dev_lookup (number),"atm-device-%d" , + number); +if (!dev)return -ENODEV ;switch (cmd) { -case ATM_GETTYPE : - size =strlen (dev->type) +1 ; -if (copy_to_user (buf, dev->type, size)) { - error = -EFAULT ; - goto done; - } -break ; -case ATM_GETESI : - size =ESI_LEN ; -if (copy_to_user (buf, dev->esi, size)) { - error = -EFAULT ; - goto done; - } -break ; -case ATM_SETESI : - { -int i; - -for (i =0 ; i <ESI_LEN ; i++) -if (dev->esi[i]) { - error = -EEXIST ; - goto done; - } - } -/* fall through */ -case ATM_SETESIF : - { -unsigned char esi[ESI_LEN ]; - -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } -if (copy_from_user (esi, buf,ESI_LEN )) { - error = -EFAULT ; - goto done; - } -memcpy (dev->esi, esi,ESI_LEN ); - error =ESI_LEN ; - goto done; - } -case ATM_GETSTATZ : -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } -/* fall through */ -case ATM_GETSTAT : - size =sizeof (struct atm_dev_stats ); - error =fetch_stats (dev, buf, cmd ==ATM_GETSTATZ ); -if (error) - goto done; -break ; -case ATM_GETCIRANGE : - size =sizeof (struct atm_cirange ); -if (copy_to_user (buf, &dev->ci_range, size)) { - error = -EFAULT ; - goto done; - } -break ; -case ATM_GETLINKRATE : - size =sizeof (int ); -if (copy_to_user (buf, &dev->link_rate, size)) { - error = -EFAULT ; - goto done; - } -break ; -case ATM_RSTADDR : -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } -atm_reset_addr (dev,ATM_ADDR_LOCAL ); -break ; -case ATM_ADDADDR : -case ATM_DELADDR : -case ATM_ADDLECSADDR : -case ATM_DELLECSADDR : -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } - { -struct sockaddr_atmsvc addr; - -if (copy_from_user (&addr, buf,sizeof (addr))) { - error = -EFAULT ; - goto done; - } -if (cmd ==ATM_ADDADDR || cmd ==ATM_ADDLECSADDR ) - error =atm_add_addr (dev, &addr, - (cmd ==ATM_ADDADDR ? -ATM_ADDR_LOCAL :ATM_ADDR_LECS )); -else - error =atm_del_addr (dev, &addr, - (cmd ==ATM_DELADDR ? -ATM_ADDR_LOCAL :ATM_ADDR_LECS )); +case ATM_GETTYPE : + size =strlen (dev->type) +1 ; +if (copy_to_user (buf, dev->type, size)) { + error = -EFAULT ; + goto done; + } +break ; +case ATM_GETESI : + size =ESI_LEN ; +if (copy_to_user (buf, dev->esi, size)) { + error = -EFAULT ; + goto done; + } +break ; +case ATM_SETESI : + { +int i; + +for (i =0 ; i <ESI_LEN ; i++) +if (dev->esi[i]) { + error = -EEXIST ; goto done; } -case ATM_GETADDR : -case ATM_GETLECSADDR : - error =atm_get_addr (dev, buf, len, - (cmd ==ATM_GETADDR ? + } +/* fall through */ +case ATM_SETESIF : + { +unsigned char esi[ESI_LEN ]; + +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; + goto done; + } +if (copy_from_user (esi, buf,ESI_LEN )) { + error = -EFAULT ; + goto done; + } +memcpy (dev->esi, esi,ESI_LEN ); + error =ESI_LEN ; + goto done; + } +case ATM_GETSTATZ : +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; + goto done; + } +/* fall through */ +case ATM_GETSTAT : + size =sizeof (struct atm_dev_stats ); + error =fetch_stats (dev, buf, cmd ==ATM_GETSTATZ ); +if (error) + goto done; +break ; +case ATM_GETCIRANGE : + size =sizeof (struct atm_cirange ); +if (copy_to_user (buf, &dev->ci_range, size)) { + error = -EFAULT ; + goto done; + } +break ; +case ATM_GETLINKRATE : + size =sizeof (int ); +if (copy_to_user (buf, &dev->link_rate, size)) { + error = -EFAULT ; + goto done; + } +break ; +case ATM_RSTADDR : +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; + goto done; + } +atm_reset_addr (dev,ATM_ADDR_LOCAL ); +break ; +case ATM_ADDADDR : +case ATM_DELADDR : +case ATM_ADDLECSADDR : +case ATM_DELLECSADDR : + { +struct sockaddr_atmsvc addr; + +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; + goto done; + } + +if (copy_from_user (&addr, buf,sizeof (addr))) { + error = -EFAULT ; + goto done; + } +if (cmd ==ATM_ADDADDR || cmd ==ATM_ADDLECSADDR ) + error =atm_add_addr (dev, &addr, + (cmd ==ATM_ADDADDR ?ATM_ADDR_LOCAL :ATM_ADDR_LECS )); -if (error <0 ) - goto done; - size = error; -/* may return 0, but later on size == 0 means "don't -write the length" */ - error =put_user (size, sioc_len) - ? -EFAULT :0 ; +else + error =atm_del_addr (dev, &addr, + (cmd ==ATM_DELADDR ? +ATM_ADDR_LOCAL :ATM_ADDR_LECS )); + goto done; + } +case ATM_GETADDR : +case ATM_GETLECSADDR : + error =atm_get_addr (dev, buf, len, + (cmd ==ATM_GETADDR ? +ATM_ADDR_LOCAL :ATM_ADDR_LECS )); +if (error <0 ) + goto done; + size = error; +/* may return 0, but later on size == 0 means "don't +write the length" */ + error =put_user (size, sioc_len) ? -EFAULT :0 ; + goto done; +case ATM_SETLOOP : +if (__ATM_LM_XTRMT ((int ) (unsigned long ) buf) && +__ATM_LM_XTLOC ((int ) (unsigned long ) buf) > +__ATM_LM_XTRMT ((int ) (unsigned long ) buf)) { + error = -EINVAL ; goto done; -case ATM_SETLOOP : -if (__ATM_LM_XTRMT ((int ) (unsigned long ) buf) && -__ATM_LM_XTLOC ((int ) (unsigned long ) buf) > -__ATM_LM_XTRMT ((int ) (unsigned long ) buf)) { + } +/* fall through */ +case ATM_SETCIRANGE : +case SONET_GETSTATZ : +case SONET_SETDIAG : +case SONET_CLRDIAG : +case SONET_SETFRAMING : +if (!capable (CAP_NET_ADMIN )) { + error = -EPERM ; + goto done; + } +/* fall through */ +default : +if (compat) { +#ifdef CONFIG_COMPAT +if (!dev->ops->compat_ioctl) { error = -EINVAL ; goto done; } -/* fall through */ -case ATM_SETCIRANGE : -case SONET_GETSTATZ : -case SONET_SETDIAG : -case SONET_CLRDIAG : -case SONET_SETFRAMING : -if (!capable (CAP_NET_ADMIN )) { - error = -EPERM ; - goto done; - } -/* fall through */ -default : -if (compat) { -#ifdef CONFIG_COMPAT -if (!dev->ops->compat_ioctl) { - error = -EINVAL ; - goto done; - } - size = dev->ops->compat_ioctl (dev, cmd, buf); + size = dev->ops->compat_ioctl (dev, cmd, buf);#endif - }else { -if (!dev->ops->ioctl) { - error = -EINVAL ; - goto done; - } - size = dev->ops->ioctl (dev, cmd, buf); - } -if (size <0 ) { - error = (size == -ENOIOCTLCMD ? -EINVAL : size); + }else { +if (!dev->ops->ioctl) { + error = -EINVAL ; goto done; } + size = dev->ops->ioctl (dev, cmd, buf); + } +if (size <0 ) { + error = (size == -ENOIOCTLCMD ? -EINVAL : size); + goto done; + } }if (size) - error =put_user (size, sioc_len) - ? -EFAULT :0 ; + error =put_user (size, sioc_len) ? -EFAULT :0 ;else error =0 ; done:
@@ -445,7 +444,7 @@ done:return error; } -static __inline__void *dev_get_idx (loff_t left) +static inline void *dev_get_idx (loff_t left) {struct list_head *p;
@@ -474,8 +473,3 @@ void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) ? atm_devs.next : ((struct list_head *)v)->next;return (v == &atm_devs) ?NULL : v; } - - -EXPORT_SYMBOL (atm_dev_register); -EXPORT_SYMBOL (atm_dev_deregister); -EXPORT_SYMBOL (atm_dev_lookup);
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 18/21 net/atm/signaling.c: checkpatch cleanups
In reply to Joe PerchesMostly 80 column wrapped.
Move embedded assigns out of tests
Move trailing statements to new lines
switch/case cleanups
--- net/atm/signaling.c | 202 +++++++++++++++++++++++++------------------------- 1 files changed, 101 insertions(+), 101 deletions(-)
net/atm/signaling.c +101 -101
@@ -18,7 +18,6 @@#include "resources.h" #include "signaling.h" -#undef WAIT_FOR_DEMON/* #define this if system calls on SVC sockets should block until the demon runs. Danger: may cause nasty hangs if the demon
@@ -29,20 +28,19 @@ struct atm_vcc *sigd = NULL;static DECLARE_WAIT_QUEUE_HEAD (sigd_sleep);#endif -static void sigd_put_skb (struct sk_buff *skb) {#ifdef WAIT_FOR_DEMON -DECLARE_WAITQUEUE (wait,current); +DECLARE_WAITQUEUE (wait, current); -add_wait_queue (&sigd_sleep,&wait); +add_wait_queue (&sigd_sleep, &wait);while (!sigd) {set_current_state (TASK_UNINTERRUPTIBLE );pr_debug ("atmsvc: waiting for signaling daemon...\n" );schedule (); } current->state =TASK_RUNNING ; -remove_wait_queue (&sigd_sleep,&wait); +remove_wait_queue (&sigd_sleep, &wait);#else if (!sigd) {pr_debug ("atmsvc: no signaling daemon\n" );
@@ -50,39 +48,39 @@ static void sigd_put_skb(struct sk_buff *skb)return ; }#endif -atm_force_charge (sigd,skb->truesize); -skb_queue_tail (&sk_atm (sigd)->sk_receive_queue,skb); +atm_force_charge (sigd, skb->truesize); +skb_queue_tail (&sk_atm (sigd)->sk_receive_queue, skb);sk_atm (sigd)->sk_data_ready (sk_atm (sigd), skb->len); } - -static void modify_qos (struct atm_vcc *vcc,struct atmsvc_msg *msg) +static void modify_qos (struct atm_vcc *vcc,struct atmsvc_msg *msg) {struct sk_buff *skb; -if (test_bit (ATM_VF_RELEASED ,&vcc->flags) || - !test_bit (ATM_VF_READY ,&vcc->flags)) +if (test_bit (ATM_VF_RELEASED , &vcc->flags) || + !test_bit (ATM_VF_READY , &vcc->flags))return ; msg->type = as_error; -if (!vcc->dev->ops->change_qos) msg->reply = -EOPNOTSUPP ; +if (!vcc->dev->ops->change_qos) + msg->reply = -EOPNOTSUPP ;else {/* should lock VCC */ - msg->reply = vcc->dev->ops->change_qos (vcc,&msg->qos, - msg->reply); -if (!msg->reply) msg->type = as_okay; + msg->reply = vcc->dev->ops->change_qos (vcc, &msg->qos, + msg->reply); +if (!msg->reply) + msg->type = as_okay; }/* * Should probably just turn around the old skb. But the, the buffer * space accounting needs to follow the change too. Maybe later. */ -while (!(skb =alloc_skb (sizeof (struct atmsvc_msg ),GFP_KERNEL ))) +while (!(skb =alloc_skb (sizeof (struct atmsvc_msg ),GFP_KERNEL )))schedule (); - *(struct atmsvc_msg *)skb_put (skb,sizeof (struct atmsvc_msg )) = *msg; + *(struct atmsvc_msg *)skb_put (skb,sizeof (struct atmsvc_msg )) = *msg;sigd_put_skb (skb); } - -static int sigd_send (struct atm_vcc *vcc,struct sk_buff *skb) +static int sigd_send (struct atm_vcc *vcc,struct sk_buff *skb) {struct atmsvc_msg *msg;struct atm_vcc *session_vcc;
@@ -95,63 +93,64 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) sk =sk_atm (vcc);switch (msg->type) { -case as_okay: - sk->sk_err = -msg->reply; -clear_bit (ATM_VF_WAITING , &vcc->flags); -if (!*vcc->local.sas_addr.prv && - !*vcc->local.sas_addr.pub) { - vcc->local.sas_family =AF_ATMSVC ; -memcpy (vcc->local.sas_addr.prv, - msg->local.sas_addr.prv,ATM_ESA_LEN ); -memcpy (vcc->local.sas_addr.pub, - msg->local.sas_addr.pub,ATM_E164_LEN +1 ); - } - session_vcc = vcc->session ? vcc->session : vcc; -if (session_vcc->vpi || session_vcc->vci)break ; - session_vcc->itf = msg->pvc.sap_addr.itf; - session_vcc->vpi = msg->pvc.sap_addr.vpi; - session_vcc->vci = msg->pvc.sap_addr.vci; -if (session_vcc->vpi || session_vcc->vci) - session_vcc->qos = msg->qos; -break ; -case as_error: -clear_bit (ATM_VF_REGIS ,&vcc->flags); -clear_bit (ATM_VF_READY ,&vcc->flags); - sk->sk_err = -msg->reply; -clear_bit (ATM_VF_WAITING , &vcc->flags); +case as_okay: + sk->sk_err = -msg->reply; +clear_bit (ATM_VF_WAITING , &vcc->flags); +if (!*vcc->local.sas_addr.prv && !*vcc->local.sas_addr.pub) { + vcc->local.sas_family =AF_ATMSVC ; +memcpy (vcc->local.sas_addr.prv, + msg->local.sas_addr.prv,ATM_ESA_LEN ); +memcpy (vcc->local.sas_addr.pub, + msg->local.sas_addr.pub,ATM_E164_LEN +1 ); + } + session_vcc = vcc->session ? vcc->session : vcc; +if (session_vcc->vpi || session_vcc->vci)break ; -case as_indicate: - vcc = *(struct atm_vcc **) &msg->listen_vcc; - sk =sk_atm (vcc); -pr_debug ("as_indicate!!!\n" ); -lock_sock (sk); -if (sk_acceptq_is_full (sk)) { -sigd_enq (NULL ,as_reject,vcc,NULL ,NULL ); -dev_kfree_skb (skb); - goto as_indicate_complete; - } - sk->sk_ack_backlog++; -skb_queue_tail (&sk->sk_receive_queue, skb); -pr_debug ("waking sk->sk_sleep 0x%p\n" , sk->sk_sleep); - sk->sk_state_change (sk); + session_vcc->itf = msg->pvc.sap_addr.itf; + session_vcc->vpi = msg->pvc.sap_addr.vpi; + session_vcc->vci = msg->pvc.sap_addr.vci; +if (session_vcc->vpi || session_vcc->vci) + session_vcc->qos = msg->qos; +break ; +case as_error: +clear_bit (ATM_VF_REGIS , &vcc->flags); +clear_bit (ATM_VF_READY , &vcc->flags); + sk->sk_err = -msg->reply; +clear_bit (ATM_VF_WAITING , &vcc->flags); +break ; +case as_indicate: + vcc = *(struct atm_vcc **)&msg->listen_vcc; + sk =sk_atm (vcc); +pr_debug ("as_indicate!!!\n" ); +lock_sock (sk); +if (sk_acceptq_is_full (sk)) { +sigd_enq (NULL , as_reject, vcc,NULL ,NULL ); +dev_kfree_skb (skb); + goto as_indicate_complete; + } + sk->sk_ack_backlog++; +skb_queue_tail (&sk->sk_receive_queue, skb); +pr_debug ("waking sk->sk_sleep 0x%p\n" , sk->sk_sleep); + sk->sk_state_change (sk); as_indicate_complete: -release_sock (sk); -return 0 ; -case as_close: -set_bit (ATM_VF_RELEASED ,&vcc->flags); -vcc_release_async (vcc, msg->reply); - goto out; -case as_modify: -modify_qos (vcc,msg); -break ; -case as_addparty: -case as_dropparty: - sk->sk_err_soft = msg->reply;/* < 0 failure, otherwise ep_ref */ -clear_bit (ATM_VF_WAITING , &vcc->flags); -break ; -default : -pr_alert ("bad message type %d\n" , (int )msg->type); -return -EINVAL ; +release_sock (sk); +return 0 ; +case as_close: +set_bit (ATM_VF_RELEASED , &vcc->flags); +vcc_release_async (vcc, msg->reply); + goto out; +case as_modify: +modify_qos (vcc, msg); +break ; +case as_addparty: +case as_dropparty: + sk->sk_err_soft = msg->reply; +/* < 0 failure, otherwise ep_ref */ +clear_bit (ATM_VF_WAITING , &vcc->flags); +break ; +default : +pr_alert ("bad message type %d\n" , (int )msg->type); +return -EINVAL ; } sk->sk_state_change (sk); out:
@@ -159,48 +158,52 @@ out:return 0 ; } - -void sigd_enq2 (struct atm_vcc *vcc,enum atmsvc_msg_type type, -struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, -const struct sockaddr_atmsvc *svc,const struct atm_qos *qos,int reply) +void sigd_enq2 (struct atm_vcc *vcc,enum atmsvc_msg_type type, +struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, +const struct sockaddr_atmsvc *svc,const struct atm_qos *qos, +int reply) {struct sk_buff *skb;struct atmsvc_msg *msg;static unsigned session =0 ;pr_debug ("%d (0x%p)\n" , (int )type, vcc); -while (!(skb =alloc_skb (sizeof (struct atmsvc_msg ),GFP_KERNEL ))) +while (!(skb =alloc_skb (sizeof (struct atmsvc_msg ),GFP_KERNEL )))schedule (); - msg = (struct atmsvc_msg *)skb_put (skb,sizeof (struct atmsvc_msg )); -memset (msg,0 ,sizeof (*msg)); + msg = (struct atmsvc_msg *)skb_put (skb,sizeof (struct atmsvc_msg )); +memset (msg,0 ,sizeof (*msg)); msg->type = type; *(struct atm_vcc **) &msg->vcc = vcc; *(struct atm_vcc **) &msg->listen_vcc = listen_vcc; msg->reply = reply; -if (qos) msg->qos = *qos; -if (vcc) msg->sap = vcc->sap; -if (svc) msg->svc = *svc; -if (vcc) msg->local = vcc->local; -if (pvc) msg->pvc = *pvc; +if (qos) + msg->qos = *qos; +if (vcc) + msg->sap = vcc->sap; +if (svc) + msg->svc = *svc; +if (vcc) + msg->local = vcc->local; +if (pvc) + msg->pvc = *pvc;if (vcc) {if (type == as_connect &&test_bit (ATM_VF_SESSION , &vcc->flags)) msg->session = ++session;/* every new pmp connect gets the next session number */ }sigd_put_skb (skb); -if (vcc)set_bit (ATM_VF_REGIS ,&vcc->flags); +if (vcc) +set_bit (ATM_VF_REGIS , &vcc->flags); } - -void sigd_enq (struct atm_vcc *vcc,enum atmsvc_msg_type type, -struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, -const struct sockaddr_atmsvc *svc) +void sigd_enq (struct atm_vcc *vcc,enum atmsvc_msg_type type, +struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, +const struct sockaddr_atmsvc *svc) { -sigd_enq2 (vcc,type,listen_vcc,pvc,svc,vcc ? &vcc->qos :NULL ,0 ); +sigd_enq2 (vcc, type, listen_vcc, pvc, svc, vcc ? &vcc->qos :NULL ,0 );/* other ISP applications may use "reply" */ } -static void purge_vcc (struct atm_vcc *vcc) { if (sk_atm(vcc)->sk_family == PF_ATMSVC &&
@@ -211,7 +214,6 @@ static void purge_vcc(struct atm_vcc *vcc) } } -static void sigd_close (struct atm_vcc *vcc) {struct hlist_node *node;
@@ -225,7 +227,7 @@ static void sigd_close(struct atm_vcc *vcc)skb_queue_purge (&sk_atm (vcc)->sk_receive_queue);read_lock (&vcc_sklist_lock); -for (i =0 ; i <VCC_HTABLE_SIZE ; ++i) { +for (i =0 ; i <VCC_HTABLE_SIZE ; ++i) {struct hlist_head *head = &vcc_hash[i];sk_for_each (s, node, head) {
@@ -237,13 +239,11 @@ static void sigd_close(struct atm_vcc *vcc)read_unlock (&vcc_sklist_lock); } -static struct atmdev_ops sigd_dev_ops = { .close = sigd_close, .send = sigd_send }; -static struct atm_dev sigd_dev = { .ops = &sigd_dev_ops, .type ="sig" ,
@@ -251,16 +251,16 @@ static struct atm_dev sigd_dev = { .lock = __SPIN_LOCK_UNLOCKED(sigd_dev.lock) }; -int sigd_attach (struct atm_vcc *vcc) { -if (sigd)return -EADDRINUSE ; +if (sigd) +return -EADDRINUSE ;pr_debug ("\n" ); sigd = vcc; vcc->dev = &sigd_dev;vcc_insert_socket (sk_atm (vcc)); -set_bit (ATM_VF_META ,&vcc->flags); -set_bit (ATM_VF_READY ,&vcc->flags); +set_bit (ATM_VF_META , &vcc->flags); +set_bit (ATM_VF_READY , &vcc->flags);#ifdef WAIT_FOR_DEMON wake_up (&sigd_sleep);#endif
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 19/21 net/atm/svc.c: checkpatch cleanups
In reply to Joe PerchesConvert #include <asm... to #include <linux...
Spacing cleanups
Mostly 80 column wrapped
Move trailing statements to new lines
switch/case cleanups
--- net/atm/svc.c | 249 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 125 insertions(+), 124 deletions(-)
net/atm/svc.c +125 -124
@@ -19,14 +19,15 @@#include <linux/atmdev.h> #include <linux/bitops.h> #include <net/sock.h> /* for sock_no_* */ -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include "resources.h" #include "common.h" /* common for PVCs and SVCs */ #include "signaling.h" #include "addr.h" -static int svc_create (struct net *net,struct socket *sock,int protocol,int kern); +static int svc_create (struct net *net,struct socket *sock,int protocol, +int kern);/* * Note: since all this is still nicely synchronized with the signaling demon,
@@ -35,25 +36,25 @@ static int svc_create(struct net *net, struct socket *sock, int protocol, int ke*/ -static int svc_shutdown (struct socket *sock,int how) +static int svc_shutdown (struct socket *sock,int how) {return 0 ; } -static void svc_disconnect (struct atm_vcc *vcc) {DEFINE_WAIT (wait);struct sk_buff *skb;struct sock *sk =sk_atm (vcc); -pr_debug ("%p\n" ,vcc); -if (test_bit (ATM_VF_REGIS ,&vcc->flags)) { +pr_debug ("%p\n" , vcc); +if (test_bit (ATM_VF_REGIS , &vcc->flags)) {prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); -sigd_enq (vcc,as_close,NULL ,NULL ,NULL ); -while (!test_bit (ATM_VF_RELEASED ,&vcc->flags) && sigd) { +sigd_enq (vcc, as_close,NULL ,NULL ,NULL ); +while (!test_bit (ATM_VF_RELEASED , &vcc->flags) && sigd) {schedule (); -prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); +prepare_to_wait (sk->sk_sleep, &wait, +TASK_UNINTERRUPTIBLE ); }finish_wait (sk->sk_sleep, &wait); }
@@ -62,35 +63,35 @@ static void svc_disconnect(struct atm_vcc *vcc)while ((skb =skb_dequeue (&sk->sk_receive_queue)) !=NULL ) {atm_return (vcc, skb->truesize);pr_debug ("LISTEN REL\n" ); -sigd_enq2 (NULL ,as_reject,vcc,NULL ,NULL ,&vcc->qos,0 ); +sigd_enq2 (NULL , as_reject, vcc,NULL ,NULL , &vcc->qos,0 );dev_kfree_skb (skb); }clear_bit (ATM_VF_REGIS , &vcc->flags);/* ... may retry later */ } -static int svc_release (struct socket *sock) {struct sock *sk = sock->sk;struct atm_vcc *vcc; -if (sk) { +if (sk) { vcc =ATM_SD (sock);pr_debug ("%p\n" , vcc);clear_bit (ATM_VF_READY , &vcc->flags); -/* VCC pointer is used as a reference, so we must not free it -(thereby subjecting it to re-use) before all pending connections -are closed */ +/* +* VCC pointer is used as a reference, +* so we must not free it (thereby subjecting it to re-use) +* before all pending connections are closed +*/ svc_disconnect (vcc);vcc_release (sock); }return 0 ; } - -static int svc_bind (struct socket *sock,struct sockaddr *sockaddr, -int sockaddr_len) +static int svc_bind (struct socket *sock,struct sockaddr *sockaddr, +int sockaddr_len) {DEFINE_WAIT (wait);struct sock *sk = sock->sk;
@@ -115,38 +116,37 @@ static int svc_bind(struct socket *sock,struct sockaddr *sockaddr, error = -EAFNOSUPPORT ; goto out; } -clear_bit (ATM_VF_BOUND ,&vcc->flags); +clear_bit (ATM_VF_BOUND , &vcc->flags);/* failing rebind will kill old binding */ /* @@@ check memory (de)allocation on rebind */ -if (!test_bit (ATM_VF_HASQOS ,&vcc->flags)) { +if (!test_bit (ATM_VF_HASQOS , &vcc->flags)) { error = -EBADFD ; goto out; } vcc->local = *addr;set_bit (ATM_VF_WAITING , &vcc->flags);prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); -sigd_enq (vcc,as_bind,NULL ,NULL ,&vcc->local); +sigd_enq (vcc, as_bind,NULL ,NULL , &vcc->local);while (test_bit (ATM_VF_WAITING , &vcc->flags) && sigd) {schedule ();prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); }finish_wait (sk->sk_sleep, &wait); -clear_bit (ATM_VF_REGIS ,&vcc->flags);/* doesn't count */ +clear_bit (ATM_VF_REGIS , &vcc->flags);/* doesn't count */ if (!sigd) { error = -EUNATCH ; goto out; }if (!sk->sk_err) -set_bit (ATM_VF_BOUND ,&vcc->flags); +set_bit (ATM_VF_BOUND , &vcc->flags); error = -sk->sk_err; out:release_sock (sk);return error; } - -static int svc_connect (struct socket *sock,struct sockaddr *sockaddr, -int sockaddr_len,int flags) +static int svc_connect (struct socket *sock,struct sockaddr *sockaddr, +int sockaddr_len,int flags) {DEFINE_WAIT (wait);struct sock *sk = sock->sk;
@@ -154,7 +154,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,struct atm_vcc *vcc =ATM_SD (sock);int error; -pr_debug ("%p\n" ,vcc); +pr_debug ("%p\n" , vcc);lock_sock (sk);if (sockaddr_len !=sizeof (struct sockaddr_atmsvc )) { error = -EINVAL ;
@@ -202,7 +202,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr, vcc->remote = *addr;set_bit (ATM_VF_WAITING , &vcc->flags);prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); -sigd_enq (vcc,as_connect,NULL ,NULL ,&vcc->remote); +sigd_enq (vcc, as_connect,NULL ,NULL , &vcc->remote);if (flags &O_NONBLOCK ) {finish_wait (sk->sk_sleep, &wait); sock->state =SS_CONNECTING ;
@@ -213,7 +213,8 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,while (test_bit (ATM_VF_WAITING , &vcc->flags) && sigd) {schedule ();if (!signal_pending (current)) { -prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (sk->sk_sleep, &wait, +TASK_INTERRUPTIBLE );continue ; }pr_debug ("*ABORT*\n" );
@@ -229,20 +230,22 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,* Kernel <--okay---- Demon * Kernel <--close--- Demon */ -sigd_enq (vcc,as_close,NULL ,NULL ,NULL ); +sigd_enq (vcc, as_close,NULL ,NULL ,NULL );while (test_bit (ATM_VF_WAITING , &vcc->flags) && sigd) { -prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (sk->sk_sleep, &wait, +TASK_INTERRUPTIBLE );schedule (); }if (!sk->sk_err) -while (!test_bit (ATM_VF_RELEASED ,&vcc->flags) - && sigd) { -prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); +while (!test_bit (ATM_VF_RELEASED , &vcc->flags) && + sigd) { +prepare_to_wait (sk->sk_sleep, &wait, +TASK_INTERRUPTIBLE );schedule (); } -clear_bit (ATM_VF_REGIS ,&vcc->flags); -clear_bit (ATM_VF_RELEASED ,&vcc->flags); -clear_bit (ATM_VF_CLOSE ,&vcc->flags); +clear_bit (ATM_VF_REGIS , &vcc->flags); +clear_bit (ATM_VF_RELEASED , &vcc->flags); +clear_bit (ATM_VF_CLOSE , &vcc->flags);/* we're gone now but may connect later */ error = -EINTR ;break ;
@@ -270,17 +273,17 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,/* * #endif */ -if (!(error =vcc_connect (sock, vcc->itf, vcc->vpi, vcc->vci))) + error =vcc_connect (sock, vcc->itf, vcc->vpi, vcc->vci); +if (!error) sock->state =SS_CONNECTED ;else - (void )svc_disconnect (vcc); + (void )svc_disconnect (vcc); out:release_sock (sk);return error; } - -static int svc_listen (struct socket *sock,int backlog) +static int svc_listen (struct socket *sock,int backlog) {DEFINE_WAIT (wait);struct sock *sk = sock->sk;
@@ -290,17 +293,17 @@ static int svc_listen(struct socket *sock,int backlog)pr_debug ("%p\n" , vcc);lock_sock (sk);/* let server handle listen on unbound sockets */ -if (test_bit (ATM_VF_SESSION ,&vcc->flags)) { +if (test_bit (ATM_VF_SESSION , &vcc->flags)) { error = -EINVAL ; goto out; }if (test_bit (ATM_VF_LISTEN , &vcc->flags)) { error = -EADDRINUSE ; goto out; - } + }set_bit (ATM_VF_WAITING , &vcc->flags);prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); -sigd_enq (vcc,as_listen,NULL ,NULL ,&vcc->local); +sigd_enq (vcc, as_listen,NULL ,NULL , &vcc->local);while (test_bit (ATM_VF_WAITING , &vcc->flags) && sigd) {schedule ();prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE );
@@ -310,7 +313,7 @@ static int svc_listen(struct socket *sock,int backlog) error = -EUNATCH ; goto out; } -set_bit (ATM_VF_LISTEN ,&vcc->flags); +set_bit (ATM_VF_LISTEN , &vcc->flags);vcc_insert_socket (sk); sk->sk_max_ack_backlog = backlog >0 ? backlog :ATM_BACKLOG_DEFAULT ; error = -sk->sk_err;
@@ -319,8 +322,7 @@ out:return error; } - -static int svc_accept (struct socket *sock,struct socket *newsock,int flags) +static int svc_accept (struct socket *sock,struct socket *newsock,int flags) {struct sock *sk = sock->sk;struct sk_buff *skb;
@@ -344,8 +346,9 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags)prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE );while (!(skb =skb_dequeue (&sk->sk_receive_queue)) && sigd) { -if (test_bit (ATM_VF_RELEASED ,&old_vcc->flags))break ; -if (test_bit (ATM_VF_CLOSE ,&old_vcc->flags)) { +if (test_bit (ATM_VF_RELEASED , &old_vcc->flags)) +break ; +if (test_bit (ATM_VF_CLOSE , &old_vcc->flags)) { error = -sk->sk_err;break ; }
@@ -360,7 +363,8 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) error = -ERESTARTSYS ;break ; } -prepare_to_wait (sk->sk_sleep, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (sk->sk_sleep, &wait, +TASK_INTERRUPTIBLE ); }finish_wait (sk->sk_sleep, &wait);if (error)
@@ -369,31 +373,34 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) error = -EUNATCH ; goto out; } - msg = (struct atmsvc_msg *) skb->data; + msg = (struct atmsvc_msg *)skb->data; new_vcc->qos = msg->qos; -set_bit (ATM_VF_HASQOS ,&new_vcc->flags); +set_bit (ATM_VF_HASQOS , &new_vcc->flags); new_vcc->remote = msg->svc; new_vcc->local = msg->local; new_vcc->sap = msg->sap; error =vcc_connect (newsock, msg->pvc.sap_addr.itf, - msg->pvc.sap_addr.vpi, msg->pvc.sap_addr.vci); + msg->pvc.sap_addr.vpi, + msg->pvc.sap_addr.vci);dev_kfree_skb (skb); sk->sk_ack_backlog--;if (error) { -sigd_enq2 (NULL ,as_reject,old_vcc,NULL ,NULL , - &old_vcc->qos,error); +sigd_enq2 (NULL , as_reject, old_vcc,NULL ,NULL , + &old_vcc->qos, error); error = error == -EAGAIN ? -EBUSY : error; goto out; }/* wait should be short, so we ignore the non-blocking flag */ set_bit (ATM_VF_WAITING , &new_vcc->flags); -prepare_to_wait (sk_atm (new_vcc)->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); -sigd_enq (new_vcc,as_accept,old_vcc,NULL ,NULL ); +prepare_to_wait (sk_atm (new_vcc)->sk_sleep, &wait, +TASK_UNINTERRUPTIBLE ); +sigd_enq (new_vcc, as_accept, old_vcc,NULL ,NULL );while (test_bit (ATM_VF_WAITING , &new_vcc->flags) && sigd) {release_sock (sk);schedule ();lock_sock (sk); -prepare_to_wait (sk_atm (new_vcc)->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); +prepare_to_wait (sk_atm (new_vcc)->sk_sleep, &wait, +TASK_UNINTERRUPTIBLE ); }finish_wait (sk_atm (new_vcc)->sk_sleep, &wait);if (!sigd) {
@@ -413,39 +420,37 @@ out:return error; } - -static int svc_getname (struct socket *sock,struct sockaddr *sockaddr, -int *sockaddr_len,int peer) +static int svc_getname (struct socket *sock,struct sockaddr *sockaddr, +int *sockaddr_len,int peer) {struct sockaddr_atmsvc *addr; *sockaddr_len =sizeof (struct sockaddr_atmsvc ); addr = (struct sockaddr_atmsvc *) sockaddr; -memcpy (addr,peer ? &ATM_SD (sock)->remote : &ATM_SD (sock)->local, -sizeof (struct sockaddr_atmsvc )); +memcpy (addr, peer ? &ATM_SD (sock)->remote : &ATM_SD (sock)->local, +sizeof (struct sockaddr_atmsvc ));return 0 ; } - -int svc_change_qos (struct atm_vcc *vcc,struct atm_qos *qos) +int svc_change_qos (struct atm_vcc *vcc,struct atm_qos *qos) {struct sock *sk =sk_atm (vcc);DEFINE_WAIT (wait);set_bit (ATM_VF_WAITING , &vcc->flags);prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); -sigd_enq2 (vcc,as_modify,NULL ,NULL ,&vcc->local,qos,0 ); +sigd_enq2 (vcc, as_modify,NULL ,NULL , &vcc->local, qos,0 );while (test_bit (ATM_VF_WAITING , &vcc->flags) && !test_bit (ATM_VF_RELEASED , &vcc->flags) && sigd) {schedule ();prepare_to_wait (sk->sk_sleep, &wait,TASK_UNINTERRUPTIBLE ); }finish_wait (sk->sk_sleep, &wait); -if (!sigd)return -EUNATCH ; +if (!sigd) +return -EUNATCH ;return -sk->sk_err; } -static int svc_setsockopt (struct socket *sock,int level,int optname,char __user *optval,unsigned int optlen) {
@@ -455,37 +460,35 @@ static int svc_setsockopt(struct socket *sock, int level, int optname,lock_sock (sk);switch (optname) { -case SO_ATMSAP : -if (level !=SOL_ATM || optlen !=sizeof (struct atm_sap )) { - error = -EINVAL ; - goto out; - } -if (copy_from_user (&vcc->sap, optval, optlen)) { - error = -EFAULT ; - goto out; - } -set_bit (ATM_VF_HASSAP , &vcc->flags); -break ; -case SO_MULTIPOINT : -if (level !=SOL_ATM || optlen !=sizeof (int )) { - error = -EINVAL ; - goto out; - } -if (get_user (value, (int __user *) optval)) { - error = -EFAULT ; - goto out; - } -if (value ==1 ) { -set_bit (ATM_VF_SESSION , &vcc->flags); - }else if (value ==0 ) { -clear_bit (ATM_VF_SESSION , &vcc->flags); - }else { - error = -EINVAL ; - } -break ; -default : - error =vcc_setsockopt (sock, level, optname, - optval, optlen); +case SO_ATMSAP : +if (level !=SOL_ATM || optlen !=sizeof (struct atm_sap )) { + error = -EINVAL ; + goto out; + } +if (copy_from_user (&vcc->sap, optval, optlen)) { + error = -EFAULT ; + goto out; + } +set_bit (ATM_VF_HASSAP , &vcc->flags); +break ; +case SO_MULTIPOINT : +if (level !=SOL_ATM || optlen !=sizeof (int )) { + error = -EINVAL ; + goto out; + } +if (get_user (value, (int __user *)optval)) { + error = -EFAULT ; + goto out; + } +if (value ==1 ) +set_bit (ATM_VF_SESSION , &vcc->flags); +else if (value ==0 ) +clear_bit (ATM_VF_SESSION , &vcc->flags); +else + error = -EINVAL ; +break ; +default : + error =vcc_setsockopt (sock, level, optname, optval, optlen); } out:
@@ -493,9 +496,8 @@ out:return error; } - -static int svc_getsockopt (struct socket *sock,int level,int optname, -char __user *optval,int __user *optlen) +static int svc_getsockopt (struct socket *sock,int level,int optname, +char __user *optval,int __user *optlen) {struct sock *sk = sock->sk;int error =0 , len;
@@ -522,7 +524,6 @@ out:return error; } -static int svc_addparty (struct socket *sock,struct sockaddr *sockaddr,int sockaddr_len,int flags) {
@@ -553,7 +554,6 @@ out:return error; } -static int svc_dropparty (struct socket *sock,int ep_ref) {DEFINE_WAIT (wait);
@@ -580,7 +580,6 @@ out:return error; } -static int svc_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {int error, ep_ref;
@@ -588,29 +587,31 @@ static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)struct atm_vcc *vcc =ATM_SD (sock);switch (cmd) { -case ATM_ADDPARTY : -if (!test_bit (ATM_VF_SESSION , &vcc->flags)) -return -EINVAL ; -if (copy_from_user (&sa, (void __user *) arg,sizeof (sa))) -return -EFAULT ; - error =svc_addparty (sock, (struct sockaddr *) &sa,sizeof (sa),0 ); -break ; -case ATM_DROPPARTY : -if (!test_bit (ATM_VF_SESSION , &vcc->flags)) -return -EINVAL ; -if (copy_from_user (&ep_ref, (void __user *) arg,sizeof (int ))) -return -EFAULT ; - error =svc_dropparty (sock, ep_ref); -break ; -default : - error =vcc_ioctl (sock, cmd, arg); +case ATM_ADDPARTY : +if (!test_bit (ATM_VF_SESSION , &vcc->flags)) +return -EINVAL ; +if (copy_from_user (&sa, (void __user *) arg,sizeof (sa))) +return -EFAULT ; + error =svc_addparty (sock, (struct sockaddr *)&sa,sizeof (sa), +0 ); +break ; +case ATM_DROPPARTY : +if (!test_bit (ATM_VF_SESSION , &vcc->flags)) +return -EINVAL ; +if (copy_from_user (&ep_ref, (void __user *) arg,sizeof (int ))) +return -EFAULT ; + error =svc_dropparty (sock, ep_ref); +break ; +default : + error =vcc_ioctl (sock, cmd, arg); }return error; }#ifdef CONFIG_COMPAT -static int svc_compat_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) +static int svc_compat_ioctl (struct socket *sock,unsigned int cmd, +unsigned long arg) {/* The definition of ATM_ADDPARTY uses the size of struct atm_iobuf. But actually it takes a struct sockaddr_atmsvc, which doesn't need
@@ -661,13 +662,13 @@ static int svc_create(struct net *net, struct socket *sock, int protocol, sock->ops = &svc_proto_ops; error =vcc_create (net, sock, protocol,AF_ATMSVC ); -if (error)return error; +if (error) +return error;ATM_SD (sock)->local.sas_family =AF_ATMSVC ;ATM_SD (sock)->remote.sas_family =AF_ATMSVC ;return 0 ; } -static const struct net_proto_family svc_family_ops = { .family =PF_ATMSVC , .create = svc_create,
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 20/21 net/atm/lec.c: Add __lec_arp_check_expire and other cleanups
In reply to Joe PerchesReduce indentation in lec_arp_check_expire
Indent a case label
Remove != NULL logical tests from while ((skb = foo())) assign and tests
--- net/atm/lec.c | 153 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 80 insertions(+), 73 deletions(-)
net/atm/lec.c +80 -73
@@ -285,7 +285,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,/* Make sure we have room for lec_id */ if (skb_headroom (skb) <2 ) { -pr_debug ("reallocating skb\n" ); skb2 =skb_realloc_headroom (skb,LEC_HEADER_LEN );kfree_skb (skb);
@@ -508,34 +507,31 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)break ;case l_should_bridge:#if defined(CONFIG_BRIDGE ) || defined(CONFIG_BRIDGE_MODULE ) - { -pr_debug ("%s: bridge zeppelin asks about %pM\n" , - dev->name, mesg->content.proxy.mac_addr); + { +pr_debug ("%s: bridge zeppelin asks about %pM\n" , + dev->name, mesg->content.proxy.mac_addr); -if (br_fdb_test_addr_hook ==NULL ) -break ; +if (br_fdb_test_addr_hook ==NULL ) +break ; -if (br_fdb_test_addr_hook (dev, - mesg->content.proxy.mac_addr)) { -/* hit from bridge table, send LE_ARP_RESPONSE */ -struct sk_buff *skb2; -struct sock *sk; - -pr_debug ("%s: entry found, responding to zeppelin\n" , - dev->name); - skb2 =alloc_skb (sizeof (struct atmlec_msg ), -GFP_ATOMIC ); -if (skb2 ==NULL ) -break ; - skb2->len =sizeof (struct atmlec_msg ); -skb_copy_to_linear_data (skb2, mesg, -sizeof (*mesg)); -atm_force_charge (priv->lecd, skb2->truesize); - sk =sk_atm (priv->lecd); -skb_queue_tail (&sk->sk_receive_queue, skb2); - sk->sk_data_ready (sk, skb2->len); - } +if (br_fdb_test_addr_hook (dev, mesg->content.proxy.mac_addr)) { +/* hit from bridge table, send LE_ARP_RESPONSE */ +struct sk_buff *skb2; +struct sock *sk; + +pr_debug ("%s: entry found, responding to zeppelin\n" , + dev->name); + skb2 =alloc_skb (sizeof (struct atmlec_msg ),GFP_ATOMIC ); +if (skb2 ==NULL ) +break ; + skb2->len =sizeof (struct atmlec_msg ); +skb_copy_to_linear_data (skb2, mesg,sizeof (*mesg)); +atm_force_charge (priv->lecd, skb2->truesize); + sk =sk_atm (priv->lecd); +skb_queue_tail (&sk->sk_receive_queue, skb2); + sk->sk_data_ready (sk, skb2->len); } + }#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ break ;default :
@@ -561,7 +557,7 @@ static void lec_atm_close(struct atm_vcc *vcc)if (skb_peek (&sk_atm (vcc)->sk_receive_queue))pr_info ("%s closing with messages pending\n" , dev->name); -while ((skb =skb_dequeue (&sk_atm (vcc)->sk_receive_queue)) !=NULL ) { +while ((skb =skb_dequeue (&sk_atm (vcc)->sk_receive_queue))) {atm_return (vcc, skb->truesize);dev_kfree_skb (skb); }
@@ -1748,6 +1744,50 @@ static void lec_arp_expire_vcc(unsigned long data)lec_arp_put (to_remove); } +static bool __lec_arp_check_expire (struct lec_arp_table *entry, +unsigned long now, +struct lec_priv *priv) +{ +unsigned long time_to_check; + +if ((entry->flags) &LEC_REMOTE_FLAG && priv->topology_change) + time_to_check = priv->forward_delay_time; +else + time_to_check = priv->aging_time; + +pr_debug ("About to expire: %lx - %lx > %lx\n" , + now, entry->last_used, time_to_check); +if (time_after (now, entry->last_used + time_to_check) && + !(entry->flags &LEC_PERMANENT_FLAG ) && + !(entry->mac_addr[0 ] &0x01 )) {/* LANE2: 7.1.20 */ +/* Remove entry */ +pr_debug ("Entry timed out\n" ); +lec_arp_remove (priv, entry); +lec_arp_put (entry); + }else { +/* Something else */ +if ((entry->status ==ESI_VC_PENDING || + entry->status ==ESI_ARP_PENDING ) && +time_after_eq (now, entry->timestamp + + priv->max_unknown_frame_time)) { + entry->timestamp = jiffies; + entry->packets_flooded =0 ; +if (entry->status ==ESI_VC_PENDING ) +send_to_lecd (priv, l_svc_setup, + entry->mac_addr, + entry->atm_addr, +NULL ); + } +if (entry->status ==ESI_FLUSH_PENDING && +time_after_eq (now, entry->timestamp + + priv->path_switching_delay)) { +lec_arp_hold (entry); +return true; + } + } + +return false; +}/* * Expire entries. * 1. Re-set timer
@@ -1772,7 +1812,6 @@ static void lec_arp_check_expire(struct work_struct *work)struct hlist_node *node, *next;struct lec_arp_table *entry;unsigned long now; -unsigned long time_to_check;int i;pr_debug ("%p\n" , priv);
@@ -1782,51 +1821,19 @@ restart:for (i =0 ; i <LEC_ARP_TABLE_SIZE ; i++) {hlist_for_each_entry_safe (entry, node, next, &priv->lec_arp_tables[i], next) { -if ((entry->flags) &LEC_REMOTE_FLAG && - priv->topology_change) - time_to_check = priv->forward_delay_time; -else - time_to_check = priv->aging_time; - -pr_debug ("About to expire: %lx - %lx > %lx\n" , - now, entry->last_used, time_to_check); -if (time_after (now, entry->last_used + time_to_check) && - !(entry->flags &LEC_PERMANENT_FLAG ) && - !(entry->mac_addr[0 ] &0x01 )) {/* LANE2: 7.1.20 */ -/* Remove entry */ -pr_debug ("Entry timed out\n" ); -lec_arp_remove (priv, entry); +if (__lec_arp_check_expire (entry, now, priv)) { +struct sk_buff *skb; +struct atm_vcc *vcc = entry->vcc; + +spin_unlock_irqrestore (&priv->lec_arp_lock, + flags); +while ((skb =skb_dequeue (&entry->tx_wait))) +lec_send (vcc, skb); + entry->last_used = jiffies; + entry->status =ESI_FORWARD_DIRECT ;lec_arp_put (entry); - }else { -/* Something else */ -if ((entry->status ==ESI_VC_PENDING || - entry->status ==ESI_ARP_PENDING ) && -time_after_eq (now, - entry->timestamp + - priv->max_unknown_frame_time)) { - entry->timestamp = jiffies; - entry->packets_flooded =0 ; -if (entry->status ==ESI_VC_PENDING ) -send_to_lecd (priv, l_svc_setup, - entry->mac_addr, - entry->atm_addr, -NULL ); - } -if (entry->status ==ESI_FLUSH_PENDING && -time_after_eq (now, entry->timestamp + - priv->path_switching_delay)) { -struct sk_buff *skb; -struct atm_vcc *vcc = entry->vcc; - -lec_arp_hold (entry); -spin_unlock_irqrestore (&priv->lec_arp_lock, flags); -while ((skb =skb_dequeue (&entry->tx_wait)) !=NULL ) -lec_send (vcc, skb); - entry->last_used = jiffies; - entry->status =ESI_FORWARD_DIRECT ; -lec_arp_put (entry); - goto restart; - } + + goto restart; } } }
@@ -2237,7 +2244,7 @@ restart:lec_arp_hold (entry);spin_unlock_irqrestore (&priv->lec_arp_lock, flags); -while ((skb =skb_dequeue (&entry->tx_wait)) !=NULL ) +while ((skb =skb_dequeue (&entry->tx_wait)))lec_send (vcc, skb); entry->last_used = jiffies; entry->status =ESI_FORWARD_DIRECT ;
Signature · 1 line
1.6.6.rc0.57.gad7a
PATCH 21/21 net/atm: Cleanup dprint/ddprintk #defines and uses
In reply to Joe PerchesMove "mpoa:%s: ", __func__/__FILE__ to #defines
Remove mpoa __func__/__FILE__ from dprintk uses
Add and use #define dprint_cont where appropriate
--- net/atm/mpc.c | 153 +++++++++++++++++++++++++------------------------ net/atm/mpoa_caches.c | 50 +++++++++------- net/atm/mpoa_proc.c | 28 ++++++--- 3 files changed, 124 insertions(+), 107 deletions(-)
net/atm/mpc.c +78 -75
@@ -38,21 +38,31 @@*/ #if 0 -#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) /* debug */ +#define dprintk(format, args...) \ + printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) +#define dprintk_cont(format, args...) printk(KERN_CONT format, ##args)#else -#define dprintk(format, args...) \ - do { if (0) printk(KERN_DEBUG format, ##args); } while (0) +#define dprintk(format, args...) \ + do { if (0) \ + printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ + } while (0) +#define dprintk_cont(format, args...) \ + do { if (0) printk(KERN_CONT format, ##args); } while (0)#endif #if 0 -#define ddprintk printk(KERN_DEBUG format, ##args)/* more debug */ +#define ddprintk(format, args...) \ + printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) +#define ddprintk_cont(format, args...) printk(KERN_CONT format, ##args)#else -#define ddprintk(format, args...) \ - do { if (0) printk(KERN_DEBUG format, ##args); } while (0) +#define ddprintk(format, args...) \ + do { if (0) \ + printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ + } while (0) +#define ddprintk_cont(format, args...) \ + do { if (0) printk(KERN_CONT format, ##args); } while (0)#endif - -#define MPOA_TAG_LEN 4/* mpc_daemon -> kernel */
@@ -302,7 +312,7 @@ static struct mpoa_client *alloc_mpc(void)static void start_mpc (struct mpoa_client *mpc,struct net_device *dev) { -dprintk ("mpoa: (%s) start_mpc:\n" , mpc->dev->name); +dprintk ("(%s)\n" , mpc->dev->name);if (!dev->netdev_ops)pr_info ("(%s) not starting\n" , dev->name);else {
@@ -316,14 +326,14 @@ static void start_mpc(struct mpoa_client *mpc, struct net_device *dev)static void stop_mpc (struct mpoa_client *mpc) {struct net_device *dev = mpc->dev; -dprintk ("mpoa: (%s) stop_mpc:" , mpc->dev->name); +dprintk ("(%s)" , mpc->dev->name);/* Lets not nullify lec device's dev->hard_start_xmit */ if (dev->netdev_ops != &mpc->new_ops) { -dprintk (" mpc already stopped, not fatal\n" ); +dprintk_cont (" mpc already stopped, not fatal\n" );return ; } -dprintk ("\n" ); +dprintk_cont ("\n" ); dev->netdev_ops = mpc->old_ops; mpc->old_ops =NULL ;
@@ -371,7 +381,7 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr,struct mpoa_client *mpc; mpoa_device_type = number_of_mps_macs =0 ;/* silence gcc */ -dprintk ("mpoa: (%s) lane2_assoc_ind: received TLV(s), " , dev->name); +dprintk ("(%s) received TLV(s), " , dev->name);dprintk ("total length of all TLVs %d\n" , sizeoftlvs); mpc =find_mpc_by_lec (dev);/* Sampo-Fix: moved here from below */ if (mpc ==NULL ) {
@@ -402,7 +412,7 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, } mpoa_device_type = *tlvs++; number_of_mps_macs = *tlvs++; -dprintk ("mpoa: (%s) MPOA device type '%s', " , +dprintk ("(%s) MPOA device type '%s', " , dev->name,mpoa_device_type_string (mpoa_device_type));if (mpoa_device_type ==MPS_AND_MPC && length < (42 + number_of_mps_macs*ETH_ALEN )) {/* :) */
@@ -417,7 +427,7 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, }if (mpoa_device_type !=MPS && mpoa_device_type !=MPS_AND_MPC ) { -dprintk ("ignoring non-MPS device\n" ); +dprintk ("ignoring non-MPS device " );if (mpoa_device_type ==MPC ) tlvs +=20 ;continue ;/* we are only interested in MPSs */
@@ -427,7 +437,8 @@ static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr,pr_info ("(%s) MPS_AND_MPC has zero MACs\n" , dev->name);continue ;/* someone should read the spec */ } -dprintk ("this MPS has %d MAC addresses\n" , number_of_mps_macs); +dprintk_cont ("this MPS has %d MAC addresses\n" , + number_of_mps_macs);/* * ok, now we can go and tell our daemon
@@ -498,7 +509,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) iph = (struct iphdr *)buff; ipaddr = iph->daddr; -ddprintk ("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n" , +ddprintk ("(%s) ipaddr 0x%x\n" , mpc->dev->name, ipaddr); entry = mpc->in_ops->get (ipaddr, mpc);
@@ -510,17 +521,17 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) }/* threshold not exceeded or VCC not ready */ if (mpc->in_ops->cache_hit (entry, mpc) !=OPEN ) { -ddprintk ("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n" , +ddprintk ("(%s) cache_hit: returns != OPEN\n" , mpc->dev->name); mpc->in_ops->put (entry);return 1 ; } -ddprintk ("mpoa: (%s) send_via_shortcut: using shortcut\n" , +ddprintk ("(%s) using shortcut\n" , mpc->dev->name);/* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ if (iph->ttl <=1 ) { -ddprintk ("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n" , +ddprintk ("(%s) IP ttl = %u, using LANE\n" , mpc->dev->name, iph->ttl); mpc->in_ops->put (entry);return 1 ;
@@ -530,7 +541,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) iph->check =ip_fast_csum ((unsigned char *)iph, iph->ihl);if (entry->ctrl_info.tag !=0 ) { -ddprintk ("mpoa: (%s) send_via_shortcut: adding tag 0x%x\n" , +ddprintk ("(%s) adding tag 0x%x\n" , mpc->dev->name, entry->ctrl_info.tag); tagged_llc_snap_hdr.tag = entry->ctrl_info.tag;skb_pull (skb,ETH_HLEN );/* get rid of Eth header */
@@ -655,25 +666,23 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev)return ; } -dprintk ("mpoa: (%s) mpc_vcc_close:\n" , dev->name); +dprintk ("(%s)\n" , dev->name); in_entry = mpc->in_ops->get_by_vcc (vcc, mpc);if (in_entry) { -dprintk ("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %pI4\n" , +dprintk ("(%s) ingress SVC closed ip = %pI4\n" , mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); in_entry->shortcut =NULL ; mpc->in_ops->put (in_entry); } eg_entry = mpc->eg_ops->get_by_vcc (vcc, mpc);if (eg_entry) { -dprintk ("mpoa: (%s) mpc_vcc_close: egress SVC closed\n" , - mpc->dev->name); +dprintk ("(%s) egress SVC closed\n" , mpc->dev->name); eg_entry->shortcut =NULL ; mpc->eg_ops->put (eg_entry); }if (in_entry ==NULL && eg_entry ==NULL ) -dprintk ("mpoa: (%s) mpc_vcc_close: unused vcc closed\n" , - dev->name); +dprintk ("(%s) unused vcc closed\n" , dev->name);return ; }
@@ -687,10 +696,9 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)__be32 tag;char *tmp; -ddprintk ("mpoa: (%s) mpc_push:\n" , dev->name); +ddprintk ("(%s)\n" , dev->name);if (skb ==NULL ) { -dprintk ("mpoa: (%s) mpc_push: null skb, closing VCC\n" , - dev->name); +dprintk ("(%s) null skb, closing VCC\n" , dev->name);mpc_vcc_close (vcc, dev);return ; }
@@ -700,8 +708,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) sizeof(struct llc_snap_hdr)) == 0) {struct sock *sk =sk_atm (vcc); -dprintk ("mpoa: (%s) mpc_push: control packet arrived\n" , - dev->name); +dprintk ("(%s) control packet arrived\n" , dev->name);/* Pass control packets to daemon */ skb_queue_tail (&sk->sk_receive_queue, skb); sk->sk_data_ready (sk, skb->len);
@@ -719,8 +726,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)if (memcmp (skb->data, &llc_snap_mpoa_data_tagged,sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA tagged data */ -ddprintk ("mpoa: (%s) mpc_push: tagged data packet arrived\n" , - dev->name); +ddprintk ("(%s) tagged data packet arrived\n" , dev->name); }else if (memcmp (skb->data, &llc_snap_mpoa_data,sizeof (struct llc_snap_hdr )) ==0 ) {/* MPOA data */
@@ -813,8 +819,7 @@ static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg) mpc =find_mpc_by_itfnum (arg);if (mpc ==NULL ) { -dprintk ("mpoa: mpoad_attach: allocating new mpc for itf %d\n" , - arg); +dprintk ("allocating new mpc for itf %d\n" , arg); mpc =alloc_mpc ();if (mpc ==NULL )return -ENOMEM ;
@@ -923,55 +928,54 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb)pr_info ("no mpc found\n" );return 0 ; } -dprintk ("mpoa: (%s) msg_from_mpoad:" , - (mpc->dev) ? mpc->dev->name :"<unknown>" ); +dprintk ("(%s)" , mpc->dev ? mpc->dev->name :"<unknown>" );switch (mesg->type) {case MPOA_RES_REPLY_RCVD : -dprintk (" mpoa_res_reply_rcvd\n" ); +dprintk_cont ("mpoa_res_reply_rcvd\n" );MPOA_res_reply_rcvd (mesg, mpc);break ;case MPOA_TRIGGER_RCVD : -dprintk (" mpoa_trigger_rcvd\n" ); +dprintk_cont ("mpoa_trigger_rcvd\n" );MPOA_trigger_rcvd (mesg, mpc);break ;case INGRESS_PURGE_RCVD : -dprintk (" nhrp_purge_rcvd\n" ); +dprintk_cont ("nhrp_purge_rcvd\n" );ingress_purge_rcvd (mesg, mpc);break ;case EGRESS_PURGE_RCVD : -dprintk (" egress_purge_reply_rcvd\n" ); +dprintk_cont ("egress_purge_reply_rcvd\n" );egress_purge_rcvd (mesg, mpc);break ;case MPS_DEATH : -dprintk (" mps_death\n" ); +dprintk_cont ("mps_death\n" );mps_death (mesg, mpc);break ;case CACHE_IMPOS_RCVD : -dprintk (" cache_impos_rcvd\n" ); +dprintk_cont ("cache_impos_rcvd\n" );MPOA_cache_impos_rcvd (mesg, mpc);break ;case SET_MPC_CTRL_ADDR : -dprintk (" set_mpc_ctrl_addr\n" ); +dprintk_cont ("set_mpc_ctrl_addr\n" );set_mpc_ctrl_addr_rcvd (mesg, mpc);break ;case SET_MPS_MAC_ADDR : -dprintk (" set_mps_mac_addr\n" ); +dprintk_cont ("set_mps_mac_addr\n" );set_mps_mac_addr_rcvd (mesg, mpc);break ;case CLEAN_UP_AND_EXIT : -dprintk (" clean_up_and_exit\n" ); +dprintk_cont ("clean_up_and_exit\n" );clean_up (mesg, mpc,DIE );break ;case RELOAD : -dprintk (" reload\n" ); +dprintk_cont ("reload\n" );clean_up (mesg, mpc,RELOAD );break ;case SET_MPC_PARAMS : -dprintk (" set_mpc_params\n" ); +dprintk_cont ("set_mpc_params\n" ); mpc->parameters = mesg->content.params;break ;default : -dprintk (" unknown message %d\n" , mesg->type); +dprintk_cont ("unknown message %d\n" , mesg->type);break ; }kfree_skb (skb);
@@ -1027,8 +1031,7 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, priv->lane2_ops->associate_indicator = lane2_assoc_ind; mpc =find_mpc_by_itfnum (priv->itfnum);if (mpc ==NULL ) { -dprintk ("mpoa: mpoa_event_listener: allocating new mpc for %s\n" , - dev->name); +dprintk ("allocating new mpc for %s\n" , dev->name); mpc =alloc_mpc ();if (mpc ==NULL ) {pr_info ("no new mpc" );
@@ -1038,14 +1041,14 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, mpc->dev_num = priv->itfnum; mpc->dev = dev;dev_hold (dev); -dprintk ("mpoa: (%s) was initialized\n" , dev->name); +dprintk ("(%s) was initialized\n" , dev->name);break ;case NETDEV_UNREGISTER :/* the lec device was deallocated */ mpc =find_mpc_by_lec (dev);if (mpc ==NULL )break ; -dprintk ("mpoa: device (%s) was deallocated\n" , dev->name); +dprintk ("device (%s) was deallocated\n" , dev->name);stop_mpc (mpc);dev_put (mpc->dev); mpc->dev =NULL ;
@@ -1143,7 +1146,7 @@ static void check_qos_and_open_shortcut(struct k_message *msg, entry->shortcut = eg_entry->shortcut; }if (entry->shortcut) { -dprintk ("mpoa: (%s) using egress SVC to reach %pI4\n" , +dprintk ("(%s) using egress SVC to reach %pI4\n" , client->dev->name, &dst_ip); client->eg_ops->put (eg_entry);return ;
@@ -1170,16 +1173,16 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)__be32 dst_ip = msg->content.in_info.in_dst_ip;in_cache_entry *entry = mpc->in_ops->get (dst_ip, mpc); -dprintk ("mpoa: (%s) MPOA_res_reply_rcvd: ip %pI4\n" , +dprintk ("(%s) ip %pI4\n" , mpc->dev->name, &dst_ip); -ddprintk ("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p" , +ddprintk ("(%s) entry = %p" , mpc->dev->name, entry);if (entry ==NULL ) {pr_info ("(%s) ARGH, received res. reply for an entry that doesn't exist.\n" , mpc->dev->name);return ; } -ddprintk (" entry_state = %d " , entry->entry_state); +ddprintk_cont (" entry_state = %d " , entry->entry_state);if (entry->entry_state ==INGRESS_RESOLVED ) {pr_info ("(%s) RESOLVED entry!\n" , mpc->dev->name);
@@ -1191,7 +1194,7 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)do_gettimeofday (&(entry->tv));do_gettimeofday (&(entry->reply_wait));/* Used in refreshing func from now on */ entry->refresh_time =0 ; -ddprintk ("entry->shortcut = %p\n" , entry->shortcut); +ddprintk_cont ("entry->shortcut = %p\n" , entry->shortcut);if (entry->entry_state ==INGRESS_RESOLVING && entry->shortcut !=NULL ) {
@@ -1228,7 +1231,7 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) } do { - dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %pI4\n", + dprintk("(%s) removing an ingress entry, ip = %pI4\n", mpc->dev->name, &dst_ip); write_lock_bh(&mpc->ingress_lock); mpc->in_ops->remove_entry(entry, mpc);
@@ -1246,7 +1249,7 @@ static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id (cache_id, mpc);if (entry ==NULL ) { -dprintk ("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n" , +dprintk ("(%s) purge for a non-existing entry\n" , mpc->dev->name);return ; }
@@ -1266,7 +1269,7 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry)struct k_message *purge_msg;struct sk_buff *skb; -dprintk ("mpoa: purge_egress_shortcut: entering\n" ); +dprintk ("entering\n" );if (vcc ==NULL ) {pr_info ("vcc == NULL\n" );return ;
@@ -1290,7 +1293,7 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) sk =sk_atm (vcc);skb_queue_tail (&sk->sk_receive_queue, skb); sk->sk_data_ready (sk, skb->len); -dprintk ("mpoa: purge_egress_shortcut: exiting:\n" ); +dprintk ("exiting\n" );return ; }
@@ -1303,7 +1306,7 @@ static void mps_death(struct k_message *msg, struct mpoa_client *mpc) {eg_cache_entry *entry; -dprintk ("mpoa: (%s) mps_death:\n" , mpc->dev->name); +dprintk ("(%s)\n" , mpc->dev->name);if (memcmp (msg->MPS_ctrl, mpc->mps_ctrl_addr,ATM_ESA_LEN )) {pr_info ("(%s) wrong MPS\n" , mpc->dev->name);
@@ -1332,7 +1335,7 @@ static void MPOA_cache_impos_rcvd(struct k_message *msg,eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id (msg->content.eg_info.cache_id, mpc); holding_time = msg->content.eg_info.holding_time; -dprintk ("mpoa: (%s) MPOA_cache_impos_rcvd: entry = %p, holding_time = %u\n" , +dprintk ("(%s) entry = %p, holding_time = %u\n" , mpc->dev->name, entry, holding_time);if (entry ==NULL && holding_time) { entry = mpc->eg_ops->add_entry (msg, mpc);
@@ -1369,11 +1372,11 @@ static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg,memcpy (&tlv[7 ], mesg->MPS_ctrl,ATM_ESA_LEN );/* MPC ctrl ATM addr */ memcpy (mpc->our_ctrl_addr, mesg->MPS_ctrl,ATM_ESA_LEN ); -dprintk ("mpoa: (%s) setting MPC ctrl ATM address to " , - (mpc->dev) ? mpc->dev->name :"<unknown>" ); +dprintk ("(%s) setting MPC ctrl ATM address to" , + mpc->dev ? mpc->dev->name :"<unknown>" );for (i =7 ; i <sizeof (tlv); i++) -dprintk ("%02x " , tlv[i]); -dprintk ("\n" ); +dprintk_cont (" %02x" , tlv[i]); +dprintk_cont ("\n" );if (mpc->dev) { priv =netdev_priv (mpc->dev);
@@ -1424,7 +1427,7 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action) entry = mpc->eg_cache;while (entry !=NULL ) { msg->content.eg_info = entry->ctrl_info; -dprintk ("mpoa: cache_id %u\n" , entry->ctrl_info.cache_id); +dprintk ("cache_id %u\n" , entry->ctrl_info.cache_id);msg_to_mpoad (msg, mpc); entry = entry->next; }
@@ -1537,15 +1540,15 @@ static void __exit atm_mpoa_cleanup(void)if (priv->lane2_ops !=NULL ) priv->lane2_ops->associate_indicator =NULL ; } -ddprintk ("mpoa: cleanup_module: about to clear caches\n" ); +ddprintk ("about to clear caches\n" ); mpc->in_ops->destroy_cache (mpc); mpc->eg_ops->destroy_cache (mpc); -ddprintk ("mpoa: cleanup_module: caches cleared\n" ); +ddprintk ("caches cleared\n" );kfree (mpc->mps_macs);memset (mpc,0 ,sizeof (struct mpoa_client )); -ddprintk ("mpoa: cleanup_module: about to kfree %p\n" , mpc); +ddprintk ("about to kfree %p\n" , mpc);kfree (mpc); -ddprintk ("mpoa: cleanup_module: next mpc is at %p\n" , tmp); +ddprintk ("next mpc is at %p\n" , tmp); mpc = tmp; }
@@ -1553,7 +1556,7 @@ static void __exit atm_mpoa_cleanup(void) qos_head =NULL ;while (qos !=NULL ) { nextqos = qos->next; -dprintk ("mpoa: cleanup_module: freeing qos entry %p\n" , qos); +dprintk ("freeing qos entry %p\n" , qos);kfree (qos); qos = nextqos; }
net/atm/mpoa_caches.c +27 -23
136 lines not on this page · raw message
net/atm/mpoa_proc.c +19 -9
@@ -21,10 +21,23 @@*/ #if 1 -#define dprintk(format, args...) printk(KERN_DEBUG format, ##args) /* debug */ +#define dprintk(format, args...) \ + printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)/* debug */ #else -#define dprintk(format, args...) \ - do { if (0) printk(KERN_DEBUG format, ##args); } while (0) +#define dprintk(format, args...) \ + do { if (0) \ + printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ + } while (0) +#endif + +#if 0 +#define ddprintk(format, args...) \ + printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)/* debug */ +#else +#define ddprintk(format, args...) \ + do { if (0) \ + printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ + } while (0)#endif #define STAT_FILE_NAME "mpc"/* Our statistic file's name */
@@ -258,12 +271,9 @@ static int parse_qos(const char *buff) qos.rxtp.max_pcr = rx_pcr; qos.rxtp.max_sdu = rx_sdu; qos.aal =ATM_AAL5 ; -dprintk ("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n" , - qos.txtp.max_pcr, - qos.txtp.max_sdu, - qos.rxtp.max_pcr, - qos.rxtp.max_sdu - ); +dprintk ("parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n" , + qos.txtp.max_pcr, qos.txtp.max_sdu, + qos.rxtp.max_pcr, qos.rxtp.max_sdu);atm_mpoa_add_qos (ipaddr, &qos);return 1 ;
Signature · 1 line
1.6.6.rc0.57.gad7a
From: Joe Perches <[email protected]>
Date: Tue, 26 Jan 2010 13:39:59 -0800
Quoted 1 line
Miscellaneous cleanups to net/atm
All looks good.
Thanks for doing this work Joe.
Applied to net-next-2.6
Quoted 4 lines · David Miller
From: Joe Perches <[email protected]>
Date: Tue, 26 Jan 2010 13:39:59 -0800Quoted 1 line
Miscellaneous cleanups to net/atm
All looks good.
Unfortunately, appearances aren't necessarily trustworthy. 5/21 is missing a close parenthesis.
+ print_hex_dump(KERN_DEBUG, "br2684: skb: ", DUMP_OFFSET,
+ 16, 1, skb->data, min(NUM2PRINT, skb->len, true);
#endif
should be:
+ print_hex_dump(KERN_DEBUG, "br2684: skb: ", DUMP_OFFSET,
+ 16, 1, skb->data, min(NUM2PRINT, skb->len), true);
#endif
Want an updated 5/21 or another patch?
David Miller
maintainerFrom: Joe Perches <[email protected]>
Date: Tue, 26 Jan 2010 21:11:49 -0800
Quoted 19 lines · David Miller
Quoted 4 lines
From: Joe Perches <[email protected]>
Date: Tue, 26 Jan 2010 13:39:59 -0800Quoted 1 line
Miscellaneous cleanups to net/atm
All looks good.
Unfortunately, appearances aren't necessarily trustworthy. 5/21 is missing a close parenthesis.
(quoted diff) +2
-0+ print_hex_dump(KERN_DEBUG, "br2684: skb: ", DUMP_OFFSET, + 16, 1, skb->data, min(NUM2PRINT, skb->len, true); #endifshould be:
(quoted diff) +2
-0+ print_hex_dump(KERN_DEBUG, "br2684: skb: ", DUMP_OFFSET, + 16, 1, skb->data, min(NUM2PRINT, skb->len), true); #endif
Quoted 1 line
Want an updated 5/21 or another patch?
I'll fix it up myself, thanks.