Remove 2.6 conditionals in master

This commit is contained in:
Bjarne von Horn
2023-12-12 12:26:57 +01:00
parent f77a746b26
commit 543dc87d88
7 changed files with 1 additions and 140 deletions

View File

@@ -57,7 +57,6 @@ static int eccdev_mmap(struct file *, struct vm_area_struct *);
/** This is the kernel version from which the .fault member of the
* vm_operations_struct is usable.
*/
#define PAGE_FAULT_VERSION KERNEL_VERSION(2, 6, 23)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
# define FAULT_RETURN_TYPE int
@@ -65,16 +64,11 @@ static int eccdev_mmap(struct file *, struct vm_area_struct *);
# define FAULT_RETURN_TYPE vm_fault_t
#endif
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION
static FAULT_RETURN_TYPE eccdev_vma_fault(
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
struct vm_area_struct *,
#endif
struct vm_fault *);
#else
static struct page *eccdev_vma_nopage(
struct vm_area_struct *, unsigned long, int *);
#endif
/*****************************************************************************/
@@ -91,11 +85,7 @@ static struct file_operations eccdev_fops = {
/** Callbacks for a virtual memory area retrieved with ecdevc_mmap().
*/
struct vm_operations_struct eccdev_vm_ops = {
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION
.fault = eccdev_vma_fault
#else
.nopage = eccdev_vma_nopage
#endif
};
/*****************************************************************************/
@@ -255,8 +245,6 @@ int eccdev_mmap(
/*****************************************************************************/
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION
/** Page fault callback for a virtual memory area.
*
* Called at the first access on a virtual-memory area retrieved with
@@ -296,42 +284,4 @@ static FAULT_RETURN_TYPE eccdev_vma_fault(
return 0;
}
#else
/** Nopage callback for a virtual memory area.
*
* Called at the first access on a virtual-memory area retrieved with
* ecdev_mmap().
*/
struct page *eccdev_vma_nopage(
struct vm_area_struct *vma, /**< Virtual memory area initialized by
the kernel. */
unsigned long address, /**< Requested virtual address. */
int *type /**< Type output parameter. */
)
{
unsigned long offset;
struct page *page = NOPAGE_SIGBUS;
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data;
ec_master_t *master = priv->cdev->master;
offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
if (offset >= priv->ctx.process_data_size)
return NOPAGE_SIGBUS;
page = vmalloc_to_page(priv->ctx.process_data + offset);
EC_MASTER_DBG(master, 1, "Nopage fault vma, address = %#lx,"
" offset = %#lx, page = %p\n", address, offset, page);
get_page(page);
if (type)
*type = VM_FAULT_MINOR;
return page;
}
#endif
/*****************************************************************************/

View File

@@ -50,7 +50,6 @@ int ec_dbgdev_stop(struct net_device *);
int ec_dbgdev_tx(struct sk_buff *, struct net_device *);
struct net_device_stats *ec_dbgdev_stats(struct net_device *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
/** Device operations for debug interfaces.
*/
static const struct net_device_ops ec_dbg_netdev_ops =
@@ -60,7 +59,6 @@ static const struct net_device_ops ec_dbg_netdev_ops =
.ndo_start_xmit = ec_dbgdev_tx,
.ndo_get_stats = ec_dbgdev_stats,
};
#endif
/*****************************************************************************/
@@ -88,7 +86,7 @@ int ec_debug_init(
#else
dbg->dev = alloc_netdev(sizeof(ec_debug_t *), name, ether_setup);
#endif
if (!(dbg->dev))
if (!(dbg->dev))
{
EC_MASTER_ERR(device->master, "Unable to allocate net_device"
" for debug object!\n");
@@ -96,14 +94,7 @@ int ec_debug_init(
}
// initialize net_device
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
dbg->dev->netdev_ops = &ec_dbg_netdev_ops;
#else
dbg->dev->open = ec_dbgdev_open;
dbg->dev->stop = ec_dbgdev_stop;
dbg->dev->hard_start_xmit = ec_dbgdev_tx;
dbg->dev->get_stats = ec_dbgdev_stats;
#endif
// initialize private data
*((ec_debug_t **) netdev_priv(dbg->dev)) = dbg;

View File

@@ -264,11 +264,7 @@ int ec_device_open(
ec_device_clear_stats(device);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
ret = device->dev->netdev_ops->ndo_open(device->dev);
#else
ret = device->dev->open(device->dev);
#endif
if (!ret)
device->open = 1;
@@ -297,11 +293,7 @@ int ec_device_close(
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
ret = device->dev->netdev_ops->ndo_stop(device->dev);
#else
ret = device->dev->stop(device->dev);
#endif
if (!ret)
device->open = 0;
@@ -349,12 +341,8 @@ void ec_device_send(
}
// start sending
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
if (device->dev->netdev_ops->ndo_start_xmit(skb, device->dev) ==
NETDEV_TX_OK)
#else
if (device->dev->hard_start_xmit(skb, device->dev) == NETDEV_TX_OK)
#endif
{
device->tx_count++;
device->master->device_stats.tx_count++;

View File

@@ -82,7 +82,6 @@ struct net_device_stats *ec_eoedev_stats(struct net_device *);
/*****************************************************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
/** Device operations for EoE interfaces.
*/
static const struct net_device_ops ec_eoedev_ops = {
@@ -91,7 +90,6 @@ static const struct net_device_ops ec_eoedev_ops = {
.ndo_start_xmit = ec_eoedev_tx,
.ndo_get_stats = ec_eoedev_stats,
};
#endif
/*****************************************************************************/
@@ -163,14 +161,7 @@ int ec_eoe_init(
}
// initialize net_device
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
eoe->dev->netdev_ops = &ec_eoedev_ops;
#else
eoe->dev->open = ec_eoedev_open;
eoe->dev->stop = ec_eoedev_stop;
eoe->dev->hard_start_xmit = ec_eoedev_tx;
eoe->dev->get_stats = ec_eoedev_stats;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
eth_hw_addr_set(eoe->dev, mac_addr);

View File

@@ -40,11 +40,7 @@
#include <linux/list.h>
#include <linux/netdevice.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
#include <linux/semaphore.h>
#else
#include <asm/semaphore.h>
#endif
#include "globals.h"
#include "slave.h"

View File

@@ -326,23 +326,9 @@ int ec_master_init(ec_master_t *master, /**< EtherCAT master */
if (ret)
goto out_clear_sync_mon;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
master->class_device = device_create(class, NULL,
MKDEV(MAJOR(device_number), master->index), NULL,
"EtherCAT%u", master->index);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
master->class_device = device_create(class, NULL,
MKDEV(MAJOR(device_number), master->index),
"EtherCAT%u", master->index);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
master->class_device = class_device_create(class, NULL,
MKDEV(MAJOR(device_number), master->index), NULL,
"EtherCAT%u", master->index);
#else
master->class_device = class_device_create(class,
MKDEV(MAJOR(device_number), master->index), NULL,
"EtherCAT%u", master->index);
#endif
if (IS_ERR(master->class_device)) {
EC_MASTER_ERR(master, "Failed to create class device!\n");
ret = PTR_ERR(master->class_device);
@@ -361,11 +347,7 @@ int ec_master_init(ec_master_t *master, /**< EtherCAT master */
#ifdef EC_RTDM
out_unregister_class_device:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
device_unregister(master->class_device);
#else
class_device_unregister(master->class_device);
#endif
#endif
out_clear_cdev:
ec_cdev_clear(&master->cdev);
@@ -402,11 +384,7 @@ void ec_master_clear(
ec_rtdm_dev_clear(&master->rtdm_dev);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
device_unregister(master->class_device);
#else
class_device_unregister(master->class_device);
#endif
ec_cdev_clear(&master->cdev);
@@ -1404,22 +1382,6 @@ static enum hrtimer_restart ec_master_nanosleep_wakeup(struct hrtimer *timer)
/*****************************************************************************/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
/* compatibility with new hrtimer interface */
static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
{
return timer->expires;
}
/*****************************************************************************/
static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
{
timer->expires = time;
}
#endif
/*****************************************************************************/
@@ -1431,15 +1393,6 @@ void ec_master_nanosleep(const unsigned long nsecs)
hrtimer_init(&t.timer, CLOCK_MONOTONIC, mode);
t.timer.function = ec_master_nanosleep_wakeup;
t.task = current;
#ifdef CONFIG_HIGH_RES_TIMERS
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART;
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26)
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28)
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED;
#endif
#endif
hrtimer_set_expires(&t.timer, ktime_set(0, nsecs));
do {

View File

@@ -43,11 +43,7 @@
#include <linux/wait.h>
#include <linux/kthread.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
#include <linux/semaphore.h>
#else
#include <asm/semaphore.h>
#endif
#include "device.h"
#include "domain.h"
@@ -196,11 +192,7 @@ struct ec_master {
unsigned int reserved; /**< \a True, if the master is in use. */
ec_cdev_t cdev; /**< Master character device. */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
struct device *class_device; /**< Master class device. */
#else
struct class_device *class_device; /**< Master class device. */
#endif
#ifdef EC_RTDM
ec_rtdm_dev_t rtdm_dev; /**< RTDM device. */