merged e100 for 2.6.27.
authorFlorian Pose <fp@igh-essen.com>
Wed, 21 Oct 2009 18:49:47 +0200
changeset 1547 e6f664477a46
parent 1545 cd9672f63886 (diff)
parent 1546 f60cf2500bf8 (current diff)
child 1549 68d2af150381
merged e100 for 2.6.27.
devices/Makefile.am
--- a/TODO	Wed Sep 30 21:14:40 2009 +0200
+++ b/TODO	Wed Oct 21 18:49:47 2009 +0200
@@ -54,6 +54,11 @@
 * Change SDO index at runtime for SDO request.
 * Implement ecrt_slave_config_request_state().
 * Output skipped datagrams again.
+* Output warning on unmatched slave configuration.
+* ec_direction_t default
+* Send_ext context warn
+* XML hex
+* r8169
 
 Future issues:
 
--- a/configure.ac	Wed Sep 30 21:14:40 2009 +0200
+++ b/configure.ac	Wed Oct 21 18:49:47 2009 +0200
@@ -102,6 +102,29 @@
 AC_MSG_RESULT([$LINUX_SOURCE_DIR (Kernel $LINUX_KERNEL_RELEASE)])
 
 #------------------------------------------------------------------------------
+# Generic Ethernet driver
+#------------------------------------------------------------------------------
+
+AC_ARG_ENABLE([generic],
+    AS_HELP_STRING([--enable-generic],
+                   [Enable generic Ethernet driver]),
+    [
+        case "${enableval}" in
+            yes) enablegeneric=1
+                ;;
+            no) enablegeneric=0
+                ;;
+            *) AC_MSG_ERROR([Invalid value for --enable-generic])
+                ;;
+        esac
+    ],
+    [enablegeneric=0]
+)
+
+AM_CONDITIONAL(ENABLE_GENERIC, test "x$enablegeneric" = "x1")
+AC_SUBST(ENABLE_GENERIC,[$enablegeneric])
+
+#------------------------------------------------------------------------------
 # 8139too driver
 #------------------------------------------------------------------------------
 
--- a/devices/Kbuild.in	Wed Sep 30 21:14:40 2009 +0200
+++ b/devices/Kbuild.in	Wed Oct 21 18:49:47 2009 +0200
@@ -37,6 +37,13 @@
 		hg id -i $(src)/.. 2>/dev/null || echo "unknown"; \
 	fi)
 
+ifeq (@ENABLE_GENERIC@,1)
+	EC_GENERIC_OBJ := generic.o
+	obj-m += ec_generic.o
+	ec_generic-objs := $(EC_GENERIC_OBJ)
+	CFLAGS_$(EC_GENERIC_OBJ) = -DREV=$(REV)
+endif
+
 ifeq (@ENABLE_8139TOO@,1)
 	EC_8139TOO_OBJ := 8139too-@KERNEL_8139TOO@-ethercat.o
 	obj-m += ec_8139too.o
--- a/devices/Makefile.am	Wed Sep 30 21:14:40 2009 +0200
+++ b/devices/Makefile.am	Wed Oct 21 18:49:47 2009 +0200
@@ -70,6 +70,7 @@
 	e100-2.6.29-ethercat.c \
 	e100-2.6.29-orig.c \
 	ecdev.h \
+	generic.c \
 	r8169-2.6.24-ethercat.c \
 	r8169-2.6.24-orig.c \
 	r8169-2.6.28-ethercat.c \
@@ -88,6 +89,9 @@
 
 modules_install:
 	mkdir -p $(DESTDIR)$(LINUX_MOD_PATH)
+if ENABLE_GENERIC
+	cp $(srcdir)/ec_generic.ko $(DESTDIR)$(LINUX_MOD_PATH)
+endif
 if ENABLE_8139TOO
 	cp $(srcdir)/ec_8139too.ko $(DESTDIR)$(LINUX_MOD_PATH)
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devices/generic.c	Wed Oct 21 18:49:47 2009 +0200
@@ -0,0 +1,407 @@
+/******************************************************************************
+ *
+ *  $Id$
+ *
+ *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
+ *
+ *  This file is part of the IgH EtherCAT Master.
+ *
+ *  The IgH EtherCAT Master is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License version 2, as
+ *  published by the Free Software Foundation.
+ *
+ *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+ *  Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with the IgH EtherCAT Master; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *  ---
+ *
+ *  The license mentioned above concerns the source code only. Using the
+ *  EtherCAT technology and brand is only permitted in compliance with the
+ *  industrial property and similar rights of Beckhoff Automation GmbH.
+ *
+ *****************************************************************************/
+
+/** \file
+ * EtherCAT generic Ethernet device module.
+ */
+
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/version.h>
+#include <linux/if_arp.h> /* ARPHRD_ETHER */
+#include <linux/etherdevice.h>
+
+#include "../globals.h"
+#include "ecdev.h"
+
+#define PFX "ec_generic: "
+
+#define ETH_P_ETHERCAT 0x88A4
+
+/*****************************************************************************/
+
+int __init ec_gen_init_module(void);
+void __exit ec_gen_cleanup_module(void);
+
+/*****************************************************************************/
+
+/** \cond */
+
+MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
+MODULE_DESCRIPTION("EtherCAT master generic Ethernet device module");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(EC_MASTER_VERSION);
+
+/** \endcond */
+
+struct list_head generic_devices;
+
+typedef struct {
+    struct list_head list;
+    struct net_device *netdev;
+    struct socket *socket;
+    ec_device_t *ecdev;
+} ec_gen_device_t;
+
+int ec_gen_device_open(ec_gen_device_t *);
+int ec_gen_device_stop(ec_gen_device_t *);
+int ec_gen_device_start_xmit(ec_gen_device_t *, struct sk_buff *);
+void ec_gen_device_poll(ec_gen_device_t *);
+
+/*****************************************************************************/
+
+static int ec_gen_netdev_open(struct net_device *dev)
+{
+    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
+    return ec_gen_device_open(gendev);
+}
+
+/*****************************************************************************/
+
+static int ec_gen_netdev_stop(struct net_device *dev)
+{
+    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
+    return ec_gen_device_stop(gendev);
+}
+
+/*****************************************************************************/
+
+static int ec_gen_netdev_start_xmit(
+        struct sk_buff *skb,
+        struct net_device *dev
+        )
+{
+    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
+    return ec_gen_device_start_xmit(gendev, skb);
+}
+
+/*****************************************************************************/
+
+void ec_gen_poll(struct net_device *dev)
+{
+    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
+    ec_gen_device_poll(gendev);
+}
+
+/*****************************************************************************/
+
+static const struct net_device_ops ec_gen_netdev_ops = {
+	.ndo_open		= ec_gen_netdev_open,
+	.ndo_stop		= ec_gen_netdev_stop,
+	.ndo_start_xmit	= ec_gen_netdev_start_xmit,
+};
+
+/*****************************************************************************/
+
+/** Init generic device.
+ */
+int ec_gen_device_init(
+        ec_gen_device_t *dev,
+        struct net_device *real_netdev
+        )
+{
+    ec_gen_device_t **priv;
+    char null = 0x00;
+
+    dev->ecdev = NULL;
+    dev->socket = NULL;
+
+	dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
+	if (!dev->netdev) {
+		return -ENOMEM;
+	}
+    memcpy(dev->netdev->dev_addr, real_netdev->dev_addr, ETH_ALEN);
+    dev->netdev->netdev_ops = &ec_gen_netdev_ops;
+    priv = netdev_priv(dev->netdev);
+    *priv = dev;
+
+    return 0;
+}
+
+/*****************************************************************************/
+
+/** Clear generic device.
+ */
+void ec_gen_device_clear(
+        ec_gen_device_t *dev
+        )
+{
+    if (dev->ecdev) {
+        ecdev_close(dev->ecdev);
+        ecdev_withdraw(dev->ecdev);
+    }
+    if (dev->socket) {
+        sock_release(dev->socket);
+    }
+    free_netdev(dev->netdev);
+}
+
+/*****************************************************************************/
+
+/** Creates a network socket.
+ */
+int ec_gen_device_create_socket(
+        ec_gen_device_t *dev,
+        struct net_device *real_netdev
+        )
+{
+    int ret;
+    struct sockaddr_ll sa;
+
+    ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT), &dev->socket);
+    if (ret) {
+        printk(KERN_ERR PFX "Failed to create socket.\n");
+        return ret;
+    }
+
+    printk(KERN_ERR PFX "Binding socket to interface %i (%s).\n",
+            real_netdev->ifindex, real_netdev->name);
+
+    memset(&sa, 0x00, sizeof(sa));
+    sa.sll_family = AF_PACKET;
+    sa.sll_protocol = htons(ETH_P_ETHERCAT);
+    sa.sll_ifindex = real_netdev->ifindex;
+    ret = kernel_bind(dev->socket, (struct sockaddr *) &sa, sizeof(sa));
+    if (ret) {
+        printk(KERN_ERR PFX "Failed to bind() socket to interface.\n");
+        sock_release(dev->socket);
+        dev->socket = NULL;
+        return ret;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************/
+
+/** Offer generic device to master.
+ */
+int ec_gen_device_offer(
+        ec_gen_device_t *dev,
+        struct net_device *real_netdev
+        )
+{
+    int ret = 0;
+
+	dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
+    if (dev->ecdev) {
+        if (ec_gen_device_create_socket(dev, real_netdev)) {
+            ecdev_withdraw(dev->ecdev);
+            dev->ecdev = NULL;
+        } else if (ecdev_open(dev->ecdev)) {
+            ecdev_withdraw(dev->ecdev);
+            dev->ecdev = NULL;
+        } else {
+            ecdev_set_link(dev->ecdev, 1); // FIXME
+            ret = 1;
+        }
+    }
+
+    return ret;
+}
+
+/*****************************************************************************/
+
+/** Open the device.
+ */
+int ec_gen_device_open(
+        ec_gen_device_t *dev
+        )
+{
+    return 0;
+}
+
+/*****************************************************************************/
+
+/** Stop the device.
+ */
+int ec_gen_device_stop(
+        ec_gen_device_t *dev
+        )
+{
+    return 0;
+}
+
+/*****************************************************************************/
+
+int ec_gen_device_start_xmit(
+        ec_gen_device_t *dev,
+        struct sk_buff *skb
+        )
+{
+    struct msghdr msg;
+    struct kvec iov;
+    size_t len = skb->len;
+    int ret;
+
+    iov.iov_base = skb->data;
+    iov.iov_len = len;
+    memset(&msg, 0, sizeof(msg));
+
+    ret = kernel_sendmsg(dev->socket, &msg, &iov, 1, len);
+
+    return ret == len ? NETDEV_TX_OK : NETDEV_TX_BUSY;
+}
+
+/*****************************************************************************/
+
+/** Polls the device.
+ */
+void ec_gen_device_poll(
+        ec_gen_device_t *dev
+        )
+{
+    struct msghdr msg;
+    struct kvec iov;
+    char buf[2000]; // FIXME
+    int ret, budget = 10; // FIXME
+
+    iov.iov_base = buf;
+    iov.iov_len = 2000;
+    memset(&msg, 0, sizeof(msg));
+
+    do {
+        ret = kernel_recvmsg(dev->socket, &msg, &iov, 1, iov.iov_len,
+                MSG_DONTWAIT);
+        if (ret > 0) {
+            ecdev_receive(dev->ecdev, buf, ret);
+        } else if (ret < 0) {
+            break;
+        }
+        budget--;
+    } while (budget);
+}
+
+/*****************************************************************************/
+
+/** Offer device.
+ */
+int offer_device(
+        struct net_device *netdev
+        )
+{
+    ec_gen_device_t *gendev;
+    int ret = 0;
+
+    gendev = kmalloc(sizeof(ec_gen_device_t), GFP_KERNEL);
+    if (!gendev) {
+        return -ENOMEM;
+    }
+
+    ret = ec_gen_device_init(gendev, netdev);
+    if (ret) {
+        kfree(gendev);
+        return ret;
+    }
+
+    if (ec_gen_device_offer(gendev, netdev)) {
+        list_add_tail(&gendev->list, &generic_devices);
+    } else {
+        ec_gen_device_clear(gendev);
+        kfree(gendev);
+    }
+
+    return ret;
+}
+
+/*****************************************************************************/
+
+/** Clear devices.
+ */
+void clear_devices(void)
+{
+    ec_gen_device_t *gendev, *next;
+
+    list_for_each_entry_safe(gendev, next, &generic_devices, list) {
+        list_del(&gendev->list);
+        ec_gen_device_clear(gendev);
+        kfree(gendev);
+    }
+}
+
+/*****************************************************************************/
+
+/** Module initialization.
+ *
+ * Initializes \a master_count masters.
+ * \return 0 on success, else < 0
+ */
+int __init ec_gen_init_module(void)
+{
+    int ret = 0;
+    struct net_device *netdev;
+
+    printk(KERN_INFO PFX "EtherCAT master generic Ethernet device module %s\n",
+            EC_MASTER_VERSION);
+
+    INIT_LIST_HEAD(&generic_devices);
+
+    read_lock(&dev_base_lock);
+    for_each_netdev(&init_net, netdev) {
+        if (netdev->type != ARPHRD_ETHER)
+            continue;
+        ret = offer_device(netdev);
+        if (ret) {
+            read_unlock(&dev_base_lock);
+            goto out_err;
+        }
+    }
+    read_unlock(&dev_base_lock);
+    return ret;
+
+out_err:
+    clear_devices();
+    return ret;
+}
+
+/*****************************************************************************/
+
+/** Module cleanup.
+ *
+ * Clears all master instances.
+ */
+void __exit ec_gen_cleanup_module(void)
+{
+    clear_devices();
+    printk(KERN_INFO PFX "Unloading.\n");
+}
+
+/*****************************************************************************/
+
+/** \cond */
+
+module_init(ec_gen_init_module);
+module_exit(ec_gen_cleanup_module);
+
+/** \endcond */
+
+/*****************************************************************************/
--- a/master/cdev.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/cdev.c	Wed Oct 21 18:49:47 2009 +0200
@@ -587,7 +587,7 @@
 
     if (domain->data_size != data.data_size) {
         up(&master->master_sem);
-        EC_ERR("Data size mismatch %u/%u!\n",
+        EC_ERR("Data size mismatch %u/%zu!\n",
                 data.data_size, domain->data_size);
         return -EFAULT;
     }
@@ -972,7 +972,7 @@
             || data.offset + data.nwords > slave->sii_nwords) {
         up(&master->master_sem);
         EC_ERR("Invalid SII read offset/size %u/%u for slave "
-                "SII size %u!\n", data.offset,
+                "SII size %zu!\n", data.offset,
                 data.nwords, slave->sii_nwords);
         return -EINVAL;
     }
@@ -3052,7 +3052,7 @@
     data.error_code = request.req.error_code;
 
     if (master->debug_level) {
-        EC_DBG("Read %d bytes via FoE (result = 0x%x).\n",
+        EC_DBG("Read %zd bytes via FoE (result = 0x%x).\n",
                 request.req.data_size, request.req.result);
     }
 
--- a/master/datagram.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/datagram.c	Wed Oct 21 18:49:47 2009 +0200
@@ -149,7 +149,7 @@
     }
 
     if (!(datagram->data = kmalloc(size, GFP_KERNEL))) {
-        EC_ERR("Failed to allocate %u bytes of datagram memory!\n", size);
+        EC_ERR("Failed to allocate %zu bytes of datagram memory!\n", size);
         return -ENOMEM;
     }
 
@@ -516,8 +516,8 @@
         datagram->stats_output_jiffies = jiffies;
     
         if (unlikely(datagram->skip_count)) {
-            EC_WARN("Datagram %x (%s) was SKIPPED %u time%s.\n",
-                    (unsigned int) datagram, datagram->name,
+            EC_WARN("Datagram %p (%s) was SKIPPED %u time%s.\n",
+                    datagram, datagram->name,
                     datagram->skip_count,
                     datagram->skip_count == 1 ? "" : "s");
             datagram->skip_count = 0;
--- a/master/domain.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/domain.c	Wed Oct 21 18:49:47 2009 +0200
@@ -118,7 +118,7 @@
     list_add_tail(&fmmu->list, &domain->fmmu_configs);
 
     if (domain->master->debug_level)
-        EC_DBG("Domain %u: Added %u bytes, total %u.\n", domain->index,
+        EC_DBG("Domain %u: Added %u bytes, total %zu.\n", domain->index,
                 fmmu->data_size, domain->data_size);
 }
 
@@ -213,7 +213,7 @@
     if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
         if (!(domain->data =
                     (uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) {
-            EC_ERR("Failed to allocate %u bytes internal memory for"
+            EC_ERR("Failed to allocate %zu bytes internal memory for"
                     " domain %u!\n", domain->data_size, domain->index);
             return -ENOMEM;
         }
@@ -267,12 +267,12 @@
         datagram_count++;
     }
 
-    EC_INFO("Domain%u: Logical address 0x%08x, %u byte, "
+    EC_INFO("Domain%u: Logical address 0x%08x, %zu byte, "
             "expected working counter %u.\n", domain->index,
             domain->logical_base_address, domain->data_size,
             domain->expected_working_counter);
     list_for_each_entry(datagram, &domain->datagrams, list) {
-        EC_INFO("  Datagram %s: Logical offset 0x%08x, %u byte, type %s.\n",
+        EC_INFO("  Datagram %s: Logical offset 0x%08x, %zu byte, type %s.\n",
                 datagram->name, EC_READ_U32(datagram->address),
                 datagram->data_size, ec_datagram_type_string(datagram));
     }
@@ -328,8 +328,8 @@
     int ret;
     
     if (domain->master->debug_level)
-        EC_DBG("ecrt_domain_reg_pdo_entry_list(domain = 0x%x, regs = 0x%x)\n",
-                (u32) domain, (u32) regs);
+        EC_DBG("ecrt_domain_reg_pdo_entry_list(domain = 0x%p, regs = 0x%p)\n",
+                domain, regs);
 
     for (reg = regs; reg->index; reg++) {
         sc = ecrt_master_slave_config_err(domain->master, reg->alias,
@@ -360,8 +360,8 @@
 void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
 {
     if (domain->master->debug_level)
-        EC_DBG("ecrt_domain_external_memory(domain = 0x%x, mem = 0x%x)\n",
-                (u32) domain, (u32) mem);
+        EC_DBG("ecrt_domain_external_memory(domain = 0x%p, mem = 0x%p)\n",
+                domain, mem);
 
     down(&domain->master->master_sem);
 
--- a/master/foe_request.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/foe_request.c	Wed Oct 21 18:49:47 2009 +0200
@@ -114,7 +114,7 @@
     ec_foe_request_clear_data(req);
 
     if (!(req->buffer = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
-        EC_ERR("Failed to allocate %u bytes of FoE memory.\n", size);
+        EC_ERR("Failed to allocate %zu bytes of FoE memory.\n", size);
         return -1;
     }
 
--- a/master/fsm_coe.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_coe.c	Wed Oct 21 18:49:47 2009 +0200
@@ -446,7 +446,7 @@
     }
 
     if (rec_size < 3) {
-        EC_ERR("Received corrupted SDO dictionary response (size %u).\n",
+        EC_ERR("Received corrupted SDO dictionary response (size %zu).\n",
                 rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
@@ -480,7 +480,7 @@
     }
 
     if (rec_size < 8 || rec_size % 2) {
-        EC_ERR("Invalid data size %u!\n", rec_size);
+        EC_ERR("Invalid data size %zu!\n", rec_size);
         ec_print_data(data, rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
@@ -690,7 +690,7 @@
     }
 
     if (rec_size < 3) {
-        EC_ERR("Received corrupted SDO description response (size %u).\n",
+        EC_ERR("Received corrupted SDO description response (size %zu).\n",
                 rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
@@ -707,7 +707,7 @@
     }
 
     if (rec_size < 8) {
-        EC_ERR("Received corrupted SDO description response (size %u).\n",
+        EC_ERR("Received corrupted SDO description response (size %zu).\n",
                 rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
@@ -929,7 +929,7 @@
 
     if (rec_size < 3) {
         EC_ERR("Received corrupted SDO entry description response "
-                "(size %u).\n", rec_size);
+                "(size %zu).\n", rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
     }
@@ -946,7 +946,7 @@
 
     if (rec_size < 9) {
         EC_ERR("Received corrupted SDO entry description response "
-                "(size %u).\n", rec_size);
+                "(size %zu).\n", rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
     }
@@ -969,7 +969,7 @@
     }
 
     if (rec_size < 16) {
-        EC_ERR("Invalid data size %u!\n", rec_size);
+        EC_ERR("Invalid data size %zu!\n", rec_size);
         ec_print_data(data, rec_size);
         fsm->state = ec_fsm_coe_error;
         return;
@@ -1314,7 +1314,7 @@
 
     if (rec_size < 6) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Received data are too small (%u bytes):\n", rec_size);
+        EC_ERR("Received data are too small (%zu bytes):\n", rec_size);
         ec_print_data(data, rec_size);
         return;
     }
@@ -1328,7 +1328,7 @@
         } else {
             sprintf(subidxstr, ":%02X", request->subindex);
         }
-        EC_ERR("SDO download 0x%04X%s (%u bytes) aborted on slave %u.\n",
+        EC_ERR("SDO download 0x%04X%s (%zu bytes) aborted on slave %u.\n",
                 request->index, subidxstr, request->data_size,
                 slave->ring_position);
         if (rec_size < 10) {
@@ -1597,7 +1597,7 @@
 
     if (rec_size < 6) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Received currupted SDO upload response (%u bytes)!\n", rec_size);
+        EC_ERR("Received currupted SDO upload response (%zu bytes)!\n", rec_size);
         ec_print_data(data, rec_size);
         return;
     }
@@ -1657,7 +1657,7 @@
         if (rec_size < 6 + fsm->complete_size) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Received currupted SDO expedited upload"
-                    " response (only %u bytes)!\n", rec_size);
+                    " response (only %zu bytes)!\n", rec_size);
             ec_print_data(data, rec_size);
             return;
         }
@@ -1670,7 +1670,7 @@
         if (rec_size < 10) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Received currupted SDO normal upload"
-                    " response (only %u bytes)!\n", rec_size);
+                    " response (only %zu bytes)!\n", rec_size);
             ec_print_data(data, rec_size);
             return;
         }
@@ -1699,7 +1699,7 @@
 
         if (data_size < fsm->complete_size) {
             if (master->debug_level)
-                EC_DBG("SDO data incomplete (%u / %u). Segmenting...\n",
+                EC_DBG("SDO data incomplete (%zu / %u). Segmenting...\n",
                         data_size, fsm->complete_size);
 
             ec_fsm_coe_up_prepare_segment_request(fsm);
@@ -1927,7 +1927,7 @@
 
     if (request->data_size != fsm->complete_size) {
         EC_WARN("SDO upload 0x%04X:%02X on slave %u: Assembled data"
-                " size (%u) does not match complete size (%u)!\n",
+                " size (%zu) does not match complete size (%u)!\n",
                 request->index, request->subindex, slave->ring_position,
                 request->data_size, fsm->complete_size);
     }
--- a/master/fsm_foe.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_foe.c	Wed Oct 21 18:49:47 2009 +0200
@@ -849,7 +849,7 @@
         printk ("ERROR: data doesn't fit in receive buffer\n");
         printk ("       rx_buffer_size  = %d\n", fsm->rx_buffer_size);
         printk ("       rx_buffer_offset= %d\n", fsm->rx_buffer_offset);
-        printk ("       rec_size        = %d\n", rec_size);
+        printk ("       rec_size        = %zd\n", rec_size);
         printk ("       rx_mailbox_size = %d\n",
                 slave->configured_rx_mailbox_size);
         printk ("       rx_last_packet  = %d\n", fsm->rx_last_packet);
--- a/master/fsm_master.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_master.c	Wed Oct 21 18:49:47 2009 +0200
@@ -366,13 +366,13 @@
         // found pending request; process it!
         if (master->debug_level)
             EC_DBG("Processing register request for slave %u, "
-                    "offset 0x%04x, length %u...\n",
+                    "offset 0x%04x, length %zu...\n",
                     request->slave->ring_position,
                     request->offset, request->length);
 
         if (request->length > fsm->datagram->mem_size) {
-            EC_ERR("Request length (%u) exceeds maximum "
-                    "datagram size (%u)!\n", request->length,
+            EC_ERR("Request length (%zu) exceeds maximum "
+                    "datagram size (%zu)!\n", request->length,
                     fsm->datagram->mem_size);
             request->state = EC_INT_REQUEST_FAILURE;
             wake_up(&master->reg_queue);
@@ -943,7 +943,7 @@
 
     // finished writing SII
     if (master->debug_level)
-        EC_DBG("Finished writing %u words of SII data to slave %u.\n",
+        EC_DBG("Finished writing %zu words of SII data to slave %u.\n",
                 request->nwords, slave->ring_position);
 
     if (request->offset <= 4 && request->offset + request->nwords > 4) {
@@ -990,7 +990,7 @@
 
     // finished transferring FoE
     if (master->debug_level)
-        EC_DBG("Successfully transferred %u bytes of FoE data from/to"
+        EC_DBG("Successfully transferred %zu bytes of FoE data from/to"
                 " slave %u.\n", request->data_size, slave->ring_position);
 
     request->state = EC_INT_REQUEST_SUCCESS;
@@ -1096,7 +1096,7 @@
                 kfree(request->data);
             request->data = kmalloc(request->length, GFP_KERNEL);
             if (!request->data) {
-                EC_ERR("Failed to allocate %u bytes of memory for"
+                EC_ERR("Failed to allocate %zu bytes of memory for"
                         " register data.\n", request->length);
                 request->state = EC_INT_REQUEST_FAILURE;
                 wake_up(&master->reg_queue);
--- a/master/fsm_pdo.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_pdo.c	Wed Oct 21 18:49:47 2009 +0200
@@ -236,7 +236,7 @@
     }
 
     if (fsm->request.data_size != sizeof(uint8_t)) {
-        EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
+        EC_ERR("Invalid data size %zu returned when uploading SDO 0x%04X:%02X "
                 "from slave %u.\n", fsm->request.data_size,
                 fsm->request.index, fsm->request.subindex,
                 fsm->slave->ring_position);
@@ -298,7 +298,7 @@
     }
 
     if (fsm->request.data_size != sizeof(uint16_t)) {
-        EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
+        EC_ERR("Invalid data size %zu returned when uploading SDO 0x%04X:%02X "
                 "from slave %u.\n", fsm->request.data_size,
                 fsm->request.index, fsm->request.subindex,
                 fsm->slave->ring_position);
--- a/master/fsm_pdo_entry.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_pdo_entry.c	Wed Oct 21 18:49:47 2009 +0200
@@ -193,7 +193,7 @@
     }
 
     if (fsm->request.data_size != sizeof(uint8_t)) {
-        EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
+        EC_ERR("Invalid data size %zu at uploading SDO 0x%04X:%02X.\n",
                 fsm->request.data_size, fsm->request.index,
                 fsm->request.subindex);
         fsm->state = ec_fsm_pdo_entry_state_error;
@@ -248,7 +248,7 @@
     }
 
     if (fsm->request.data_size != sizeof(uint32_t)) {
-        EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
+        EC_ERR("Invalid data size %zu at uploading SDO 0x%04X:%02X.\n",
                 fsm->request.data_size, fsm->request.index,
                 fsm->request.subindex);
         fsm->state = ec_fsm_pdo_entry_state_error;
--- a/master/fsm_slave_scan.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/fsm_slave_scan.c	Wed Oct 21 18:49:47 2009 +0200
@@ -544,7 +544,7 @@
 
     if (!(slave->sii_words =
                 (uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_KERNEL))) {
-        EC_ERR("Failed to allocate %u words of SII data for slave %u.\n",
+        EC_ERR("Failed to allocate %zu words of SII data for slave %u.\n",
                slave->sii_nwords, slave->ring_position);
         slave->sii_nwords = 0;
         slave->error_flag = 1;
--- a/master/globals.h	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/globals.h	Wed Oct 21 18:49:47 2009 +0200
@@ -248,30 +248,6 @@
 #define EC_DBG(fmt, args...) \
     printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
 
-/** Convenience macro for defining read-only SysFS attributes.
- *
- * This results in creating a static variable called attr_\a NAME. The SysFS
- * file will be world-readable.
- *
- * \param NAME name of the attribute to create.
- */
-#define EC_SYSFS_READ_ATTR(NAME) \
-    static struct attribute attr_##NAME = { \
-        .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \
-    }
-
-/** Convenience macro for defining read-write SysFS attributes.
- *
- * This results in creating a static variable called attr_\a NAME. The SysFS
- * file will be word-readable plus owner-writable.
- *
- * \param NAME name of the attribute to create.
- */
-#define EC_SYSFS_READ_WRITE_ATTR(NAME) \
-    static struct attribute attr_##NAME = { \
-        .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
-    }
-
 /*****************************************************************************/
 
 extern char *ec_master_version_str;
--- a/master/mailbox.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/mailbox.c	Wed Oct 21 18:49:47 2009 +0200
@@ -66,7 +66,7 @@
     total_size = EC_MBOX_HEADER_SIZE + size;
 
     if (unlikely(total_size > slave->configured_rx_mailbox_size)) {
-        EC_ERR("Data size (%u) does not fit in mailbox (%u)!\n",
+        EC_ERR("Data size (%zu) does not fit in mailbox (%u)!\n",
                 total_size, slave->configured_rx_mailbox_size);
         return ERR_PTR(-EOVERFLOW);
     }
--- a/master/master.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/master.c	Wed Oct 21 18:49:47 2009 +0200
@@ -365,6 +365,69 @@
 
     master->dc_ref_clock = NULL;
 
+    // external requests are obsolete, so we wake pending waiters and remove
+    // them from the list
+    //
+	// SII requests
+	while (1) {
+		ec_sii_write_request_t *request;
+		if (list_empty(&master->sii_requests))
+			break;
+		// get first request
+        request = list_entry(master->sii_requests.next,
+                ec_sii_write_request_t, list);
+		list_del_init(&request->list); // dequeue
+		EC_INFO("Discarding SII request, slave %u does not exist anymore.\n",
+				request->slave->ring_position);
+		request->state = EC_INT_REQUEST_FAILURE;
+		wake_up(&master->sii_queue);
+	}
+
+	// Register requests
+	while (1) {
+	    ec_reg_request_t *request;
+		if (list_empty(&master->reg_requests))
+			break;
+		// get first request
+		request = list_entry(master->reg_requests.next,
+				ec_reg_request_t, list);
+		list_del_init(&request->list); // dequeue
+		EC_INFO("Discarding Reg request, slave %u does not exist anymore.\n",
+				request->slave->ring_position);
+		request->state = EC_INT_REQUEST_FAILURE;
+		wake_up(&master->reg_queue);
+	}
+
+	// SDO requests
+	while (1) {
+		ec_master_sdo_request_t *request;
+		if (list_empty(&master->slave_sdo_requests))
+			break;
+		// get first request
+		request = list_entry(master->slave_sdo_requests.next,
+				ec_master_sdo_request_t, list);
+		list_del_init(&request->list); // dequeue
+		EC_INFO("Discarding SDO request, slave %u does not exist anymore.\n",
+				request->slave->ring_position);
+		request->req.state = EC_INT_REQUEST_FAILURE;
+		wake_up(&master->sdo_queue);
+	}
+
+	// FoE requests
+	while (1) {
+		ec_master_foe_request_t *request;
+		if (list_empty(&master->foe_requests))
+			break;
+		// get first request
+		request = list_entry(master->foe_requests.next,
+				ec_master_foe_request_t, list);
+		list_del_init(&request->list); // dequeue
+		EC_INFO("Discarding FOE request, slave %u does not exist anymore.\n",
+				request->slave->ring_position);
+		request->req.state = EC_INT_REQUEST_FAILURE;
+		wake_up(&master->foe_queue);
+	}
+
     for (slave = master->slaves;
             slave < master->slaves + master->slave_count;
             slave++) {
@@ -636,7 +699,7 @@
         if (queued_datagram == datagram) {
             datagram->skip_count++;
             if (master->debug_level)
-                EC_DBG("skipping datagram %x.\n", (unsigned int) datagram);
+                EC_DBG("skipping datagram %p.\n", datagram);
             datagram->state = EC_DATAGRAM_QUEUED;
             return;
         }
@@ -750,7 +813,7 @@
             EC_WRITE_U8(cur_data++, 0x00);
 
         if (unlikely(master->debug_level > 1))
-            EC_DBG("frame size: %u\n", cur_data - frame_data);
+            EC_DBG("frame size: %zu\n", cur_data - frame_data);
 
         // send frame
         ec_device_send(&master->main_device, cur_data - frame_data);
@@ -804,7 +867,7 @@
 
     if (unlikely(size < EC_FRAME_HEADER_SIZE)) {
         if (master->debug_level) {
-            EC_DBG("Corrupted frame received (size %u < %u byte):\n",
+            EC_DBG("Corrupted frame received (size %zu < %u byte):\n",
                     size, EC_FRAME_HEADER_SIZE);
             ec_print_data(frame_data, size);
         }
@@ -821,8 +884,8 @@
 
     if (unlikely(frame_size > size)) {
         if (master->debug_level) {
-            EC_DBG("Corrupted frame received (invalid frame size %u for "
-                    "received size %u):\n", frame_size, size);
+            EC_DBG("Corrupted frame received (invalid frame size %zu for "
+                    "received size %zu):\n", frame_size, size);
             ec_print_data(frame_data, size);
         }
         master->stats.corrupted++;
@@ -842,7 +905,7 @@
         if (unlikely(cur_data - frame_data
                      + data_size + EC_DATAGRAM_FOOTER_SIZE > size)) {
             if (master->debug_level) {
-                EC_DBG("Corrupted frame received (invalid data size %u):\n",
+                EC_DBG("Corrupted frame received (invalid data size %zu):\n",
                         data_size);
                 ec_print_data(frame_data, size);
             }
@@ -1552,7 +1615,7 @@
     unsigned int index;
 
     if (master->debug_level)
-        EC_DBG("ecrt_master_create_domain(master = 0x%x)\n", (u32) master);
+        EC_DBG("ecrt_master_create_domain(master = 0x%p)\n", master);
 
     if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
         EC_ERR("Error allocating domain memory!\n");
@@ -1598,7 +1661,7 @@
     int ret;
 
     if (master->debug_level)
-        EC_DBG("ecrt_master_activate(master = 0x%x)\n", (u32) master);
+        EC_DBG("ecrt_master_activate(master = 0x%p)\n", master);
 
     if (master->active) {
         EC_WARN("%s: Master already active!\n", __func__);
@@ -1613,7 +1676,7 @@
         ret = ec_domain_finish(domain, domain_offset);
         if (ret < 0) {
             up(&master->master_sem);
-            EC_ERR("Failed to finish domain 0x%08X!\n", (u32) domain);
+            EC_ERR("Failed to finish domain 0x%p!\n", domain);
             return ret;
         }
         domain_offset += domain->data_size;
@@ -1633,7 +1696,7 @@
     ec_master_thread_stop(master);
 
     if (master->debug_level)
-        EC_DBG("FSM datagram is %x.\n", (unsigned int) &master->fsm_datagram);
+        EC_DBG("FSM datagram is %p.\n", &master->fsm_datagram);
 
     master->injection_seq_fsm = 0;
     master->injection_seq_rt = 0;
@@ -1790,8 +1853,8 @@
                 time_us = (unsigned int) ((master->main_device.jiffies_poll -
                             datagram->jiffies_sent) * 1000000 / HZ);
 #endif
-                EC_DBG("TIMED OUT datagram %08x, index %02X waited %u us.\n",
-                        (unsigned int) datagram, datagram->index, time_us);
+                EC_DBG("TIMED OUT datagram %p, index %02X waited %u us.\n",
+                        datagram, datagram->index, time_us);
             }
         }
     }
@@ -1827,9 +1890,9 @@
 
 
     if (master->debug_level)
-        EC_DBG("ecrt_master_slave_config(master = 0x%x, alias = %u, "
+        EC_DBG("ecrt_master_slave_config(master = 0x%p, alias = %u, "
                 "position = %u, vendor_id = 0x%08x, product_code = 0x%08x)\n",
-                (u32) master, alias, position, vendor_id, product_code);
+                master, alias, position, vendor_id, product_code);
 
     list_for_each_entry(sc, &master->configs, list) {
         if (sc->alias == alias && sc->position == position) {
@@ -1890,9 +1953,9 @@
         void (*send_cb)(void *), void (*receive_cb)(void *), void *cb_data)
 {
     if (master->debug_level)
-        EC_DBG("ecrt_master_callbacks(master = 0x%x, send_cb = 0x%x, "
-                " receive_cb = 0x%x, cb_data = 0x%x)\n", (u32) master,
-                (u32) send_cb, (u32) receive_cb, (u32) cb_data);
+        EC_DBG("ecrt_master_callbacks(master = 0x%p, send_cb = 0x%p, "
+                " receive_cb = 0x%p, cb_data = 0x%p)\n", master,
+                send_cb, receive_cb, cb_data);
 
     master->app_send_cb = send_cb;
     master->app_receive_cb = receive_cb;
--- a/master/sdo_request.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/sdo_request.c	Wed Oct 21 18:49:47 2009 +0200
@@ -145,7 +145,7 @@
     ec_sdo_request_clear_data(req);
 
     if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
-        EC_ERR("Failed to allocate %u bytes of SDO memory.\n", size);
+        EC_ERR("Failed to allocate %zu bytes of SDO memory.\n", size);
         return -ENOMEM;
     }
 
--- a/master/slave.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/slave.c	Wed Oct 21 18:49:47 2009 +0200
@@ -321,7 +321,7 @@
     uint8_t flags;
 
     if (data_size != 32) {
-        EC_ERR("Wrong size of general category (%u/32) in slave %u.\n",
+        EC_ERR("Wrong size of general category (%zu/32) in slave %u.\n",
                 data_size, slave->ring_position);
         return -EINVAL;
     }
@@ -376,7 +376,7 @@
 
     // one sync manager struct is 4 words long
     if (data_size % 8) {
-        EC_ERR("Invalid SII sync manager category size %u in slave %u.\n",
+        EC_ERR("Invalid SII sync manager category size %zu in slave %u.\n",
                 data_size, slave->ring_position);
         return -EINVAL;
     }
@@ -391,7 +391,7 @@
         }
         memsize = sizeof(ec_sync_t) * total_count;
         if (!(syncs = kmalloc(memsize, GFP_KERNEL))) {
-            EC_ERR("Failed to allocate %u bytes for sync managers.\n",
+            EC_ERR("Failed to allocate %zu bytes for sync managers.\n",
                     memsize);
             return -ENOMEM;
         }
--- a/master/slave_config.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/slave_config.c	Wed Oct 21 18:49:47 2009 +0200
@@ -418,9 +418,9 @@
     ec_sync_config_t *sync_config;
     
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%x, sync_index = %u, "
+        EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%p, sync_index = %u, "
                 "dir = %i, watchdog_mode = %i)\n",
-                (u32) sc, sync_index, dir, watchdog_mode);
+                 sc, sync_index, dir, watchdog_mode);
 
     if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -444,8 +444,8 @@
         uint16_t divider, uint16_t intervals)
 {
     if (sc->master->debug_level)
-        EC_DBG("%s(sc = 0x%x, divider = %u, intervals = %u)\n",
-                __func__, (u32) sc, divider, intervals);
+        EC_DBG("%s(sc = 0x%p, divider = %u, intervals = %u)\n",
+                __func__, sc, divider, intervals);
 
     sc->watchdog_divider = divider;
     sc->watchdog_intervals = intervals;
@@ -459,8 +459,8 @@
     ec_pdo_t *pdo;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%x, sync_index = %u, "
-                "pdo_index = 0x%04X)\n", (u32) sc, sync_index, pdo_index);
+        EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%p, sync_index = %u, "
+                "pdo_index = 0x%04X)\n", sc, sync_index, pdo_index);
 
     if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -488,8 +488,8 @@
         uint8_t sync_index)
 {
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%x, "
-                "sync_index = %u)\n", (u32) sc, sync_index);
+        EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%p, "
+                "sync_index = %u)\n", sc, sync_index);
 
     if (sync_index >= EC_MAX_SYNC_MANAGERS) {
         EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -513,10 +513,10 @@
     int retval = 0;
     
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_pdo_mapping_add(sc = 0x%x, "
+        EC_DBG("ecrt_slave_config_pdo_mapping_add(sc = 0x%p, "
                 "pdo_index = 0x%04X, entry_index = 0x%04X, "
                 "entry_subindex = 0x%02X, entry_bit_length = %u)\n",
-                (u32) sc, pdo_index, entry_index, entry_subindex,
+                sc, pdo_index, entry_index, entry_subindex,
                 entry_bit_length);
 
     for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
@@ -549,8 +549,8 @@
     ec_pdo_t *pdo = NULL;
     
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%x, "
-                "pdo_index = 0x%04X)\n", (u32) sc, pdo_index);
+        EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%p, "
+                "pdo_index = 0x%04X)\n", sc, pdo_index);
 
     for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
         if ((pdo = ec_pdo_list_find_pdo(
@@ -579,8 +579,8 @@
     const ec_pdo_entry_info_t *entry_info;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_pdos(sc = 0x%x, n_syncs = %u, "
-                "syncs = 0x%x)\n", (u32) sc, n_syncs, (u32) syncs);
+        EC_DBG("ecrt_slave_config_pdos(sc = 0x%p, n_syncs = %u, "
+                "syncs = 0x%p)\n", sc, n_syncs, syncs);
 
     if (!syncs)
         return 0;
@@ -651,9 +651,9 @@
     int sync_offset;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_reg_pdo_entry(sc = 0x%x, index = 0x%04X, "
-                "subindex = 0x%02X, domain = 0x%x, bit_position = 0x%x)\n",
-                (u32) sc, index, subindex, (u32) domain, (u32) bit_position);
+        EC_DBG("ecrt_slave_config_reg_pdo_entry(sc = 0x%p, index = 0x%04X, "
+                "subindex = 0x%02X, domain = 0x%p, bit_position = 0x%p)\n",
+                sc, index, subindex, domain, bit_position);
 
     for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
         sync_config = &sc->sync_configs[sync_index];
@@ -713,9 +713,9 @@
     int ret;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sdo(sc = 0x%x, index = 0x%04X, "
-                "subindex = 0x%02X, data = 0x%x, size = %u)\n", (u32) sc,
-                index, subindex, (u32) data, size);
+        EC_DBG("ecrt_slave_config_sdo(sc = 0x%p, index = 0x%04X, "
+                "subindex = 0x%02X, data = 0x%p, size = %zu)\n", sc,
+                index, subindex, data, size);
 
     if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
         EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
@@ -752,8 +752,8 @@
     uint8_t data[1];
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sdo8(sc = 0x%x, index = 0x%04X, "
-                "subindex = 0x%02X, value = %u)\n", (u32) sc,
+        EC_DBG("ecrt_slave_config_sdo8(sc = 0x%p, index = 0x%04X, "
+                "subindex = 0x%02X, value = %u)\n", sc,
                 index, subindex, (u32) value);
 
     EC_WRITE_U8(data, value);
@@ -768,8 +768,8 @@
     uint8_t data[2];
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sdo16(sc = 0x%x, index = 0x%04X, "
-                "subindex = 0x%02X, value = %u)\n", (u32) sc,
+        EC_DBG("ecrt_slave_config_sdo16(sc = 0x%p, index = 0x%04X, "
+                "subindex = 0x%02X, value = %u)\n", sc,
                 index, subindex, value);
 
     EC_WRITE_U16(data, value);
@@ -784,8 +784,8 @@
     uint8_t data[4];
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_sdo32(sc = 0x%x, index = 0x%04X, "
-                "subindex = 0x%02X, value = %u)\n", (u32) sc,
+        EC_DBG("ecrt_slave_config_sdo32(sc = 0x%p, index = 0x%04X, "
+                "subindex = 0x%02X, value = %u)\n", sc,
                 index, subindex, value);
 
     EC_WRITE_U32(data, value);
@@ -802,9 +802,8 @@
     int ret;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_complete_sdo(sc = 0x%x, index = 0x%04X, "
-                "data = 0x%x, size = %u)\n", (u32) sc,
-                index, (u32) data, size);
+        EC_DBG("ecrt_slave_config_complete_sdo(sc = 0x%p, index = 0x%04X, "
+                "data = 0x%p, size = %zu)\n", sc, index, data, size);
 
     if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
         EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
@@ -846,8 +845,8 @@
     int ret;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_create_sdo_request(sc = 0x%x, "
-                "index = 0x%04X, subindex = 0x%02X, size = %u)\n", (u32) sc,
+        EC_DBG("ecrt_slave_config_create_sdo_request(sc = 0x%p, "
+                "index = 0x%04X, subindex = 0x%02X, size = %zu)\n", sc,
                 index, subindex, size);
 
     if (!(req = (ec_sdo_request_t *)
@@ -899,8 +898,8 @@
     int ret;
 
     if (sc->master->debug_level)
-        EC_DBG("ecrt_slave_config_create_voe_handler(sc = 0x%x, size = %u)\n",
-                (u32) sc, size);
+        EC_DBG("ecrt_slave_config_create_voe_handler(sc = 0x%p, size = %zu)\n",
+                sc, size);
 
     if (!(voe = (ec_voe_handler_t *)
                 kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) {
--- a/master/voe_handler.c	Wed Sep 30 21:14:40 2009 +0200
+++ b/master/voe_handler.c	Wed Oct 21 18:49:47 2009 +0200
@@ -212,7 +212,7 @@
     uint8_t *data;
 
     if (slave->master->debug_level) {
-        EC_DBG("Writing %u bytes of VoE data to slave %u.\n",
+        EC_DBG("Writing %zu bytes of VoE data to slave %u.\n",
                voe->data_size, slave->ring_position);
         ec_print_data(ecrt_voe_handler_data(voe), voe->data_size);
     }
@@ -419,7 +419,7 @@
     if (rec_size < EC_VOE_HEADER_SIZE) {
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
-        EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size);
+        EC_ERR("Received VoE header is incomplete (%zu bytes)!\n", rec_size);
         return;
     }
 
@@ -519,7 +519,7 @@
     if (rec_size < EC_VOE_HEADER_SIZE) {
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
-        EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size);
+        EC_ERR("Received VoE header is incomplete (%zu bytes)!\n", rec_size);
         return;
     }