#include <net/sock.h>
#include "af_can.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#include "compat.h"
+#endif
#include <linux/can/version.h> /* for RCSID. Removed by mkpatch script */
RCSID("$Id$");
struct s_stats can_stats; /* packet statistics */
struct s_pstats can_pstats; /* receive list statistics */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-static void *kzalloc(size_t size, unsigned int __nocast flags)
-{
- void *ret = kmalloc(size, flags);
- if (ret)
- memset(ret, 0, size);
- return ret;
-}
-#endif
-
/*
* af_can socket functions
*/
if (stats_timer) {
/* the statistics are updated every second (timer triggered) */
setup_timer(&can_stattimer, can_stat_update, 0);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
mod_timer(&can_stattimer, round_jiffies(jiffies + HZ));
-#else
- mod_timer(&can_stattimer, jiffies + HZ);
-#endif
} else
can_stattimer.function = NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#include <net/net_namespace.h>
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#include "compat.h"
+#endif
#include <linux/can/version.h> /* for RCSID. Removed by mkpatch script */
RCSID("$Id$");
#endif
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-static void *kzalloc(size_t size, unsigned int __nocast flags)
-{
- void *ret = kmalloc(size, flags);
-
- if (ret)
- memset(ret, 0, size);
-
- return ret;
-}
-
-static inline void skb_get_timestamp(const struct sk_buff *skb,
- struct timeval *stamp)
-{
- stamp->tv_sec = skb->stamp.tv_sec;
- stamp->tv_usec = skb->stamp.tv_usec;
-}
-
-static inline void skb_set_timestamp(struct sk_buff *skb,
- const struct timeval *stamp)
-{
- skb->stamp.tv_sec = stamp->tv_sec;
- skb->stamp.tv_usec = stamp->tv_usec;
-}
-#endif
-
#define CFSIZ sizeof(struct can_frame)
#define OPSIZ sizeof(struct bcm_op)
#define MHSIZ sizeof(struct bcm_msg_head)
return "any";
/* no usage counting */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = __dev_get_by_index(&init_net, ifindex);
-#else
- dev = __dev_get_by_index(ifindex);
-#endif
if (dev)
return dev->name;
if (!op->ifindex)
return;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, op->ifindex);
-#else
- dev = dev_get_by_index(op->ifindex);
-#endif
if (!dev) {
/* RFC: should this bcm_op remove itself here? */
return;
if (op->rx_reg_dev) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net,
op->ifindex);
-#else
- dev = dev_get_by_index(op->ifindex);
-#endif
if (dev) {
bcm_rx_unreg(dev, op);
dev_put(dev);
if (ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ifindex);
-#else
- dev = dev_get_by_index(ifindex);
-#endif
if (dev) {
err = can_rx_register(dev, op->can_id,
REGMASK(op->can_id),
return err;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ifindex);
-#else
- dev = dev_get_by_index(ifindex);
-#endif
if (!dev) {
kfree_skb(skb);
return -ENODEV;
if (ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ifindex);
-#else
- dev = dev_get_by_index(ifindex);
-#endif
if (!dev)
return -ENODEV;
if (op->rx_reg_dev) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, op->ifindex);
-#else
- dev = dev_get_by_index(op->ifindex);
-#endif
if (dev) {
bcm_rx_unreg(dev, op);
dev_put(dev);
if (addr->can_ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, addr->can_ifindex);
-#else
- dev = dev_get_by_index(addr->can_ifindex);
-#endif
if (!dev)
return -ENODEV;
--- /dev/null
+/*
+ * $Id$
+ */
+
+#ifndef CAN_COMPAT_H
+#define CAN_COMPAT_H
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+static inline void *kzalloc(size_t size, unsigned int __nocast flags)
+{
+ void *ret = kmalloc(size, flags);
+ if (ret)
+ memset(ret, 0, size);
+ return ret;
+}
+
+static inline void skb_get_timestamp(const struct sk_buff *skb,
+ struct timeval *stamp)
+{
+ stamp->tv_sec = skb->stamp.tv_sec;
+ stamp->tv_usec = skb->stamp.tv_usec;
+}
+
+static inline void skb_set_timestamp(struct sk_buff *skb,
+ const struct timeval *stamp)
+{
+ skb->stamp.tv_sec = stamp->tv_sec;
+ skb->stamp.tv_usec = stamp->tv_usec;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#define round_jiffies(j) (j)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+#define dev_get_by_index(ns, ifindex) dev_get_by_index(ifindex)
+#define __dev_get_by_index(ns, ifindex) __dev_get_by_index(ifindex)
+#endif
+
+#endif
#include <linux/can/core.h>
#include "af_can.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#include "compat.h"
+#endif
#include <linux/can/version.h> /* for RCSID. Removed by mkpatch script */
RCSID("$Id$");
can_stats.matches_delta = 0;
/* restart timer (one second) */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
mod_timer(&can_stattimer, round_jiffies(jiffies + HZ));
-#else
- mod_timer(&can_stattimer, jiffies + HZ);
-#endif
}
/*
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#include <net/net_namespace.h>
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#include "compat.h"
+#endif
#include <linux/can/version.h> /* for RCSID. Removed by mkpatch script */
RCSID("$Id$");
if (ro->ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ro->ifindex);
-#else
- dev = dev_get_by_index(ro->ifindex);
-#endif
if (dev) {
raw_disable_allfilters(dev, sk);
dev_put(dev);
if (addr->can_ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, addr->can_ifindex);
-#else
- dev = dev_get_by_index(addr->can_ifindex);
-#endif
if (!dev) {
err = -ENODEV;
goto out;
if (ro->ifindex) {
struct net_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ro->ifindex);
-#else
- dev = dev_get_by_index(ro->ifindex);
-#endif
if (dev) {
raw_disable_allfilters(dev, sk);
dev_put(dev);
lock_sock(sk);
if (ro->bound && ro->ifindex)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ro->ifindex);
-#else
- dev = dev_get_by_index(ro->ifindex);
-#endif
if (ro->bound) {
/* (try to) register the new filters */
lock_sock(sk);
if (ro->bound && ro->ifindex)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ro->ifindex);
-#else
- dev = dev_get_by_index(ro->ifindex);
-#endif
/* remove current error mask */
if (ro->bound) {
} else
ifindex = ro->ifindex;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ifindex);
-#else
- dev = dev_get_by_index(ifindex);
-#endif
if (!dev)
return -ENXIO;