From 04f487a2392d3903ad36862f8516e333bb566a72 Mon Sep 17 00:00:00 2001 From: hartkopp Date: Fri, 9 Mar 2007 16:35:09 +0000 Subject: [PATCH] Forgot to use kv to get rid of the #ifdef LINUX_VERION_CODE stuff. Now it's fixed. git-svn-id: svn://svn.berlios.de//socketcan/trunk@182 030b6a49-0b11-0410-94ab-b0dab22257f2 --- ...tworking-R180-2.6.21-rc3_2_New_Source.diff | 89 ++----------------- ...networking-R180-2.6.21-rc3_X_Complete.diff | 89 ++----------------- 2 files changed, 16 insertions(+), 162 deletions(-) diff --git a/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_2_New_Source.diff b/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_2_New_Source.diff index f068d1b..c1d5bdc 100644 --- a/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_2_New_Source.diff +++ b/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_2_New_Source.diff @@ -404,8 +404,8 @@ diff -N -u -r b/include/linux/can/bcm.h c/include/linux/can/bcm.h +#endif /* CAN_BCM_H */ diff -N -u -r b/include/linux/can/core.h c/include/linux/can/core.h --- b/include/linux/can/core.h 1970-01-01 01:00:00.000000000 +0100 -+++ c/include/linux/can/core.h 2007-03-08 12:03:06.000000000 +0100 -@@ -0,0 +1,62 @@ ++++ c/include/linux/can/core.h 2007-03-09 17:24:11.000000000 +0100 +@@ -0,0 +1,56 @@ +/* + * linux/can/core.h + * @@ -438,13 +438,7 @@ diff -N -u -r b/include/linux/can/core.h c/include/linux/can/core.h + int protocol; + int capability; + struct proto_ops *ops; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + struct proto *prot; -+#else -+ struct module *owner; -+ int (*init)(struct sock *sk); -+ size_t obj_size; -+#endif +}; + +/* function prototypes for the CAN networklayer core (af_can.c) */ @@ -729,8 +723,8 @@ diff -N -u -r b/include/linux/can.h c/include/linux/can.h +#endif /* CAN_H */ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c --- b/net/can/af_can.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/af_can.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,973 @@ ++++ c/net/can/af_can.c 2007-03-09 17:25:16.000000000 +0100 +@@ -0,0 +1,934 @@ +/* + * af_can.c - Protocol family CAN core module + * (used by different CAN protocol modules) @@ -836,13 +830,8 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c +static int can_notifier(struct notifier_block *nb, + unsigned long msg, void *data); +static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) +static int can_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev); -+#else -+static int can_rcv(struct sk_buff *skb, struct net_device *dev, -+ struct packet_type *pt); -+#endif +static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb); +static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev); +static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask, @@ -866,11 +855,7 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c +static struct dev_rcv_lists rx_alldev_list; +static spinlock_t rcv_lists_lock = SPIN_LOCK_UNLOCKED; + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) +static struct kmem_cache *rcv_cache __read_mostly; -+#else -+static kmem_cache_t *rcv_cache; -+#endif + +static struct packet_type can_packet = { + .type = __constant_htons(ETH_P_CAN), @@ -985,11 +970,9 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c + return; + } + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + if (proto_register(cp->prot, 0) != 0) { + return; + } -+#endif + proto_tab[proto] = cp; + + /* use generic ioctl function if the module doesn't bring its own */ @@ -1004,9 +987,7 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c + printk(KERN_ERR "CAN: protocol %d is not registered\n", proto); + return; + } -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + proto_unregister(cp->prot); -+#endif + proto_tab[proto] = NULL; +} + @@ -1093,34 +1074,17 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c + + sock->ops = cp->ops; + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + sk = sk_alloc(PF_CAN, GFP_KERNEL, cp->prot, 1); + if (!sk) + goto oom; -+#else -+ sk = sk_alloc(PF_CAN, GFP_KERNEL, 1, 0); -+ if (!sk) -+ goto oom; -+ if (cp->obj_size && -+ !(sk->sk_protinfo = kmalloc(cp->obj_size, GFP_KERNEL))) { -+ sk_free(sk); -+ goto oom; -+ } -+ sk_set_owner(sk, proto_tab[protocol]->owner); -+#endif + sock_init_data(sock, sk); + sk->sk_destruct = can_sock_destruct; + + DBG("created sock: %p\n", sk); + + ret = 0; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + if (sk->sk_prot->init) + ret = sk->sk_prot->init(sk); -+#else -+ if (cp->init) -+ ret = cp->init(sk); -+#endif + if (ret) { + /* we must release sk */ + sock_orphan(sk); @@ -1220,11 +1184,7 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c + case SIOCGSTAMP: + return sock_get_timestamp(sk, (struct timeval __user *)arg); + default: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + return -ENOIOCTLCMD; -+#else -+ return dev_ioctl(cmd, (void __user *)arg); -+#endif + } + return 0; +} @@ -1405,13 +1365,8 @@ diff -N -u -r b/net/can/af_can.c c/net/can/af_can.c + return ret; +} + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) +static int can_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) -+#else -+static int can_rcv(struct sk_buff *skb, struct net_device *dev, -+ struct packet_type *pt) -+#endif +{ + struct dev_rcv_lists *d; + int matches; @@ -1829,8 +1784,8 @@ diff -N -u -r b/net/can/af_can.h c/net/can/af_can.h +#endif /* AF_CAN_H */ diff -N -u -r b/net/can/bcm.c c/net/can/bcm.c --- b/net/can/bcm.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/bcm.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,1614 @@ ++++ c/net/can/bcm.c 2007-03-09 17:26:51.000000000 +0100 +@@ -0,0 +1,1600 @@ +/* + * bcm.c - Broadcast Manager to filter/send (cyclic) CAN content + * @@ -2027,7 +1982,6 @@ diff -N -u -r b/net/can/bcm.c c/net/can/bcm.c +#define BCM_CAP CAP_NET_RAW +#endif + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) +struct bcm_sock { + struct sock sk; + struct bcm_opt opt; @@ -2049,19 +2003,6 @@ diff -N -u -r b/net/can/bcm.c c/net/can/bcm.c + .ops = &bcm_ops, + .prot = &bcm_proto, +}; -+#else -+#define bcm_sk(sk) ((struct bcm_opt *)(sk)->sk_protinfo) -+ -+static struct can_proto bcm_can_proto = { -+ .type = SOCK_DGRAM, -+ .protocol = CAN_BCM, -+ .capability = BCM_CAP, -+ .ops = &bcm_ops, -+ .owner = THIS_MODULE, -+ .obj_size = sizeof(struct bcm_opt), -+ .init = bcm_init, -+}; -+#endif + +#define CFSIZ sizeof(struct can_frame) +#define OPSIZ sizeof(struct bcm_op) @@ -4205,8 +4146,8 @@ diff -N -u -r b/net/can/proc.c c/net/can/proc.c +} diff -N -u -r b/net/can/raw.c c/net/can/raw.c --- b/net/can/raw.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/raw.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,738 @@ ++++ c/net/can/raw.c 2007-03-09 17:27:37.000000000 +0100 +@@ -0,0 +1,724 @@ +/* + * raw.c - Raw sockets for protocol family CAN + * @@ -4360,7 +4301,6 @@ diff -N -u -r b/net/can/raw.c c/net/can/raw.c + +#undef CAN_RAW_SUPPORT_REBIND /* use bind on already bound socket */ + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) +struct raw_sock { + struct sock sk; + struct raw_opt opt; @@ -4382,19 +4322,6 @@ diff -N -u -r b/net/can/raw.c c/net/can/raw.c + .ops = &raw_ops, + .prot = &raw_proto, +}; -+#else -+#define raw_sk(sk) ((struct raw_opt *)(sk)->sk_protinfo) -+ -+static struct can_proto raw_can_proto = { -+ .type = SOCK_RAW, -+ .protocol = CAN_RAW, -+ .capability = RAW_CAP, -+ .ops = &raw_ops, -+ .owner = THIS_MODULE, -+ .obj_size = sizeof(struct raw_opt), -+ .init = raw_init, -+}; -+#endif + +#define MASK_ALL 0 + diff --git a/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_X_Complete.diff b/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_X_Complete.diff index 20a53d5..c2adc25 100644 --- a/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_X_Complete.diff +++ b/patches/linux-2.6.21-rc3/can-networking-R180-2.6.21-rc3_X_Complete.diff @@ -448,8 +448,8 @@ diff -N -u -r a/include/linux/can/bcm.h c/include/linux/can/bcm.h +#endif /* CAN_BCM_H */ diff -N -u -r a/include/linux/can/core.h c/include/linux/can/core.h --- a/include/linux/can/core.h 1970-01-01 01:00:00.000000000 +0100 -+++ c/include/linux/can/core.h 2007-03-08 12:03:06.000000000 +0100 -@@ -0,0 +1,62 @@ ++++ c/include/linux/can/core.h 2007-03-09 17:24:11.000000000 +0100 +@@ -0,0 +1,56 @@ +/* + * linux/can/core.h + * @@ -482,13 +482,7 @@ diff -N -u -r a/include/linux/can/core.h c/include/linux/can/core.h + int protocol; + int capability; + struct proto_ops *ops; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + struct proto *prot; -+#else -+ struct module *owner; -+ int (*init)(struct sock *sk); -+ size_t obj_size; -+#endif +}; + +/* function prototypes for the CAN networklayer core (af_can.c) */ @@ -853,8 +847,8 @@ diff -N -u -r a/MAINTAINERS c/MAINTAINERS M: muli@il.ibm.com diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c --- a/net/can/af_can.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/af_can.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,973 @@ ++++ c/net/can/af_can.c 2007-03-09 17:25:16.000000000 +0100 +@@ -0,0 +1,934 @@ +/* + * af_can.c - Protocol family CAN core module + * (used by different CAN protocol modules) @@ -960,13 +954,8 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c +static int can_notifier(struct notifier_block *nb, + unsigned long msg, void *data); +static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) +static int can_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev); -+#else -+static int can_rcv(struct sk_buff *skb, struct net_device *dev, -+ struct packet_type *pt); -+#endif +static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb); +static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev); +static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask, @@ -990,11 +979,7 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c +static struct dev_rcv_lists rx_alldev_list; +static spinlock_t rcv_lists_lock = SPIN_LOCK_UNLOCKED; + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) +static struct kmem_cache *rcv_cache __read_mostly; -+#else -+static kmem_cache_t *rcv_cache; -+#endif + +static struct packet_type can_packet = { + .type = __constant_htons(ETH_P_CAN), @@ -1109,11 +1094,9 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c + return; + } + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + if (proto_register(cp->prot, 0) != 0) { + return; + } -+#endif + proto_tab[proto] = cp; + + /* use generic ioctl function if the module doesn't bring its own */ @@ -1128,9 +1111,7 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c + printk(KERN_ERR "CAN: protocol %d is not registered\n", proto); + return; + } -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + proto_unregister(cp->prot); -+#endif + proto_tab[proto] = NULL; +} + @@ -1217,34 +1198,17 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c + + sock->ops = cp->ops; + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + sk = sk_alloc(PF_CAN, GFP_KERNEL, cp->prot, 1); + if (!sk) + goto oom; -+#else -+ sk = sk_alloc(PF_CAN, GFP_KERNEL, 1, 0); -+ if (!sk) -+ goto oom; -+ if (cp->obj_size && -+ !(sk->sk_protinfo = kmalloc(cp->obj_size, GFP_KERNEL))) { -+ sk_free(sk); -+ goto oom; -+ } -+ sk_set_owner(sk, proto_tab[protocol]->owner); -+#endif + sock_init_data(sock, sk); + sk->sk_destruct = can_sock_destruct; + + DBG("created sock: %p\n", sk); + + ret = 0; -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) + if (sk->sk_prot->init) + ret = sk->sk_prot->init(sk); -+#else -+ if (cp->init) -+ ret = cp->init(sk); -+#endif + if (ret) { + /* we must release sk */ + sock_orphan(sk); @@ -1344,11 +1308,7 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c + case SIOCGSTAMP: + return sock_get_timestamp(sk, (struct timeval __user *)arg); + default: -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + return -ENOIOCTLCMD; -+#else -+ return dev_ioctl(cmd, (void __user *)arg); -+#endif + } + return 0; +} @@ -1529,13 +1489,8 @@ diff -N -u -r a/net/can/af_can.c c/net/can/af_can.c + return ret; +} + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) +static int can_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) -+#else -+static int can_rcv(struct sk_buff *skb, struct net_device *dev, -+ struct packet_type *pt) -+#endif +{ + struct dev_rcv_lists *d; + int matches; @@ -1953,8 +1908,8 @@ diff -N -u -r a/net/can/af_can.h c/net/can/af_can.h +#endif /* AF_CAN_H */ diff -N -u -r a/net/can/bcm.c c/net/can/bcm.c --- a/net/can/bcm.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/bcm.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,1614 @@ ++++ c/net/can/bcm.c 2007-03-09 17:26:51.000000000 +0100 +@@ -0,0 +1,1600 @@ +/* + * bcm.c - Broadcast Manager to filter/send (cyclic) CAN content + * @@ -2151,7 +2106,6 @@ diff -N -u -r a/net/can/bcm.c c/net/can/bcm.c +#define BCM_CAP CAP_NET_RAW +#endif + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) +struct bcm_sock { + struct sock sk; + struct bcm_opt opt; @@ -2173,19 +2127,6 @@ diff -N -u -r a/net/can/bcm.c c/net/can/bcm.c + .ops = &bcm_ops, + .prot = &bcm_proto, +}; -+#else -+#define bcm_sk(sk) ((struct bcm_opt *)(sk)->sk_protinfo) -+ -+static struct can_proto bcm_can_proto = { -+ .type = SOCK_DGRAM, -+ .protocol = CAN_BCM, -+ .capability = BCM_CAP, -+ .ops = &bcm_ops, -+ .owner = THIS_MODULE, -+ .obj_size = sizeof(struct bcm_opt), -+ .init = bcm_init, -+}; -+#endif + +#define CFSIZ sizeof(struct can_frame) +#define OPSIZ sizeof(struct bcm_op) @@ -4329,8 +4270,8 @@ diff -N -u -r a/net/can/proc.c c/net/can/proc.c +} diff -N -u -r a/net/can/raw.c c/net/can/raw.c --- a/net/can/raw.c 1970-01-01 01:00:00.000000000 +0100 -+++ c/net/can/raw.c 2007-03-09 13:47:12.000000000 +0100 -@@ -0,0 +1,738 @@ ++++ c/net/can/raw.c 2007-03-09 17:27:37.000000000 +0100 +@@ -0,0 +1,724 @@ +/* + * raw.c - Raw sockets for protocol family CAN + * @@ -4484,7 +4425,6 @@ diff -N -u -r a/net/can/raw.c c/net/can/raw.c + +#undef CAN_RAW_SUPPORT_REBIND /* use bind on already bound socket */ + -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) +struct raw_sock { + struct sock sk; + struct raw_opt opt; @@ -4506,19 +4446,6 @@ diff -N -u -r a/net/can/raw.c c/net/can/raw.c + .ops = &raw_ops, + .prot = &raw_proto, +}; -+#else -+#define raw_sk(sk) ((struct raw_opt *)(sk)->sk_protinfo) -+ -+static struct can_proto raw_can_proto = { -+ .type = SOCK_RAW, -+ .protocol = CAN_RAW, -+ .capability = RAW_CAP, -+ .ops = &raw_ops, -+ .owner = THIS_MODULE, -+ .obj_size = sizeof(struct raw_opt), -+ .init = raw_init, -+}; -+#endif + +#define MASK_ALL 0 + -- 2.39.2