]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
Reformated to meet Linux Documentation/Codingstyle (e.g. 80 chars/Line).
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Mon, 5 Mar 2007 12:34:43 +0000 (12:34 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Mon, 5 Mar 2007 12:34:43 +0000 (12:34 +0000)
Cosmetics.

git-svn-id: svn://svn.berlios.de//socketcan/trunk@167 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/drivers/net/can/vcan.c
kernel/2.6/net/can/af_can.c
kernel/2.6/net/can/bcm.c
kernel/2.6/net/can/proc.c
kernel/2.6/net/can/raw.c

index 0862f6032e0893c1a8ffea350b81c799c4f66f88..241843fef871762eb5c98de7d96c4b722a749225 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * vcan.c
+ * vcan.c - Virtual CAN interface
  *
  * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
  * All rights reserved.
@@ -54,7 +54,8 @@
 
 RCSID("$Id$");
 
-static __initdata const char banner[] = KERN_INFO "CAN: virtual CAN interface " VERSION "\n"; 
+static __initdata const char banner[] = KERN_INFO "CAN: virtual CAN "
+                                       "interface " VERSION "\n"; 
 
 MODULE_DESCRIPTION("virtual CAN interface");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -78,6 +79,8 @@ module_param(debug, int, S_IRUGO);
 /* should be done in af_can.c */
 #undef  DO_LOOPBACK
 
+#define STATSIZE sizeof(struct net_device_stats)
+
 static int numdev = 4; /* default number of virtual CAN interfaces */
 module_param(numdev, int, S_IRUGO);
 MODULE_PARM_DESC(numdev, "Number of virtual CAN devices");
@@ -198,7 +201,7 @@ static void vcan_init(struct net_device *dev)
 
        ether_setup(dev);
 
-       memset(dev->priv, 0, sizeof(struct net_device_stats));
+       memset(dev->priv, 0, STATSIZE);
 
        dev->type              = ARPHRD_CAN;
        dev->mtu               = sizeof(struct can_frame);
@@ -229,7 +232,8 @@ static __init int vcan_init_module(void)
        if (numdev < 1)
                numdev = 1; /* register at least one interface */
 
-       printk(KERN_INFO "vcan: registering %d virtual CAN interfaces.\n", numdev );
+       printk(KERN_INFO "vcan: registering %d virtual CAN interfaces.\n",
+              numdev );
 
        vcan_devs = kmalloc(numdev * sizeof(struct net_device *), GFP_KERNEL);
        if (!vcan_devs) {
@@ -241,13 +245,14 @@ static __init int vcan_init_module(void)
        memset(vcan_devs, 0, numdev * sizeof(struct net_device *));
 
        for (i = 0; i < numdev; i++) {
-               if (!(vcan_devs[i] = alloc_netdev(sizeof(struct net_device_stats),
-                                                 "vcan%d", vcan_init))) {
+               if (!(vcan_devs[i] = alloc_netdev(STATSIZE, "vcan%d",
+                                                 vcan_init))) {
                        printk(KERN_ERR "vcan: error allocating net_device\n");
                        result = -ENOMEM;
                        goto out;
                } else if ((result = register_netdev(vcan_devs[i])) < 0) {
-                       printk(KERN_ERR "vcan: error %d registering interface %s\n",
+                       printk(KERN_ERR "vcan: error %d registering "
+                              "interface %s\n",
                               result, vcan_devs[i]->name);
                        free_netdev(vcan_devs[i]);
                        vcan_devs[i] = NULL;
index 1a451cd9fa2492431cdf2366f966069d03a3e102..744b03d4c5366d21d8a7841ad085b9e932216ddd 100644 (file)
@@ -1,7 +1,8 @@
 /*
- * af_can.c
+ * af_can.c - Protocol family CAN core module
+ *            (used by different CAN protocol modules)
  *
- * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -52,6 +53,8 @@
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
 #include <linux/socket.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
 #include <linux/skbuff.h>
 #include <linux/net.h>
 #include <linux/netdevice.h>
 RCSID("$Id$");
 
 #define IDENT "af_can"
-static __initdata const char banner[] = KERN_INFO "CAN: PF_CAN core " VERSION "\n"; 
+static __initdata const char banner[] = KERN_INFO "CAN: Controller Area "
+                                       "Network PF_CAN core " VERSION "\n"; 
 
-MODULE_DESCRIPTION("PF_CAN core");
+MODULE_DESCRIPTION("Controller Area Network PF_CAN core");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>, "
              "Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
@@ -237,11 +241,13 @@ void can_proto_register(struct can_proto *cp)
 {
        int proto = cp->protocol;
        if (proto < 0 || proto >= CAN_NPROTO) {
-               printk(KERN_ERR "CAN: protocol number %d out of range\n", proto);
+               printk(KERN_ERR "CAN: protocol number %d out "
+                      "of range\n", proto);
                return;
        }
        if (proto_tab[proto]) {
-               printk(KERN_ERR "CAN: protocol %d already registered\n", proto);
+               printk(KERN_ERR "CAN: protocol %d already "
+                      "registered\n", proto);
                return;
        }
 
@@ -252,7 +258,7 @@ void can_proto_register(struct can_proto *cp)
 #endif
        proto_tab[proto] = cp;
 
-       /* use our generic ioctl function if the module doesn't bring its own */
+       /* use generic ioctl function if the module doesn't bring its own */
        if (!cp->ops->ioctl)
                cp->ops->ioctl = can_ioctl;
 }
@@ -340,8 +346,8 @@ static int can_create(struct socket *sock, int protocol)
                char module_name[30];
                sprintf(module_name, "can-proto-%d", protocol);
                if (request_module(module_name) == -ENOSYS)
-                       printk(KERN_INFO "CAN: request_module(%s) not implemented.\n",
-                              module_name);
+                       printk(KERN_INFO "CAN: request_module(%s) not"
+                              " implemented.\n", module_name);
        }
 
        /* check for success and correct type */
@@ -416,7 +422,8 @@ static int can_notifier(struct notifier_block *nb,
                DBG("creating new dev_rcv_lists for %s\n", dev->name);
                if (!(d = kmalloc(sizeof(*d),
                                  in_interrupt() ? GFP_ATOMIC : GFP_KERNEL))) {
-                       printk(KERN_ERR "CAN: allocation of receive list failed\n");
+                       printk(KERN_ERR "CAN: allocation of receive "
+                              "list failed\n");
                        return NOTIFY_DONE;
                }
                /* N.B. zeroing the struct is the correct initialization
index 274ff3c8edabada7741ea53dfc45010f1bf9f2b7..cb6e383dbd4f11b1309d53ccdffd85f2b0ef7b60 100644 (file)
@@ -75,19 +75,19 @@ module_param(debug, int, S_IRUGO);
 
 /* use of last_frames[index].can_dlc */
 #define RX_RECV    0x40 /* received data for this element */
-#define RX_THR     0x80 /* this element has not been sent due to throttle functionality */
-#define BCM_CAN_DLC_MASK 0x0F /* clean flags by masking with BCM_CAN_DLC_MASK */
+#define RX_THR     0x80 /* element not been sent due to throttle feature */
+#define BCM_CAN_DLC_MASK 0x0F /* clean private flags in can_dlc by masking */
 #define BCM_RX_REGMASK (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG)
 
 #define IDENT "bcm"
-static __initdata const char banner[] =
-       KERN_INFO "CAN: broadcast manager (bcm) socket protocol " VERSION "\n"; 
+static __initdata const char banner[] = KERN_INFO
+       "CAN: broadcast manager (bcm) socket protocol " VERSION "\n"; 
 
 MODULE_DESCRIPTION("PF_CAN bcm sockets");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
 
-#define GET_U64(p) (*(unsigned long long*)(p)->data) /* easy access */
+#define GET_U64(p) (*(u64*)(p)->data) /* easy access */
 
 struct bcm_op {
        struct list_head list;
@@ -156,11 +156,15 @@ static void bcm_rx_update_and_send(struct bcm_op *op,
 static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
                             struct can_frame *frames, struct timeval *tv);
 
-static int  bcm_delete_tx_op(struct list_head *ops, canid_t can_id, int ifindex);
-static int  bcm_delete_rx_op(struct list_head *ops, canid_t can_id, int ifindex);
+static int  bcm_delete_tx_op(struct list_head *ops, canid_t can_id,
+                            int ifindex);
+static int  bcm_delete_rx_op(struct list_head *ops, canid_t can_id,
+                            int ifindex);
 static void bcm_remove_op(struct bcm_op *op);
-static int  bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, int ifindex);
-static struct bcm_op *bcm_find_op(struct list_head *ops, canid_t can_id, int ifindex);
+static int  bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head,
+                       int ifindex);
+static struct bcm_op *bcm_find_op(struct list_head *ops, canid_t can_id,
+                                 int ifindex);
 
 static struct proto_ops bcm_ops = {
        .family        = PF_CAN,
@@ -313,23 +317,26 @@ static int bcm_release(struct socket *sock)
        /* remove bcm_ops, timer, rx_unregister(), etc. */
 
        list_for_each_entry_safe(op, next, &bo->tx_ops, list) {
-               DBG("removing tx_op (%p) for can_id <%03X>\n", op, op->can_id);
+               DBG("removing tx_op %p for can_id %03X\n", op, op->can_id);
                bcm_remove_op(op);
        }
 
        list_for_each_entry_safe(op, next, &bo->rx_ops, list) {
-               DBG("removing rx_op (%p) for can_id <%03X>\n", op, op->can_id);
+               DBG("removing rx_op %p for can_id %03X\n", op, op->can_id);
 
                /* Don't care if we're bound or not (due to netdev problems) */
                /* can_rx_unregister() is always a save thing to do here     */
                if (op->ifindex) {
                        struct net_device *dev = dev_get_by_index(op->ifindex);
                        if (dev) {
-                               can_rx_unregister(dev, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op);
+                               can_rx_unregister(dev, op->can_id,
+                                                 BCM_RX_REGMASK,
+                                                 bcm_rx_handler, op);
                                dev_put(dev);
                        }
                } else
-                       can_rx_unregister(NULL, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op);
+                       can_rx_unregister(NULL, op->can_id, BCM_RX_REGMASK,
+                                         bcm_rx_handler, op);
 
                bcm_remove_op(op);
        }
@@ -367,23 +374,29 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
        if (addr->can_ifindex) {
                struct net_device *dev = dev_get_by_index(addr->can_ifindex);
                if (!dev) {
-                       DBG("could not find device index %d\n", addr->can_ifindex);
+                       DBG("could not find device index %d\n",
+                           addr->can_ifindex);
                        return -ENODEV;
                }
                bo->ifindex = dev->ifindex;
-               can_dev_register(dev, bcm_notifier, sk); /* register notifier */
+               can_dev_register(dev, bcm_notifier, sk); /* register notif. */
                dev_put(dev);
 
-               DBG("socket %p bound to device %s (idx %d)\n", sock, dev->name, dev->ifindex);
-       } else
-               bo->ifindex = 0; /* no notifier for ifindex = 0 ('any' CAN device) */
+               DBG("socket %p bound to device %s (idx %d)\n",
+                   sock, dev->name, dev->ifindex);
+       } else {
+               /* no notifier for ifindex = 0 ('any' CAN device) */
+               bo->ifindex = 0;
+       }
 
        bo->bound = 1;
 
        if (proc_dir) {
-               sprintf(bo->procname, "%p", sock); /* unique socket address as filename */
+               /* unique socket address as filename */
+               sprintf(bo->procname, "%p", sock);
                bo->bcm_proc_read = create_proc_read_entry(bo->procname, 0644,
-                                                          proc_dir, bcm_read_proc, sk);
+                                                          proc_dir,
+                                                          bcm_read_proc, sk);
        }
 
        return 0;
@@ -406,7 +419,8 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock,
        /* check for alternative ifindex for this bcm_op */
 
        if (!ifindex && msg->msg_name) { /* no bound device as default */
-               struct sockaddr_can *addr = (struct sockaddr_can *)msg->msg_name;
+               struct sockaddr_can *addr = 
+                       (struct sockaddr_can *)msg->msg_name;
                if (addr->can_family != AF_CAN)
                        return -EINVAL;
                ifindex = addr->can_ifindex; /* ifindex from sendto() */
@@ -419,11 +433,11 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock,
 
        /* read message head information */
 
-       if ((ret = memcpy_fromiovec((unsigned char*)&msg_head, msg->msg_iov,
+       if ((ret = memcpy_fromiovec((u8*)&msg_head, msg->msg_iov,
                                    MHSIZ)) < 0)
                return ret;
 
-       DBG("opcode %d for can_id <%03X>\n", msg_head.opcode, msg_head.can_id);
+       DBG("opcode %d for can_id %03X\n", msg_head.opcode, msg_head.can_id);
 
        switch (msg_head.opcode) {
 
@@ -559,7 +573,7 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                /* update existing BCM operation */
 
-               DBG("TX_SETUP: modifying existing tx_op (%p) for can_id <%03X>\n",
+               DBG("TX_SETUP: modifying existing tx_op %p for can_id %03X\n",
                    op, msg_head->can_id);
 
                /* Do we need more space for the can_frames than currently */
@@ -570,11 +584,14 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                /* update can_frames content */
                for (i = 0; i < msg_head->nframes; i++) {
-                       if ((err = memcpy_fromiovec((unsigned char*)&op->frames[i], msg->msg_iov, CFSIZ)) < 0)
+                       if ((err = memcpy_fromiovec((u8*)&op->frames[i],
+                                                   msg->msg_iov, CFSIZ)) < 0)
                                return err;
 
-                       if (msg_head->flags & TX_CP_CAN_ID)
-                               op->frames[i].can_id = msg_head->can_id; /* copy can_id into frame */
+                       if (msg_head->flags & TX_CP_CAN_ID) {
+                               /* copy can_id into frame */
+                               op->frames[i].can_id = msg_head->can_id;
+                       }
                }
 
        } else {
@@ -585,38 +602,52 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                memset(op, 0, OPSIZ); /* init to zero, e.g. for timers */
 
-               DBG("TX_SETUP: creating new tx_op (%p) for can_id <%03X>\n",
+               DBG("TX_SETUP: creating new tx_op %p for can_id %03X\n",
                    op, msg_head->can_id);
 
                op->can_id    = msg_head->can_id;
 
                /* create array for can_frames and copy the data */
-               if (!(op->frames = kmalloc(msg_head->nframes * CFSIZ, GFP_KERNEL))) {
+               if (!(op->frames = kmalloc(msg_head->nframes * CFSIZ,
+                                          GFP_KERNEL))) {
                        kfree(op);
                        return -ENOMEM;
                }
 
                for (i = 0; i < msg_head->nframes; i++) {
-                       if ((err = memcpy_fromiovec((unsigned char*)&op->frames[i], msg->msg_iov, CFSIZ)) < 0) {
+                       if ((err = memcpy_fromiovec((u8*)&op->frames[i],
+                                                   msg->msg_iov,
+                                                   CFSIZ)) < 0) {
                                kfree(op->frames);
                                kfree(op);
                                return err;
                        }
 
-                       if (msg_head->flags & TX_CP_CAN_ID)
-                               op->frames[i].can_id = msg_head->can_id; /* copy can_id into frame */
+                       if (msg_head->flags & TX_CP_CAN_ID) {
+                               /* copy can_id into frame */
+                               op->frames[i].can_id = msg_head->can_id;
+                       }
                }
 
-               op->last_frames = NULL; /* tx_ops never compare with previous received messages */
+               /* tx_ops never compare with previous received messages */
+               op->last_frames = NULL;
+
+               /* bcm_can_tx / bcm_tx_timeout_handler needs this */
+               op->sk = sk;
 
-               op->sk = sk; /* bcm_can_tx / bcm_tx_timeout_handler needs this */
                op->ifindex = ifindex;
 
-               init_timer(&op->timer); /* initialize uninitialized (kmalloc) structure */
-               init_timer(&op->thrtimer); /* currently unused in tx_ops */
+               /* initialize uninitialized (kmalloc) structure */
+               init_timer(&op->timer);
+
+               /* currently unused in tx_ops */
+               init_timer(&op->thrtimer);
+
+               /* handler for tx_ops */
+               op->timer.function = bcm_tx_timeout_handler;
 
-               op->timer.function = bcm_tx_timeout_handler; /* handler for tx_ops */
-               op->timer.data = (unsigned long)op; /* timer.data points to this op-structure */
+               /* timer.data points to this op-structure */
+               op->timer.data = (unsigned long)op;
 
                /* add this bcm_op to the list of the tx_ops */
                list_add(&op->list, &bo->tx_ops);
@@ -625,15 +656,18 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
        if (op->nframes != msg_head->nframes) {
                op->nframes   = msg_head->nframes;
-               op->currframe = 0; /* start multiple frame transmission with index 0 */
+               /* start multiple frame transmission with index 0 */
+               op->currframe = 0;
        }
 
        /* check flags */
 
        op->flags = msg_head->flags;
 
-       if (op->flags & TX_RESET_MULTI_IDX)
-               op->currframe = 0; /* start multiple frame transmission with index 0 */
+       if (op->flags & TX_RESET_MULTI_IDX) {
+               /* start multiple frame transmission with index 0 */
+               op->currframe = 0; 
+       }
 
        if (op->flags & SETTIMER) {
 
@@ -655,21 +689,26 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                }
        }
 
-       if ((op->flags & STARTTIMER) && ((op->j_ival1 && op->count) || op->j_ival2)) {
+       if ((op->flags & STARTTIMER) &&
+           ((op->j_ival1 && op->count) || op->j_ival2)) {
 
                del_timer(&op->timer);
 
-               op->flags |= TX_ANNOUNCE; /* spec: send can_frame when starting timer */
+               /* spec: send can_frame when starting timer */
+               op->flags |= TX_ANNOUNCE;
+
                if (op->j_ival1 && (op->count > 0)){
                        op->timer.expires = jiffies + op->j_ival1;
                        /* op->count-- is done in bcm_tx_timeout_handler */
-                       DBG("TX_SETUP: adding timer ival1. func=%p data=(%p) exp=0x%08X\n",
+                       DBG("TX_SETUP: adding timer ival1. func=%p data=%p "
+                           "exp=0x%08X\n",
                            op->timer.function,
                            (char*) op->timer.data,
                            (unsigned int) op->timer.expires);
                } else{
                        op->timer.expires = jiffies + op->j_ival2;
-                       DBG("TX_SETUP: adding timer ival2. func=%p data=(%p) exp=0x%08X\n",
+                       DBG("TX_SETUP: adding timer ival2. func=%p data=%p "
+                           "exp=0x%08X\n",
                            op->timer.function,
                            (char*) op->timer.data,
                            (unsigned int) op->timer.expires);
@@ -699,7 +738,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
        }
 
        if ((msg_head->flags & RX_RTR_FRAME) &&
-           ((msg_head->nframes != 1) || (!(msg_head->can_id & CAN_RTR_FLAG)))) {
+           ((msg_head->nframes != 1) ||
+            (!(msg_head->can_id & CAN_RTR_FLAG)))) {
 
                DBG("RX_SETUP: bad RX_RTR_FRAME setup!\n");
                return -EINVAL;
@@ -711,7 +751,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                /* update existing BCM operation */
 
-               DBG("RX_SETUP: modifying existing rx_op (%p) for can_id <%03X>\n",
+               DBG("RX_SETUP: modifying existing rx_op %p for can_id %03X\n",
                    op, msg_head->can_id);
 
                /* Do we need more space for the can_frames than currently */
@@ -722,15 +762,18 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                if (msg_head->nframes) {
                        /* update can_frames content */
-                       if ((err = memcpy_fromiovec((unsigned char*)op->frames, msg->msg_iov, msg_head->nframes * CFSIZ) < 0))
+                       if ((err = memcpy_fromiovec((u8*)op->frames,
+                                                   msg->msg_iov,
+                                                   msg_head->nframes
+                                                   * CFSIZ) < 0))
                                return err;
 
-                       /* clear received can_frames to indicate 'nothing received' */
+                       /* clear last_frames to indicate 'nothing received' */
                        memset(op->last_frames, 0, msg_head->nframes * CFSIZ);
                }
 
                op->nframes = msg_head->nframes;
-               /* Only an update -> do not call can_rx_register() at end of RX_SETUP */
+               /* Only an update -> do not call can_rx_register() */
                do_rx_register = 0;
 
        } else {
@@ -741,7 +784,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                memset(op, 0, OPSIZ); /* init to zero, e.g. for timers */
 
-               DBG("RX_SETUP: creating new rx_op (%p) for can_id <%03X>\n",
+               DBG("RX_SETUP: creating new rx_op %p for can_id %03X\n",
                    op, msg_head->can_id);
 
                op->can_id    = msg_head->can_id;
@@ -750,31 +793,37 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                if (msg_head->nframes) {
 
                        /* create array for can_frames and copy the data */
-                       if (!(op->frames = kmalloc(msg_head->nframes * CFSIZ, GFP_KERNEL))) {
+                       if (!(op->frames = kmalloc(msg_head->nframes * CFSIZ,
+                                                  GFP_KERNEL))) {
                                kfree(op);
                                return -ENOMEM;
                        }
 
-                       if ((err = memcpy_fromiovec((unsigned char*)op->frames, msg->msg_iov, msg_head->nframes * CFSIZ)) < 0) {
+                       if ((err = memcpy_fromiovec((u8*)op->frames,
+                                                   msg->msg_iov,
+                                                   msg_head->nframes
+                                                   * CFSIZ)) < 0) {
                                kfree(op->frames);
                                kfree(op);
                                return err;
                        }
 
                        /* create array for received can_frames */
-                       if (!(op->last_frames = kmalloc(msg_head->nframes * CFSIZ, GFP_KERNEL))) {
+                       if (!(op->last_frames = kmalloc(msg_head->nframes
+                                                       * CFSIZ,
+                                                       GFP_KERNEL))) {
                                kfree(op->frames);
                                kfree(op);
                                return -ENOMEM;
                        }
 
-                       /* clear received can_frames to indicate 'nothing received' */
+                       /* clear last_frames to indicate 'nothing received' */
                        memset(op->last_frames, 0, msg_head->nframes * CFSIZ);
                } else {
                        /* op->frames = NULL due to memset */
 
-                       /* even when we have the RX_FILTER_ID case, we need to store the last frame */
-                       /* for the throttle functionality */
+                       /* even when we have the RX_FILTER_ID case, we need */
+                       /* to store the last frame for the throttle feature */
 
                        /* create array for received can_frames */
                        if (!(op->last_frames = kmalloc(CFSIZ, GFP_KERNEL))) {
@@ -782,27 +831,37 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                                return -ENOMEM;
                        }
 
-                       /* clear received can_frames to indicate 'nothing received' */
+                       /* clear last_frames to indicate 'nothing received' */
                        memset(op->last_frames, 0, CFSIZ);
                }
 
                op->sk = sk; /* bcm_delete_rx_op() needs this */
                op->ifindex = ifindex;
 
-               init_timer(&op->timer); /* initialize uninitialized (kmalloc) structure */
-               init_timer(&op->thrtimer); /* init throttle timer for RX_CHANGED */
+               /* initialize uninitialized (kmalloc) structure */
+               init_timer(&op->timer);
+
+               /* init throttle timer for RX_CHANGED */
+               init_timer(&op->thrtimer);
+
+               /* handler for rx timeouts */
+               op->timer.function = bcm_rx_timeout_handler;
 
-               op->timer.function = bcm_rx_timeout_handler; /* handler for rx timeouts */
-               op->timer.data = (unsigned long)op; /* timer.data points to this op-structure */
+               /* timer.data points to this op-structure */
+               op->timer.data = (unsigned long)op;
+
+               /* handler for RX_CHANGED throttle timeouts */
+               op->thrtimer.function = bcm_rx_thr_handler;
+
+               /* timer.data points to this op-structure */
+               op->thrtimer.data = (unsigned long)op;
 
-               op->thrtimer.function = bcm_rx_thr_handler; /* handler for RX_CHANGED throttle timeouts */
-               op->thrtimer.data = (unsigned long)op; /* timer.data points to this op-structure */
                op->thrtimer.expires = 0; /* mark disabled timer */
 
                /* add this bcm_op to the list of the tx_ops */
                list_add(&op->list, &bo->rx_ops);
 
-               do_rx_register = 1; /* call can_rx_register() at end of RX_SETUP */
+               do_rx_register = 1; /* call can_rx_register() */
 
        } /* if ((op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex))) */
 
@@ -840,18 +899,20 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                        /* disable an active timer due to zero value? */
                        if (!op->j_ival1) {
                                del_timer(&op->timer);
-                               DBG("RX_SETUP: disabled timer for rx timeouts.\n");
+                               DBG("RX_SETUP: disabled timer rx timeouts.\n");
                        }
 
                        /* free currently blocked msgs ? */
-                       if (op->thrtimer.expires) { /* running throttle timer? */
+                       if (op->thrtimer.expires) { /* blocked by timer? */
                                DBG("RX_SETUP: unblocking throttled msgs.\n");
                                del_timer(&op->thrtimer);
-                               op->thrtimer.expires = jiffies + 2; /* send blocked msgs hereafter */
+                               /* send blocked msgs hereafter */
+                               op->thrtimer.expires = jiffies + 2;
                                add_timer(&op->thrtimer);
                        }
-                       /* if (op->j_ival2) is zero, no (new) throttling will happen */
-                       /* see bcm_rx_update_and_send() and bcm_rx_thr_handler()     */
+                       /* if (op->j_ival2) is zero, no (new) throttling     */
+                       /* will happen. For details see functions            */
+                       /* bcm_rx_update_and_send() and bcm_rx_thr_handler() */
                }
 
                if ((op->flags & STARTTIMER) && op->j_ival1) {
@@ -860,7 +921,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                        op->timer.expires = jiffies + op->j_ival1;
 
-                       DBG("RX_SETUP: adding timer ival1. func=%p data=(%p) exp=0x%08X\n",
+                       DBG("RX_SETUP: adding timer ival1. func=%p data=%p"
+                           " exp=0x%08X\n",
                            (char *) op->timer.function,
                            (char *) op->timer.data,
                            (unsigned int) op->timer.expires);
@@ -871,17 +933,21 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
        /* now we can register for can_ids, if we added a new bcm_op */
        if (do_rx_register) {
-               DBG("RX_SETUP: can_rx_register() for can_id <%03X>. rx_op is (%p)\n", op->can_id, op);
+               DBG("RX_SETUP: can_rx_register() for can_id %03X. "
+                   "rx_op is %p\n", op->can_id, op);
 
                if (ifindex) {
                        struct net_device *dev = dev_get_by_index(ifindex);
 
                        if (dev) {
-                               can_rx_register(dev, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op, IDENT);
+                               can_rx_register(dev, op->can_id,
+                                               BCM_RX_REGMASK,
+                                               bcm_rx_handler, op, IDENT);
                                dev_put(dev);
                        }
                } else 
-                       can_rx_register(NULL, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op, IDENT);
+                       can_rx_register(NULL, op->can_id, BCM_RX_REGMASK,
+                                       bcm_rx_handler, op, IDENT);
        }
 
        return msg_head->nframes * CFSIZ + MHSIZ;
@@ -903,7 +969,8 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
        if (!skb)
                return -ENOMEM;
 
-       if ((err = memcpy_fromiovec(skb_put(skb, CFSIZ), msg->msg_iov, CFSIZ)) < 0) {
+       if ((err = memcpy_fromiovec(skb_put(skb, CFSIZ), msg->msg_iov,
+                                   CFSIZ)) < 0) {
                kfree_skb(skb);
                return err;
        }
@@ -925,14 +992,16 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
        return CFSIZ + MHSIZ;
 }
 
-static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, int ifindex)
+static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head,
+                      int ifindex)
 {
        struct bcm_op *op;
        int ret;
 
        if ((op = bcm_find_op(ops, msg_head->can_id, ifindex))) {
 
-               DBG("TRX_READ: sending status for can_id <%03X>\n", msg_head->can_id);
+               DBG("TRX_READ: sending status for can_id %03X\n",
+                   msg_head->can_id);
                /* put current values into msg_head */
                msg_head->flags   = op->flags;
                msg_head->count   = op->count;
@@ -946,7 +1015,7 @@ static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, int
 
        } else {
 
-               DBG("TRX_READ: did not find op for can_id <%03X>\n",
+               DBG("TRX_READ: did not find op for can_id %03X\n",
                    msg_head->can_id);
                ret = -EINVAL;
        }
@@ -980,11 +1049,14 @@ static int bcm_read_proc(char *page, char **start, off_t off,
        struct bcm_opt *bo = bcm_sk(sk);
        struct bcm_op *op;
 
-       len += snprintf(page + len, PAGE_SIZE - len, ">>> socket %p", sk->sk_socket);
+       len += snprintf(page + len, PAGE_SIZE - len, ">>> socket %p",
+                       sk->sk_socket);
        len += snprintf(page + len, PAGE_SIZE - len, " / sk %p", sk);
        len += snprintf(page + len, PAGE_SIZE - len, " / bo %p", bo);
-       len += snprintf(page + len, PAGE_SIZE - len, " / dropped %lu", bo->dropped_usr_msgs);
-       len += snprintf(page + len, PAGE_SIZE - len, " / bound %s", bcm_proc_getifname(bo->ifindex));
+       len += snprintf(page + len, PAGE_SIZE - len, " / dropped %lu",
+                       bo->dropped_usr_msgs);
+       len += snprintf(page + len, PAGE_SIZE - len, " / bound %s",
+                       bcm_proc_getifname(bo->ifindex));
        len += snprintf(page + len, PAGE_SIZE - len, " <<<\n");
 
        list_for_each_entry(op, &bo->rx_ops, list) {
@@ -995,17 +1067,22 @@ static int bcm_read_proc(char *page, char **start, off_t off,
                if (!op->frames_abs)
                        continue;
 
-               len += snprintf(page + len, PAGE_SIZE - len, "rx_op: %03X %-5s ",
+               len += snprintf(page + len, PAGE_SIZE - len,
+                               "rx_op: %03X %-5s ",
                                op->can_id, bcm_proc_getifname(op->ifindex));
                len += snprintf(page + len, PAGE_SIZE - len, "[%d]%c ",
-                               op->nframes,(op->flags & RX_CHECK_DLC)?'d':' ');
+                               op->nframes,
+                               (op->flags & RX_CHECK_DLC)?'d':' ');
                if (op->j_ival1)
-                       len += snprintf(page + len, PAGE_SIZE - len, "timeo=%ld ", op->j_ival1);
+                       len += snprintf(page + len, PAGE_SIZE - len,
+                                       "timeo=%ld ", op->j_ival1);
 
                if (op->j_ival2)
-                       len += snprintf(page + len, PAGE_SIZE - len, "thr=%ld ", op->j_ival2);
+                       len += snprintf(page + len, PAGE_SIZE - len,
+                                       "thr=%ld ", op->j_ival2);
 
-               len += snprintf(page + len, PAGE_SIZE - len, "# recv %ld (%ld) => reduction: ",
+               len += snprintf(page + len, PAGE_SIZE - len,
+                               "# recv %ld (%ld) => reduction: ",
                                op->frames_filtered, op->frames_abs);
 
                reduction = 100 - (op->frames_filtered * 100) / op->frames_abs;
@@ -1022,15 +1099,20 @@ static int bcm_read_proc(char *page, char **start, off_t off,
 
        list_for_each_entry(op, &bo->tx_ops, list) {
 
-               len += snprintf(page + len, PAGE_SIZE - len, "tx_op: %03X %s [%d] ",
-                               op->can_id, bcm_proc_getifname(op->ifindex), op->nframes);
+               len += snprintf(page + len, PAGE_SIZE - len,
+                               "tx_op: %03X %s [%d] ",
+                               op->can_id, bcm_proc_getifname(op->ifindex),
+                               op->nframes);
                if (op->j_ival1)
-                       len += snprintf(page + len, PAGE_SIZE - len, "t1=%ld ", op->j_ival1);
+                       len += snprintf(page + len, PAGE_SIZE - len, "t1=%ld ",
+                                       op->j_ival1);
 
                if (op->j_ival2)
-                       len += snprintf(page + len, PAGE_SIZE - len, "t2=%ld ", op->j_ival2);
+                       len += snprintf(page + len, PAGE_SIZE - len, "t2=%ld ",
+                                       op->j_ival2);
 
-               len += snprintf(page + len, PAGE_SIZE - len, "# sent %ld\n", op->frames_abs);
+               len += snprintf(page + len, PAGE_SIZE - len, "# sent %ld\n",
+                               op->frames_abs);
 
                if (len > PAGE_SIZE - 100) {
                        /* mark output cut off */
@@ -1091,17 +1173,19 @@ static void bcm_tx_timeout_handler(unsigned long data)
 {
        struct bcm_op *op = (struct bcm_op*)data;
 
-       DBG("Called with bcm_op (%p)\n", op);
+       DBG("Called with bcm_op %p\n", op);
 
        if (op->j_ival1 && (op->count > 0)) {
 
                op->count--;
 
-               if (!op->count && (op->flags & TX_COUNTEVT)) { /* create notification to user? */
+               if (!op->count && (op->flags & TX_COUNTEVT)) {
+                       /* create notification to user */
 
                        struct bcm_msg_head msg_head;
 
-                       DBG("sending TX_EXPIRED for can_id <%03X>\n", op->can_id);
+                       DBG("sending TX_EXPIRED for can_id %03X\n",
+                           op->can_id);
 
                        msg_head.opcode  = TX_EXPIRED;
                        msg_head.flags   = op->flags;
@@ -1123,7 +1207,7 @@ static void bcm_tx_timeout_handler(unsigned long data)
                op->timer.expires = jiffies + op->j_ival1;
                add_timer(&op->timer);
 
-               DBG("adding timer ival1. func=%p data=(%p) exp=0x%08X\n",
+               DBG("adding timer ival1. func=%p data=%p exp=0x%08X\n",
                    op->timer.function,
                    (char*) op->timer.data,
                    (unsigned int) op->timer.expires);
@@ -1134,7 +1218,7 @@ static void bcm_tx_timeout_handler(unsigned long data)
                        op->timer.expires = jiffies + op->j_ival2;
                        add_timer(&op->timer);
 
-                       DBG("adding timer ival2. func=%p data=(%p) exp=0x%08X\n",
+                       DBG("adding timer ival2. func=%p data=%p exp=0x%08X\n",
                            op->timer.function,
                            (char*) op->timer.data,
                            (unsigned int) op->timer.expires);
@@ -1160,15 +1244,16 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
 
        del_timer(&op->timer); /* disable timeout */
 
-       DBG("Called with bcm_op (%p)\n", op);
+       DBG("Called with bcm_op %p\n", op);
 
        if (skb->len == sizeof(rxframe)) {
                memcpy(&rxframe, skb->data, sizeof(rxframe));
                skb_get_timestamp(skb, &op->rx_stamp); /* save rx timestamp */
-               op->rx_ifindex = skb->dev->ifindex; /* save originator for recvfrom() */
+               /* save originator for recvfrom() */
+               op->rx_ifindex = skb->dev->ifindex;
                op->frames_abs++; /* statistics */
                kfree_skb(skb);
-               DBG("got can_frame with can_id <%03X>\n", rxframe.can_id);
+               DBG("got can_frame with can_id %03X\n", rxframe.can_id);
        } else {
                DBG("Wrong skb->len = %d\n", skb->len);
                kfree_skb(skb);
@@ -1178,7 +1263,7 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
        DBG_FRAME("BCM: bcm_rx_handler: CAN frame", &rxframe);
 
        if (op->can_id != rxframe.can_id) {
-               DBG("ERROR! Got wrong can_id <%03X>! Expected <%03X>.\n",
+               DBG("ERROR! Got wrong can_id %03X! Expected %03X.\n",
                    rxframe.can_id, op->can_id);
                return;
        }
@@ -1212,7 +1297,8 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
                for (i=1; i < op->nframes; i++) {
 
                        if ((GET_U64(&op->frames[0]) & GET_U64(&rxframe)) ==
-                           (GET_U64(&op->frames[0]) & GET_U64(&op->frames[i]))) {
+                           (GET_U64(&op->frames[0]) &
+                            GET_U64(&op->frames[i]))) {
                                DBG("found MUX index %d\n", i);
                                bcm_rx_cmp_to_index(op, i, &rxframe);
                                break;
@@ -1236,7 +1322,8 @@ static void bcm_rx_cmp_to_index(struct bcm_op *op, int index,
 
        /* do a real check in can_data */
 
-       DBG("op->frames[index].data = 0x%016llx\n", GET_U64(&op->frames[index]));
+       DBG("op->frames[index].data = 0x%016llx\n",
+           GET_U64(&op->frames[index]));
        DBG("op->last_frames[index].data = 0x%016llx\n",
            GET_U64(&op->last_frames[index]));
        DBG("rxdata->data = 0x%016llx\n", GET_U64(rxdata));
@@ -1253,9 +1340,11 @@ static void bcm_rx_cmp_to_index(struct bcm_op *op, int index,
 
                /* do a real check in dlc */
 
-               if (rxdata->can_dlc != (op->last_frames[index].can_dlc & BCM_CAN_DLC_MASK)) {
+               if (rxdata->can_dlc != (op->last_frames[index].can_dlc &
+                                       BCM_CAN_DLC_MASK)) {
                        DBG("dlc change :)\n");
-                       bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
+                       bcm_rx_update_and_send(op, &op->last_frames[index],
+                                              rxdata);
                        return;
                }
        }
@@ -1281,7 +1370,7 @@ static void bcm_rx_update_and_send(struct bcm_op *op,
                        op->thrtimer.expires = nexttx;
                        add_timer(&op->thrtimer);
 
-                       DBG("adding thrtimer. func=%p data=(%p) exp=0x%08X\n",
+                       DBG("adding thrtimer. func=%p data=%p exp=0x%08X\n",
                            op->thrtimer.function,
                            (char*) op->thrtimer.data,
                            (unsigned int) op->thrtimer.expires);
@@ -1299,7 +1388,8 @@ static void bcm_rx_starttimer(struct bcm_op *op)
 
                op->timer.expires = jiffies + op->j_ival1;
 
-               DBG("adding rx timeout timer ival1. func=%p data=(%p) exp=0x%08X\n",
+               DBG("adding rx timeout timer ival1. func=%p data=%p "
+                   "exp=0x%08X\n",
                    op->timer.function,
                    (char*) op->timer.data,
                    (unsigned int) op->timer.expires);
@@ -1317,9 +1407,9 @@ static void bcm_rx_changed(struct bcm_op *op, struct can_frame *data)
        op->frames_filtered++; /* statistics */
 
        if (op->frames_filtered > ULONG_MAX/100)
-               op->frames_filtered = op->frames_abs = 0; /* restart - spinlock ? */
+               op->frames_filtered = op->frames_abs = 0; /* restart */
 
-       DBG("setting j_lastmsg to 0x%08X for rx_op(%p)\n",
+       DBG("setting j_lastmsg to 0x%08X for rx_op %p\n",
            (unsigned int) op->j_lastmsg, op);
        DBG("sending notification\n");
 
@@ -1340,7 +1430,7 @@ static void bcm_rx_timeout_handler(unsigned long data)
        struct bcm_op *op = (struct bcm_op*)data;
        struct bcm_msg_head msg_head;
 
-       DBG("sending RX_TIMEOUT for can_id <%03X>. op is (%p)\n", op->can_id, op);
+       DBG("sending RX_TIMEOUT for can_id %03X. op is %p\n", op->can_id, op);
 
        msg_head.opcode  = RX_TIMEOUT;
        msg_head.flags   = op->flags;
@@ -1354,7 +1444,7 @@ static void bcm_rx_timeout_handler(unsigned long data)
 
        /* no restart of the timer is done here! */
 
-       /* if the user wants to be informed, when cyclic CAN-Messages come back ... */
+       /* if user wants to be informed, when cyclic CAN-Messages come back */
        if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) {
                /* clear received can_frames to indicate 'nothing received' */
                memset(op->last_frames, 0, op->nframes * CFSIZ);
@@ -1372,18 +1462,19 @@ static void bcm_rx_thr_handler(unsigned long data)
 
        if (op->nframes > 1){
 
-               DBG("sending MUX RX_CHANGED for can_id <%03X>. op is (%p)\n",
+               DBG("sending MUX RX_CHANGED for can_id %03X. op is %p\n",
                    op->can_id, op);
                /* for MUX filter we start at index 1 */
                for (i=1; i<op->nframes; i++){
-                       if ((op->last_frames) && (op->last_frames[i].can_dlc & RX_THR)){
+                       if ((op->last_frames) &&
+                           (op->last_frames[i].can_dlc & RX_THR)){
                                op->last_frames[i].can_dlc &= ~RX_THR;
                                bcm_rx_changed(op, &op->last_frames[i]);
                        }
                }
        } else {
 
-               DBG("sending simple RX_CHANGED for can_id <%03X>. op is (%p)\n",
+               DBG("sending simple RX_CHANGED for can_id %03X. op is %p\n",
                    op->can_id, op);
                /* for RX_FILTER_ID and simple filter */
                if (op->last_frames && (op->last_frames[0].can_dlc & RX_THR)){
@@ -1409,7 +1500,8 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
                return;
 
        memcpy(skb_put(skb, sizeof(*head)), head, sizeof(*head));
-       firstframe = (struct can_frame *) skb->tail; /* can_frames starting here */
+       /* can_frames starting here */
+       firstframe = (struct can_frame *) skb->tail;
 
        if (tv)
                skb_set_timestamp(skb, tv); /* restore timestamp */
@@ -1417,15 +1509,16 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
        addr = (struct sockaddr_can *)skb->cb;
        memset(addr, 0, sizeof(*addr));
        addr->can_family  = AF_CAN;
-       addr->can_ifindex = op->rx_ifindex; /* restore originator for recvfrom() */
+       /* restore originator for recvfrom() */
+       addr->can_ifindex = op->rx_ifindex;
 
        if (head->nframes){
                memcpy(skb_put(skb, datalen), frames, datalen);
 
-               /* the BCM uses the can_dlc-element of the can_frame structure
-                  for internal purposes. This is only relevant for updates
-                  that are generated by the BCM, where nframes is 1
-               */
+               /* the BCM uses the can_dlc-element of the can_frame */
+               /* structure for internal purposes. This is only     */
+               /* relevant for updates that are generated by the    */
+               /* BCM, where nframes is 1                           */
                if (head->nframes == 1)
                        firstframe->can_dlc &= BCM_CAN_DLC_MASK;
        }
@@ -1441,7 +1534,8 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
 /* bcm_op handling: find & delete bcm_op elements */
 /**************************************************/
 
-static struct bcm_op *bcm_find_op(struct list_head *ops, canid_t can_id, int ifindex)
+static struct bcm_op *bcm_find_op(struct list_head *ops, canid_t can_id,
+                                 int ifindex)
 {
        struct bcm_op *op;
 
@@ -1458,18 +1552,25 @@ static int bcm_delete_rx_op(struct list_head *ops, canid_t can_id, int ifindex)
 
        list_for_each_entry_safe(op, n, ops, list) {
                if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
-                       DBG("removing rx_op (%p) for can_id <%03X>\n", op, op->can_id);
+                       DBG("removing rx_op %p for can_id %03X\n",
+                           op, op->can_id);
 
-                       /* Don't care if we're bound or not (due to netdev problems) */
-                       /* can_rx_unregister() is always a save thing to do here     */
+                       /* Don't care if we're bound or not (due to netdev */
+                       /* problems) can_rx_unregister() is always a save  */
+                       /* thing to do here.                               */
                        if (op->ifindex) {
-                               struct net_device *dev = dev_get_by_index(op->ifindex);
+                               struct net_device *dev =
+                                       dev_get_by_index(op->ifindex);
                                if (dev) {
-                                       can_rx_unregister(dev, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op);
+                                       can_rx_unregister(dev, op->can_id,
+                                                         BCM_RX_REGMASK,
+                                                         bcm_rx_handler, op);
                                        dev_put(dev);
                                }
                        } else
-                               can_rx_unregister(NULL, op->can_id, BCM_RX_REGMASK, bcm_rx_handler, op);
+                               can_rx_unregister(NULL, op->can_id,
+                                                 BCM_RX_REGMASK,
+                                                 bcm_rx_handler, op);
 
                        list_del(&op->list);
                        bcm_remove_op(op);
@@ -1486,7 +1587,7 @@ static int bcm_delete_tx_op(struct list_head *ops, canid_t can_id, int ifindex)
 
        list_for_each_entry_safe(op, n, ops, list) {
                if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
-                       DBG("removing rx_op (%p) for can_id <%03X>\n",
+                       DBG("removing rx_op %p for can_id %03X\n",
                            op, op->can_id);
                        list_del(&op->list);
                        bcm_remove_op(op);
index 6f0801037cd81032b704c1628136f396928f8971..3997e3533b118bb0f145f455881b9d7b705cb665 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * af_can_proc.c
+ * proc.c - procfs support for Protocol family CAN core module
  *
- * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,9 +69,9 @@ RCSID("$Id$");
 static void can_init_stats(int caller);
 static void can_stat_update(unsigned long data);
 
-static struct proc_dir_entry *can_create_proc_read_entry(const char *name,
+static struct proc_dir_entry *can_create_proc_readentry(const char *name,
        mode_t mode, read_proc_t* read_proc, void *data);
-static void can_remove_proc_entry(const char *name);
+static void can_remove_proc_readentry(const char *name);
 static unsigned long calc_rate(unsigned long oldjif, unsigned long newjif,
                               unsigned long count);
 
@@ -126,7 +126,7 @@ void can_init_proc(void)
        can_dir = proc_mkdir(CAN_PROC_DIR, NULL);
 
        if (!can_dir) {
-               printk(KERN_INFO "af_can: failed to create CAN_PROC_DIR. "
+               printk(KERN_INFO "CAN: failed to create CAN_PROC_DIR. "
                       "CONFIG_PROC_FS missing?\n");
                return;
        }
@@ -134,23 +134,23 @@ void can_init_proc(void)
        can_dir->owner = THIS_MODULE;
 
        /* own procfs entries from the AF_CAN core */
-       pde_version     = can_create_proc_read_entry(
+       pde_version     = can_create_proc_readentry(
                CAN_PROC_VERSION, 0644, can_proc_read_version, NULL);
-       pde_stats       = can_create_proc_read_entry(
+       pde_stats       = can_create_proc_readentry(
                CAN_PROC_STATS, 0644, can_proc_read_stats, NULL);
-       pde_reset_stats = can_create_proc_read_entry(
+       pde_reset_stats = can_create_proc_readentry(
                CAN_PROC_RESET_STATS, 0644, can_proc_read_reset_stats, NULL);
-       pde_rcvlist_all = can_create_proc_read_entry(
+       pde_rcvlist_all = can_create_proc_readentry(
                CAN_PROC_RCVLIST_ALL, 0644, can_proc_read_rcvlist_all, NULL);
-       pde_rcvlist_fil = can_create_proc_read_entry(
+       pde_rcvlist_fil = can_create_proc_readentry(
                CAN_PROC_RCVLIST_FIL, 0644, can_proc_read_rcvlist_fil, NULL);
-       pde_rcvlist_inv = can_create_proc_read_entry(
+       pde_rcvlist_inv = can_create_proc_readentry(
                CAN_PROC_RCVLIST_INV, 0644, can_proc_read_rcvlist_inv, NULL);
-       pde_rcvlist_sff = can_create_proc_read_entry(
+       pde_rcvlist_sff = can_create_proc_readentry(
                CAN_PROC_RCVLIST_SFF, 0644, can_proc_read_rcvlist_sff, NULL);
-       pde_rcvlist_eff = can_create_proc_read_entry(
+       pde_rcvlist_eff = can_create_proc_readentry(
                CAN_PROC_RCVLIST_EFF, 0644, can_proc_read_rcvlist_eff, NULL);
-       pde_rcvlist_err = can_create_proc_read_entry(
+       pde_rcvlist_err = can_create_proc_readentry(
                CAN_PROC_RCVLIST_ERR, 0644, can_proc_read_rcvlist_err, NULL);
 
        if (stats_timer) {
@@ -166,31 +166,31 @@ void can_remove_proc(void)
 {
        /* procfs remove */
        if (pde_version)
-               can_remove_proc_entry(CAN_PROC_VERSION);
+               can_remove_proc_readentry(CAN_PROC_VERSION);
 
        if (pde_stats)
-               can_remove_proc_entry(CAN_PROC_STATS);
+               can_remove_proc_readentry(CAN_PROC_STATS);
 
        if (pde_reset_stats)
-               can_remove_proc_entry(CAN_PROC_RESET_STATS);
+               can_remove_proc_readentry(CAN_PROC_RESET_STATS);
 
        if (pde_rcvlist_all)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_ALL);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_ALL);
 
        if (pde_rcvlist_fil)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_FIL);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_FIL);
 
        if (pde_rcvlist_inv)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_INV);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_INV);
 
        if (pde_rcvlist_sff)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_SFF);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_SFF);
 
        if (pde_rcvlist_eff)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_EFF);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_EFF);
 
        if (pde_rcvlist_err)
-               can_remove_proc_entry(CAN_PROC_RCVLIST_ERR);
+               can_remove_proc_readentry(CAN_PROC_RCVLIST_ERR);
 
        if (can_dir)
                remove_proc_entry(CAN_PROC_DIR, NULL);
@@ -200,8 +200,8 @@ void can_remove_proc(void)
 /* proc read functions                            */
 /**************************************************/
 
-static int can_print_recv_list(char *page, int len, struct hlist_head *rx_list,
-                              struct net_device *dev)
+static int can_print_rcvlist(char *page, int len, struct hlist_head *rx_list,
+                            struct net_device *dev)
 {
        struct receiver *r;
        struct hlist_node *n;
@@ -322,7 +322,8 @@ static int can_proc_read_reset_stats(char *page, char **start, off_t off,
        can_init_stats(1);
 
        len += snprintf(page + len, PAGE_SIZE - len,
-                       "CAN statistic reset #%ld done.\n", pstats.stats_reset);
+                       "CAN statistic reset #%ld done.\n",
+                       pstats.stats_reset);
 
        *eof = 1;
        return len;
@@ -334,9 +335,8 @@ static int can_proc_read_version(char *page, char **start, off_t off,
        int len = 0;
 
        len += snprintf(page + len, PAGE_SIZE - len,
-                       "%06X [ Volkswagen AG - Low Level CAN Framework (LLCF) v%s ]\n",
-                       LLCF_VERSION_CODE, VERSION);
-
+                       "%06X [ Volkswagen Group - Low Level CAN Framework"
+                       " (LLCF) v%s ]\n", LLCF_VERSION_CODE, VERSION);
        *eof = 1;
        return len;
 }
@@ -358,7 +358,7 @@ static int can_proc_read_rcvlist_all(char *page, char **start, off_t off,
 
                if (!hlist_empty(&d->rx_all)) {
                        len = can_print_recv_banner(page, len);
-                       len = can_print_recv_list(page, len, &d->rx_all, d->dev);
+                       len = can_print_rcvlist(page, len, &d->rx_all, d->dev);
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
                                        "  (%s: no entry)\n", DNAME(d->dev));
@@ -391,7 +391,7 @@ static int can_proc_read_rcvlist_fil(char *page, char **start, off_t off,
 
                if (!hlist_empty(&d->rx_fil)) {
                        len = can_print_recv_banner(page, len);
-                       len = can_print_recv_list(page, len, &d->rx_fil, d->dev);
+                       len = can_print_rcvlist(page, len, &d->rx_fil, d->dev);
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
                                        "  (%s: no entry)\n", DNAME(d->dev));
@@ -424,7 +424,7 @@ static int can_proc_read_rcvlist_inv(char *page, char **start, off_t off,
 
                if (!hlist_empty(&d->rx_inv)) {
                        len = can_print_recv_banner(page, len);
-                       len = can_print_recv_list(page, len, &d->rx_inv, d->dev);
+                       len = can_print_rcvlist(page, len, &d->rx_inv, d->dev);
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
                                        "  (%s: no entry)\n", DNAME(d->dev));
@@ -465,8 +465,11 @@ static int can_proc_read_rcvlist_sff(char *page, char **start, off_t off,
                if (!all_empty) {
                        len = can_print_recv_banner(page, len);
                        for (i = 0; i < 0x800; i++) {
-                               if (!hlist_empty(&d->rx_sff[i]) && len < PAGE_SIZE - 100)
-                                       len = can_print_recv_list(page, len, &d->rx_sff[i], d->dev);
+                               if (!hlist_empty(&d->rx_sff[i]) &&
+                                   len < PAGE_SIZE - 100)
+                                       len = can_print_rcvlist(page, len,
+                                                               &d->rx_sff[i],
+                                                               d->dev);
                        }
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
@@ -500,7 +503,7 @@ static int can_proc_read_rcvlist_eff(char *page, char **start, off_t off,
 
                if (!hlist_empty(&d->rx_eff)) {
                        len = can_print_recv_banner(page, len);
-                       len = can_print_recv_list(page, len, &d->rx_eff, d->dev);
+                       len = can_print_rcvlist(page, len, &d->rx_eff, d->dev);
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
                                        "  (%s: no entry)\n", DNAME(d->dev));
@@ -533,7 +536,7 @@ static int can_proc_read_rcvlist_err(char *page, char **start, off_t off,
 
                if (!hlist_empty(&d->rx_err)) {
                        len = can_print_recv_banner(page, len);
-                       len = can_print_recv_list(page, len, &d->rx_err, d->dev);
+                       len = can_print_rcvlist(page, len, &d->rx_err, d->dev);
                } else
                        len += snprintf(page + len, PAGE_SIZE - len,
                                        "  (%s: no entry)\n", DNAME(d->dev));
@@ -553,15 +556,19 @@ static int can_proc_read_rcvlist_err(char *page, char **start, off_t off,
 /* proc utility functions                         */
 /**************************************************/
 
-static struct proc_dir_entry *can_create_proc_read_entry(const char *name, mode_t mode, read_proc_t* read_proc, void *data)
+static struct proc_dir_entry *can_create_proc_readentry(const char *name,
+                                                       mode_t mode,
+                                                       read_proc_t* read_proc,
+                                                       void *data)
 {
        if (can_dir)
-               return create_proc_read_entry(name, mode, can_dir, read_proc, data);
+               return create_proc_read_entry(name, mode, can_dir, read_proc,
+                                             data);
        else
                return NULL;
 }
 
-static void can_remove_proc_entry(const char *name)
+static void can_remove_proc_readentry(const char *name)
 {
        if (can_dir)
                remove_proc_entry(name, can_dir);
@@ -577,7 +584,8 @@ static unsigned long calc_rate(unsigned long oldjif, unsigned long newjif,
 
        /* see can_rcv() - this should NEVER happen! */
        if (count > (ULONG_MAX / HZ)) {
-               printk(KERN_ERR "af_can: calc_rate: count exceeded! %ld\n", count);
+               printk(KERN_ERR "CAN: calc_rate: count exceeded! %ld\n",
+                      count);
                return 99999999;
        }
 
@@ -601,7 +609,7 @@ static void can_stat_update(unsigned long data)
 {
        unsigned long j = jiffies; /* snapshot */
 
-       //DBG("af_can: can_stat_update() jiffies = %ld\n", j);
+       //DBG("CAN: can_stat_update() jiffies = %ld\n", j);
 
        if (j < stats.jiffies_init) /* jiffies overflow */
                can_init_stats(2);
@@ -618,10 +626,13 @@ static void can_stat_update(unsigned long data)
 
        /* calc total values */
        if (stats.rx_frames)
-               stats.total_rx_match_ratio = (stats.matches * 100) / stats.rx_frames;
+               stats.total_rx_match_ratio = (stats.matches * 100) / 
+                                               stats.rx_frames;
 
-       stats.total_tx_rate = calc_rate(stats.jiffies_init, j, stats.tx_frames);
-       stats.total_rx_rate = calc_rate(stats.jiffies_init, j, stats.rx_frames);
+       stats.total_tx_rate = calc_rate(stats.jiffies_init, j,
+                                       stats.tx_frames);
+       stats.total_rx_rate = calc_rate(stats.jiffies_init, j,
+                                       stats.rx_frames);
 
        /* calc current values */
        if (stats.rx_frames_delta)
index f38e2ed8b03e8d24f2355d1a9daf201dc5fca3be..897792999cbe078c1fc4adfb17172a02840b2e57 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * raw.c
+ * raw.c - Raw sockets for protocol family CAN
  *
- * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,8 @@
 RCSID("$Id$");
 
 #define IDENT "raw"
-static __initdata const char banner[] = KERN_INFO "CAN: raw socket protocol " VERSION "\n"; 
+static __initdata const char banner[] = KERN_INFO "CAN: raw socket protocol"
+                                       " " VERSION "\n"; 
 
 MODULE_DESCRIPTION("PF_CAN raw sockets");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -150,6 +151,8 @@ struct raw_opt {
 #define RAW_CAP CAP_NET_RAW
 #endif
 
+#undef CAN_RAW_SUPPORT_REBIND /* use bind on already bound socket */
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
 
 struct raw_sock {
@@ -244,7 +247,8 @@ static int raw_release(struct socket *sock)
 
        /* remove current error mask */
        if (ro->err_mask && ro->bound)
-               can_rx_unregister(dev, 0, ro->err_mask | CAN_ERR_FLAG, raw_rcv, sk);
+               can_rx_unregister(dev, 0, ro->err_mask | CAN_ERR_FLAG,
+                                 raw_rcv, sk);
 
        if (dev) {
                can_dev_unregister(dev, raw_notifier, sk);
@@ -269,9 +273,7 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
                return -EINVAL;
 
        if (ro->bound) {
-#if 1
-               return -EINVAL;
-#else
+#ifdef CAN_RAW_SUPPORT_REBIND
                /* remove current bindings / notifier */
                if (ro->ifindex) {
                        dev = dev_get_by_index(ro->ifindex);
@@ -297,6 +299,8 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
                        dev_put(dev);
 
                ro->bound = 0;
+#else
+               return -EINVAL;
 #endif
        }
 
@@ -321,7 +325,8 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
        raw_add_filters(dev, sk); /* filters set by default/setsockopt */
 
        if (ro->err_mask) /* error frame filter set by setsockopt */
-               can_rx_register(dev, 0, ro->err_mask | CAN_ERR_FLAG, raw_rcv, sk, IDENT);
+               can_rx_register(dev, 0, ro->err_mask | CAN_ERR_FLAG,
+                               raw_rcv, sk, IDENT);
 
        ro->bound = 1;
 
@@ -432,12 +437,14 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 
                /* remove current error mask */
                if (ro->err_mask && ro->bound)
-                       can_rx_unregister(dev, 0, ro->err_mask | CAN_ERR_FLAG, raw_rcv, sk);
+                       can_rx_unregister(dev, 0, ro->err_mask | CAN_ERR_FLAG,
+                                         raw_rcv, sk);
 
                /* add new error mask */
                ro->err_mask = err_mask;
                if (ro->err_mask && ro->bound)
-                       can_rx_register(dev, 0, ro->err_mask | CAN_ERR_FLAG, raw_rcv, sk, IDENT);
+                       can_rx_register(dev, 0, ro->err_mask | CAN_ERR_FLAG,
+                                       raw_rcv, sk, IDENT);
 
                if (dev)
                        dev_put(dev);
@@ -600,7 +607,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
        DBG("socket %p, sk %p\n", sock, sk);
 
        if (msg->msg_name) {
-               struct sockaddr_can *addr = (struct sockaddr_can *)msg->msg_name;
+               struct sockaddr_can *addr =
+                       (struct sockaddr_can *)msg->msg_name;
                if (addr->can_family != AF_CAN)
                        return -EINVAL;
                ifindex = addr->can_ifindex;
@@ -617,7 +625,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
                return -ENOMEM;
        }
 
-       if ((err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size)) < 0) {
+       if ((err = memcpy_fromiovec(skb_put(skb, size),
+                                   msg->msg_iov, size)) < 0) {
                kfree_skb(skb);
                dev_put(dev);
                return err;