Module: xenomai-gch
Branch: for-forge
Commit: 8fa7dba73dbb24178ae0276aaf033e141a7a4283
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=8fa7dba73dbb24178ae0276aaf033e141a7a4283

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Nov 11 23:11:01 2014 +0100

rtnet: remove now useless macros

RTNET_SET_MODULE_OWNER, RTNET_MOD_INC_USE_COUNT, RTNET_MOD_DEC_USE_COUNT

---

 kernel/drivers/net/addons/cap.c                    |    6 -
 kernel/drivers/net/drivers/8139too.c               |    5 -
 kernel/drivers/net/drivers/at91_ether.c            |    1 -
 kernel/drivers/net/drivers/e1000/e1000_main.c      |    1 -
 kernel/drivers/net/drivers/e1000e/netdev.c         |    1 -
 kernel/drivers/net/drivers/eepro100.c              |    6 -
 kernel/drivers/net/drivers/eth1394.c               |    1 -
 kernel/drivers/net/drivers/experimental/3c59x.c    |    6 -
 .../net/drivers/experimental/e1000/e1000_main.c    |    1 -
 .../net/drivers/experimental/e1000/kcompat.h       |   74 +++---
 .../net/drivers/experimental/rt2500/rt2x00core.c   |    5 -
 kernel/drivers/net/drivers/fec.c                   |    1 -
 kernel/drivers/net/drivers/igb/igb_main.c          |    1 -
 kernel/drivers/net/drivers/loopback.c              |    5 -
 kernel/drivers/net/drivers/macb.c                  |    5 -
 .../drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c  |    3 -
 kernel/drivers/net/drivers/mpc8260_fcc_enet.c      |    5 -
 kernel/drivers/net/drivers/mpc8xx_enet.c           |    5 -
 kernel/drivers/net/drivers/mpc8xx_fec.c            |    4 -
 kernel/drivers/net/drivers/natsemi.c               |    7 -
 kernel/drivers/net/drivers/pcnet32.c               |    5 -
 kernel/drivers/net/drivers/r8169.c                 |   15 --
 kernel/drivers/net/drivers/smc91111.c              |    9 -
 kernel/drivers/net/drivers/tulip/tulip_core.c      |    6 -
 kernel/drivers/net/drivers/via-rhine.c             |    7 -
 kernel/drivers/net/stack/include/rtnet_internal.h  |   90 +++----
 .../drivers/net/stack/rtmac/nomac/nomac_module.c   |   28 +--
 kernel/drivers/net/stack/rtmac/rtmac_disc.c        |   77 +++---
 kernel/drivers/net/stack/rtmac/rtmac_vnic.c        |  188 +++++++--------
 kernel/drivers/net/stack/rtmac/tdma/tdma_module.c  |  252 ++++++++++----------
 30 files changed, 332 insertions(+), 488 deletions(-)

diff --git a/kernel/drivers/net/addons/cap.c b/kernel/drivers/net/addons/cap.c
index d10e660..f1a8aa7 100644
--- a/kernel/drivers/net/addons/cap.c
+++ b/kernel/drivers/net/addons/cap.c
@@ -359,10 +359,6 @@ static void tap_dev_setup(struct net_device *dev)
 #endif /* !HAVE_NET_DEVICE_OPS */
     dev->mtu             = 1500;
     dev->flags           &= ~IFF_MULTICAST;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-    SET_MODULE_OWNER(dev);
-#endif
 }
 
 
@@ -383,7 +379,6 @@ void cleanup_tap_devices(void)
                rtdev->hard_start_xmit = tap_device[i].orig_xmit;
                if (rtdev->features & NETIF_F_LLTX)
                    rtdev->start_xmit = tap_device[i].orig_xmit;
-               RTNET_MOD_DEC_USE_COUNT_EX(rtdev->rt_owner);
                mutex_unlock(&rtdev->nrt_lock);
 
                rtdev_dereference(rtdev);
@@ -495,7 +490,6 @@ int __init rtcap_init(void)
                rtdev->start_xmit = rtdev->hard_start_xmit;
 
            tap_device[i].present |= XMIT_HOOK;
-           RTNET_MOD_INC_USE_COUNT_EX(rtdev->rt_owner);
 
            mutex_unlock(&rtdev->nrt_lock);
 
diff --git a/kernel/drivers/net/drivers/8139too.c 
b/kernel/drivers/net/drivers/8139too.c
index dea598e..35d4850 100644
--- a/kernel/drivers/net/drivers/8139too.c
+++ b/kernel/drivers/net/drivers/8139too.c
@@ -650,7 +650,6 @@ static int rtl8139_init_board (struct pci_dev *pdev,
 
        rt_rtdev_connect(rtdev, &RTDEV_manager);
 
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
        tp = rtdev->priv;
        tp->pci_dev = pdev;
@@ -1166,8 +1165,6 @@ static int rtl8139_open (struct rtnet_device *rtdev)
        rtl8139_init_ring (rtdev);
        rtl8139_hw_start (rtdev);
 
-       RTNET_MOD_INC_USE_COUNT;
-
        return 0;
 }
 
@@ -1755,8 +1752,6 @@ static int rtl8139_close (struct rtnet_device *rtdev)
        if (rtl_chip_info[tp->chipset].flags & HasHltClk)
                RTL_W8 (HltClk, 'H');        /* 'R' would leave the clock 
running. */
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/at91_ether.c 
b/kernel/drivers/net/drivers/at91_ether.c
index e5d54f9..131a133 100644
--- a/kernel/drivers/net/drivers/at91_ether.c
+++ b/kernel/drivers/net/drivers/at91_ether.c
@@ -1004,7 +1004,6 @@ static int at91ether_setup_rt(unsigned long phy_type, 
unsigned short phy_address
 
        rtdev_alloc_name(dev, "rteth%d");
        rt_rtdev_connect(dev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(dev);
        dev->vers = RTDEV_VERS_2_0;
 
        /* Get I/O base address and IRQ */
diff --git a/kernel/drivers/net/drivers/e1000/e1000_main.c 
b/kernel/drivers/net/drivers/e1000/e1000_main.c
index 2f34e3b..d1df040 100644
--- a/kernel/drivers/net/drivers/e1000/e1000_main.c
+++ b/kernel/drivers/net/drivers/e1000/e1000_main.c
@@ -731,7 +731,6 @@ static int e1000_probe(struct pci_dev *pdev,
        rt_rtdev_connect(netdev, &RTDEV_manager);
 
 
-       RTNET_SET_MODULE_OWNER(netdev);
        // SET_NETDEV_DEV(netdev, &pdev->dev);
        netdev->vers = RTDEV_VERS_2_0;
 
diff --git a/kernel/drivers/net/drivers/e1000e/netdev.c 
b/kernel/drivers/net/drivers/e1000e/netdev.c
index 39476bd..6819fac 100644
--- a/kernel/drivers/net/drivers/e1000e/netdev.c
+++ b/kernel/drivers/net/drivers/e1000e/netdev.c
@@ -4011,7 +4011,6 @@ static int e1000_probe(struct pci_dev *pdev,
 
        rtdev_alloc_name(netdev, "rteth%d");
        rt_rtdev_connect(netdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(netdev);
        netdev->vers = RTDEV_VERS_2_0;
 
        netdev->irq = pdev->irq;
diff --git a/kernel/drivers/net/drivers/eepro100.c 
b/kernel/drivers/net/drivers/eepro100.c
index e11febc..48ffabb 100644
--- a/kernel/drivers/net/drivers/eepro100.c
+++ b/kernel/drivers/net/drivers/eepro100.c
@@ -679,7 +679,6 @@ static int speedo_found1(struct pci_dev *pdev,
        rtdev_alloc_name(rtdev, "rteth%d");
        memset(rtdev->priv, 0, sizeof(struct speedo_private));
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
        // *** RTnet ***
 
@@ -878,8 +877,6 @@ speedo_open(struct rtnet_device *rtdev)
        if (speedo_debug > 1)
                printk(KERN_DEBUG "%s: speedo_open() irq %d.\n", rtdev->name, 
rtdev->irq);
 
-       RTNET_MOD_INC_USE_COUNT;
-
        pci_set_power_state(sp->pdev, 0);
 
        /* Set up the Tx queue early.. */
@@ -897,7 +894,6 @@ speedo_open(struct rtnet_device *rtdev)
                                  speedo_interrupt, RTDM_IRQTYPE_SHARED,
                                  "rt_eepro100", rtdev);
        if (retval) {
-               RTNET_MOD_DEC_USE_COUNT;
                return retval;
        }
        // *** RTnet ***
@@ -1699,8 +1695,6 @@ speedo_close(struct rtnet_device *rtdev)
 
        pci_set_power_state(sp->pdev, 2);
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/eth1394.c 
b/kernel/drivers/net/drivers/eth1394.c
index 813af9e..549a1f6 100644
--- a/kernel/drivers/net/drivers/eth1394.c
+++ b/kernel/drivers/net/drivers/eth1394.c
@@ -387,7 +387,6 @@ static void eth1394_add_host (struct hpsb_host *host)
        rtdev_alloc_name(dev, "rteth%d");
        memset(dev->priv, 0, sizeof(struct eth1394_priv));
        rt_rtdev_connect(dev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(dev);
 
        //dev->init = eth1394_init_dev;
 
diff --git a/kernel/drivers/net/drivers/experimental/3c59x.c 
b/kernel/drivers/net/drivers/experimental/3c59x.c
index a4ad351..b701a6c 100644
--- a/kernel/drivers/net/drivers/experimental/3c59x.c
+++ b/kernel/drivers/net/drivers/experimental/3c59x.c
@@ -1066,7 +1066,6 @@ static int vortex_probe1(struct pci_dev *pdev,
        rtdev_alloc_name(rtdev, "rteth%d");
        memset(rtdev->priv, 0, sizeof(*vp));
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
        // *** RTnet ***
 
@@ -1883,8 +1882,6 @@ vortex_open(struct rtnet_device *rtdev)
        int i;
        int retval;
 
-       RTNET_MOD_INC_USE_COUNT;
-
        // *** RTnet ***
        rt_stack_connect(rtdev, &STACK_manager);
 
@@ -1941,7 +1938,6 @@ vortex_open(struct rtnet_device *rtdev)
        rt_stack_disconnect(rtdev);
        // *** RTnet ***
   out:
-       RTNET_MOD_DEC_USE_COUNT;
        if (vortex_debug > 1)
                printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", 
rtdev->name, retval);
        return retval;
@@ -2955,8 +2951,6 @@ vortex_close(struct rtnet_device *rtdev)
                }
        }
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c 
b/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
index f4ff079..6a2010a 100644
--- a/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
+++ b/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
@@ -1131,7 +1131,6 @@ static int e1000_probe(struct pci_dev *pdev,
     memset(netdev->priv, 0, sizeof(struct e1000_adapter));
     rt_rtdev_connect(netdev, &RTDEV_manager);
 
-    RTNET_SET_MODULE_OWNER(netdev);
        // SET_NETDEV_DEV(netdev, &pdev->dev);
     netdev->vers = RTDEV_VERS_2_0;
 
diff --git a/kernel/drivers/net/drivers/experimental/e1000/kcompat.h 
b/kernel/drivers/net/drivers/experimental/e1000/kcompat.h
index 8ba25d5..41a9b07 100644
--- a/kernel/drivers/net/drivers/experimental/e1000/kcompat.h
+++ b/kernel/drivers/net/drivers/experimental/e1000/kcompat.h
@@ -708,7 +708,7 @@ extern int _kc_is_valid_ether_addr(u8 *addr);
 #define ADVERTISE_100HALF       0x0080  /* Try for 100mbps half-duplex */
 #define ADVERTISE_100FULL       0x0100  /* Try for 100mbps full-duplex */
 #define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
-                       ADVERTISE_100HALF | ADVERTISE_100FULL)
+                      ADVERTISE_100HALF | ADVERTISE_100FULL)
 /* Expansion register for auto-negotiation. */
 #define EXPANSION_ENABLENPAGE   0x0004  /* This enables npage words    */
 #endif
@@ -1076,8 +1076,8 @@ static inline int _kc_pci_dma_mapping_error(dma_addr_t 
dma_addr)
 #undef find_next_bit
 #define find_next_bit _kc_find_next_bit
 extern unsigned long _kc_find_next_bit(const unsigned long *addr,
-                                       unsigned long size,
-                                       unsigned long offset);
+                                      unsigned long size,
+                                      unsigned long offset);
 #define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
 
 #endif /* 2.6.0 => 2.5.28 */
@@ -1102,12 +1102,12 @@ extern unsigned long _kc_find_next_bit(const unsigned 
long *addr,
 #define bitmap_zero _kc_bitmap_zero
 static inline void _kc_bitmap_zero(unsigned long *dst, int nbits)
 {
-        if (nbits <= BITS_PER_LONG)
-                *dst = 0UL;
-        else {
-                int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
-                memset(dst, 0, len);
-        }
+       if (nbits <= BITS_PER_LONG)
+               *dst = 0UL;
+       else {
+               int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+               memset(dst, 0, len);
+       }
 }
 #endif /* < 2.6.6 */
 
@@ -1185,34 +1185,34 @@ static inline unsigned long 
_kc_msleep_interruptible(unsigned int msecs)
 #undef pci_save_state
 #endif
 #define pci_save_state(X) { \
-        int i; \
-        if (adapter->pci_state) { \
-                for (i = 0; i < 16; i++) { \
-                        pci_read_config_dword((X), \
-                                              i * 4, \
-                                              &adapter->pci_state[i]); \
-                } \
-        } \
+       int i; \
+       if (adapter->pci_state) { \
+               for (i = 0; i < 16; i++) { \
+                       pci_read_config_dword((X), \
+                                             i * 4, \
+                                             &adapter->pci_state[i]); \
+               } \
+       } \
 }
 
 #ifdef pci_restore_state
 #undef pci_restore_state
 #endif
 #define pci_restore_state(X) { \
-        int i; \
-        if (adapter->pci_state) { \
-                for (i = 0; i < 16; i++) { \
-                        pci_write_config_dword((X), \
-                                               i * 4, \
-                                               adapter->pci_state[i]); \
-                } \
-        } else { \
-                for (i = 0; i < 6; i++) { \
-                        pci_write_config_dword((X), \
-                                               PCI_BASE_ADDRESS_0 + (i * 4), \
-                                               (X)->resource[i].start); \
-                } \
-        } \
+       int i; \
+       if (adapter->pci_state) { \
+               for (i = 0; i < 16; i++) { \
+                       pci_write_config_dword((X), \
+                                              i * 4, \
+                                              adapter->pci_state[i]); \
+               } \
+       } else { \
+               for (i = 0; i < 6; i++) { \
+                       pci_write_config_dword((X), \
+                                              PCI_BASE_ADDRESS_0 + (i * 4), \
+                                              (X)->resource[i].start); \
+               } \
+       } \
 }
 #endif /* 2.4.6 <= x < 2.6.10 */
 
@@ -1310,7 +1310,7 @@ extern void *_kc_kzalloc(size_t size, int flags);
 #ifndef netdev_alloc_skb
 #define netdev_alloc_skb _kc_netdev_alloc_skb
 extern struct sk_buff *_kc_netdev_alloc_skb(struct net_device *dev,
-                                            unsigned int length);
+                                           unsigned int length);
 #endif
 
 #ifndef skb_is_gso
@@ -1341,7 +1341,7 @@ static inline int _kc_skb_is_gso(const struct sk_buff 
*skb)
 #ifndef RHEL_RELEASE_VERSION
 #define RHEL_RELEASE_VERSION(a,b) 0
 #endif
-#if (!(( RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(4,4) ) && ( 
RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0) ) || ( RHEL_RELEASE_CODE > 
RHEL_RELEASE_VERSION(5,0) ))) 
+#if (!(( RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(4,4) ) && ( 
RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0) ) || ( RHEL_RELEASE_CODE > 
RHEL_RELEASE_VERSION(5,0) )))
 typedef irqreturn_t (*irq_handler_t)(int, void*, struct pt_regs *);
 #endif
 typedef irqreturn_t (*new_handler_t)(int, void*);
@@ -1456,7 +1456,7 @@ do { \
 #define skb_network_header(skb) (skb->nh.raw)
 #define skb_tail_pointer(skb) skb->tail
 #define skb_copy_to_linear_data_offset(skb, offset, from, len) \
-                                 memcpy(skb->data + offset, from, len)
+                                memcpy(skb->data + offset, from, len)
 #define skb_network_header_len(skb) (skb->h.raw - skb->nh.raw)
 #define pci_register_driver pci_module_init
 #define skb_mac_header(skb) skb->mac.raw
@@ -1498,11 +1498,6 @@ extern int __kc_adapter_clean(struct net_device *, int 
*);
 
 
 /*****************************************************************************/
-#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22) )
-#undef ETHTOOL_GPERMADDR
-#undef SET_MODULE_OWNER
-#define SET_MODULE_OWNER(dev) do { } while (0)
-#endif /* > 2.6.22 */
 
 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
 #undef dev_get_by_name
@@ -1511,4 +1506,3 @@ extern int __kc_adapter_clean(struct net_device *, int *);
 #endif /* < 2.6.24 */
 
 #endif /* _KCOMPAT_H_ */
-
diff --git a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c 
b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
index 71e1eb2..0df34b2 100644
--- a/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
+++ b/kernel/drivers/net/drivers/experimental/rt2500/rt2x00core.c
@@ -282,8 +282,6 @@ static int rt2x00_open (struct rtnet_device *rtnet_dev) {
 
     rtnetif_start_queue(rtnet_dev);
 
-    RTNET_MOD_INC_USE_COUNT;
-
     DEBUG("Exit success.\n");
 
     return 0;
@@ -311,8 +309,6 @@ static int rt2x00_close (struct rtnet_device *rtnet_dev) {
     rtnetif_stop_queue(rtnet_dev);
     rt_stack_disconnect(rtnet_dev);
 
-    RTNET_MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
@@ -362,7 +358,6 @@ struct rtnet_device * rt2x00_core_probe(struct 
_rt2x00_dev_handler * handler,
        goto exit;
 
     rt_rtdev_connect(rtnet_dev, &RTDEV_manager);
-    RTNET_SET_MODULE_OWNER(rtnet_dev);
     rtnet_dev->vers = RTDEV_VERS_2_0;
 
     rtwlan_dev = rtnetdev_priv(rtnet_dev);
diff --git a/kernel/drivers/net/drivers/fec.c b/kernel/drivers/net/drivers/fec.c
index e00a240..2119ab4 100644
--- a/kernel/drivers/net/drivers/fec.c
+++ b/kernel/drivers/net/drivers/fec.c
@@ -1658,7 +1658,6 @@ static int fec_probe(struct platform_device *pdev)
        /* RTnet */
        rtdev_alloc_name(ndev, "rteth%d");
        rt_rtdev_connect(ndev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(ndev);
        ndev->vers = RTDEV_VERS_2_0;
 
        /* setup board info structure */
diff --git a/kernel/drivers/net/drivers/igb/igb_main.c 
b/kernel/drivers/net/drivers/igb/igb_main.c
index be72754..30e61e6 100644
--- a/kernel/drivers/net/drivers/igb/igb_main.c
+++ b/kernel/drivers/net/drivers/igb/igb_main.c
@@ -1190,7 +1190,6 @@ static int igb_probe(struct pci_dev *pdev,
 
        rtdev_alloc_name(netdev, "rteth%d");
        rt_rtdev_connect(netdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(netdev);
 
        netdev->vers = RTDEV_VERS_2_0;
 
diff --git a/kernel/drivers/net/drivers/loopback.c 
b/kernel/drivers/net/drivers/loopback.c
index 9e7afb9..3fa4c70 100644
--- a/kernel/drivers/net/drivers/loopback.c
+++ b/kernel/drivers/net/drivers/loopback.c
@@ -39,8 +39,6 @@ static struct rtnet_device* rt_loopback_dev;
  */
 static int rt_loopback_open (struct rtnet_device *rtdev)
 {
-    RTNET_MOD_INC_USE_COUNT;
-
     rt_stack_connect(rtdev, &STACK_manager);
     rtnetif_start_queue(rtdev);
 
@@ -57,8 +55,6 @@ static int rt_loopback_close (struct rtnet_device *rtdev)
     rtnetif_stop_queue(rtdev);
     rt_stack_disconnect(rtdev);
 
-    RTNET_MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
@@ -105,7 +101,6 @@ static int __init loopback_init(void)
        return -ENODEV;
 
     rt_rtdev_connect(rtdev, &RTDEV_manager);
-    RTNET_SET_MODULE_OWNER(rtdev);
 
     strcpy(rtdev->name, "rtlo");
 
diff --git a/kernel/drivers/net/drivers/macb.c 
b/kernel/drivers/net/drivers/macb.c
index 6ee76d7..3d462d3 100644
--- a/kernel/drivers/net/drivers/macb.c
+++ b/kernel/drivers/net/drivers/macb.c
@@ -980,8 +980,6 @@ static int macb_open(struct rtnet_device *rtdev)
 
        rtnetif_start_queue(rtdev);
 
-       RTNET_MOD_INC_USE_COUNT;
-
        return 0;
 }
 
@@ -1004,8 +1002,6 @@ static int macb_close(struct rtnet_device *rtdev)
        rt_stack_disconnect(rtdev);
        macb_free_consistent(bp);
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
@@ -1163,7 +1159,6 @@ static int __init macb_probe(struct platform_device *pdev)
 
        rtdev_alloc_name(rtdev, "rteth%d");
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
 
        /* TODO: Actually, we have some interesting features... */
diff --git a/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c 
b/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
index 10d4bda..6b6dc73 100644
--- a/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
+++ b/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
@@ -1168,7 +1168,6 @@ eagain:
 static int
 mpc5xxx_fec_open(struct rtnet_device *dev)
 {
-       RTNET_MOD_INC_USE_COUNT;
        return mpc5xxx_fec_setup(dev,0);
 }
 
@@ -1639,7 +1638,6 @@ static int
 mpc5xxx_fec_close(struct rtnet_device *dev)
 {
        int ret = mpc5xxx_fec_cleanup(dev,0);
-       RTNET_MOD_DEC_USE_COUNT;
        return ret;
 }
 
@@ -1961,7 +1959,6 @@ mpc5xxx_fec_init(void)
        rtdev_alloc_name(dev, "rteth%d");
        memset(dev->priv, 0, sizeof(*priv));
        rt_rtdev_connect(dev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(dev);
        dev->vers = RTDEV_VERS_2_0;
 
 
diff --git a/kernel/drivers/net/drivers/mpc8260_fcc_enet.c 
b/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
index e534224..a1449b2 100644
--- a/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
+++ b/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
@@ -805,8 +805,6 @@ fcc_enet_close(struct rtnet_device *rtdev)
        /* Don't know what to do yet. */
        rtnetif_stop_queue(rtdev);
 
-       MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
@@ -1651,7 +1649,6 @@ int __init fec_enet_init(void)
                }
                rtdev_alloc_name(rtdev, "rteth%d");
                rt_rtdev_connect(rtdev, &RTDEV_manager);
-               RTNET_SET_MODULE_OWNER(rtdev);
                rtdev->vers = RTDEV_VERS_2_0;
 
                cep = (struct fcc_enet_private *)rtdev->priv;
@@ -2233,14 +2230,12 @@ fcc_enet_open(struct rtnet_device *rtdev)
                mii_do_cmd(dev, phy_cmd_relink);
 #endif /* CONFIG_PM826 */
                rtnetif_start_queue(rtdev);
-               MOD_INC_USE_COUNT;
                return 0;               /* Success */
        }
        return -ENODEV;         /* No PHY we understand */
 #else
        fep->link = 1;
        rtnetif_start_queue(rtdev);
-       MOD_INC_USE_COUNT;
        return 0;                                       /* Always succeed */
 #endif /* CONFIG_RTAI_RTNET_USE_MDIO */
 }
diff --git a/kernel/drivers/net/drivers/mpc8xx_enet.c 
b/kernel/drivers/net/drivers/mpc8xx_enet.c
index b0b9814..03ca064 100644
--- a/kernel/drivers/net/drivers/mpc8xx_enet.c
+++ b/kernel/drivers/net/drivers/mpc8xx_enet.c
@@ -194,8 +194,6 @@ static int CPMVEC_ENET;
 static int
 scc_enet_open(struct rtnet_device *rtdev)
 {
-       RTNET_MOD_INC_USE_COUNT;
-
        /* I should reset the ring buffers here, but I don't yet know
         * a simple way to do that.
         */
@@ -589,8 +587,6 @@ scc_enet_close(struct rtnet_device *rtdev)
        */
        rtnetif_stop_queue(rtdev);
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
@@ -747,7 +743,6 @@ int __init scc_enet_init(void)
        }
        rtdev_alloc_name(rtdev, "rteth%d");
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
 
        cep = (struct scc_enet_private *)rtdev->priv;
diff --git a/kernel/drivers/net/drivers/mpc8xx_fec.c 
b/kernel/drivers/net/drivers/mpc8xx_fec.c
index 2d0617f..2dfbff2 100644
--- a/kernel/drivers/net/drivers/mpc8xx_fec.c
+++ b/kernel/drivers/net/drivers/mpc8xx_fec.c
@@ -1566,8 +1566,6 @@ fec_enet_open(struct rtnet_device *rtdev)
         * a simple way to do that.
         */
 
-       RTNET_MOD_INC_USE_COUNT;
-
 #ifdef CONFIG_RTAI_RTNET_USE_MDIO
        fep->sequence_done = 0;
        fep->link = 0;
@@ -1629,7 +1627,6 @@ fec_enet_close(struct rtnet_device *rtdev)
 
        fec_stop(rtdev);
 
-       RTNET_MOD_DEC_USE_COUNT;
        return 0;
 }
 
@@ -1959,7 +1956,6 @@ int __init fec_enet_init(void)
        }
        rtdev_alloc_name(rtdev, "rteth%d");
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
 
        fep = (struct fec_enet_private *)rtdev->priv;
diff --git a/kernel/drivers/net/drivers/natsemi.c 
b/kernel/drivers/net/drivers/natsemi.c
index d86783d..0e9678c 100644
--- a/kernel/drivers/net/drivers/natsemi.c
+++ b/kernel/drivers/net/drivers/natsemi.c
@@ -785,7 +785,6 @@ static int natsemi_probe1 (struct pci_dev *pdev,
        }
        rtdev_alloc_name(dev, "rteth%d");
        rt_rtdev_connect(dev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(dev);
        dev->vers = RTDEV_VERS_2_0;
 /*** RTnet ***/
 
@@ -1129,8 +1128,6 @@ static int netdev_open(struct rtnet_device *dev)
        long ioaddr = dev->base_addr;
        int i;
 
-       RTNET_MOD_INC_USE_COUNT;
-
        /* Reset the chip, just in case. */
        natsemi_reset(dev);
 
@@ -1141,7 +1138,6 @@ static int netdev_open(struct rtnet_device *dev)
 /*** RTnet ***/
 /*     i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);*/
        if (i) {
-               RTNET_MOD_DEC_USE_COUNT;
                return i;
        }
 
@@ -1151,7 +1147,6 @@ static int netdev_open(struct rtnet_device *dev)
        i = alloc_ring(dev);
        if (i < 0) {
                rtdm_irq_free(&np->irq_handle);
-               RTNET_MOD_DEC_USE_COUNT;
                return i;
        }
        init_ring(dev);
@@ -2652,8 +2647,6 @@ static int netdev_close(struct rtnet_device *dev)
                }
        }
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/pcnet32.c 
b/kernel/drivers/net/drivers/pcnet32.c
index 537a979..14532f8 100644
--- a/kernel/drivers/net/drivers/pcnet32.c
+++ b/kernel/drivers/net/drivers/pcnet32.c
@@ -649,7 +649,6 @@ static int pcnet32_probe1(unsigned long ioaddr, unsigned 
int irq_line, int share
        return -ENOMEM;
     rtdev_alloc_name(dev, "rteth%d");
     rt_rtdev_connect(dev, &RTDEV_manager);
-    RTNET_SET_MODULE_OWNER(dev);
     dev->vers = RTDEV_VERS_2_0;
 /*** RTnet ***/
 
@@ -966,8 +965,6 @@ pcnet32_open(struct rtnet_device *dev) /*** RTnet ***/
               lp->a.read_csr(ioaddr, 0));
 
 
-    RTNET_MOD_INC_USE_COUNT;
-
     return 0;  /* Always succeed */
 }
 
@@ -1508,8 +1505,6 @@ pcnet32_close(struct rtnet_device *dev) /*** RTnet ***/
        lp->tx_dma_addr[i] = 0;
     }
 
-    RTNET_MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/r8169.c 
b/kernel/drivers/net/drivers/r8169.c
index 030ad08..c4ef187 100644
--- a/kernel/drivers/net/drivers/r8169.c
+++ b/kernel/drivers/net/drivers/r8169.c
@@ -675,16 +675,9 @@ static int rtl8169_init_board ( struct pci_dev *pdev, 
struct rtnet_device **dev_
        }
        rtdev_alloc_name(rtdev, "rteth%d");
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
        /*** /RTnet ***/
 
-       RTNET_SET_MODULE_OWNER(rtdev);
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
-       //SET_NETDEV_DEV(rtdev, &pdev->dev);
-#endif
-
        priv = rtdev->priv;
 
        // enable device (incl. PCI PM wakeup and hotplug setup)
@@ -1090,11 +1083,8 @@ static int rtl8169_open (struct rtnet_device *rtdev)
 //     u8 diff;
 //     u32 TxPhyAddr, RxPhyAddr;
 
-       RTNET_MOD_INC_USE_COUNT;        /*** RTnet / <kk> ***/
-
        if( priv->drvinit_fail == 1 ){
                printk("%s: Gigabit driver open failed.\n", rtdev->name );
-               RTNET_MOD_DEC_USE_COUNT;        /*** RTnet / <kk> ***/
                return -ENOMEM;
        }
 
@@ -1105,7 +1095,6 @@ static int rtl8169_open (struct rtnet_device *rtdev)
 
        // retval = request_irq (dev->irq, rtl8169_interrupt, SA_SHIRQ, 
dev->name, dev);
        if (retval) {
-               RTNET_MOD_DEC_USE_COUNT;        /*** RTnet / <kk> ***/
                return retval;
        }
 
@@ -1115,14 +1104,12 @@ static int rtl8169_open (struct rtnet_device *rtdev)
        priv->txdesc_space = pci_alloc_consistent( pdev, 
priv->sizeof_txdesc_space, &priv->txdesc_phy_dma_addr );
        if( priv->txdesc_space == NULL ){
                printk("%s: Gigabit driver alloc txdesc_space failed.\n", 
rtdev->name );
-               RTNET_MOD_DEC_USE_COUNT;        /*** RTnet / <kk> ***/
                return -ENOMEM;
        }
        priv->sizeof_rxdesc_space = NUM_RX_DESC * sizeof(struct RxDesc)+256;
        priv->rxdesc_space = pci_alloc_consistent( pdev, 
priv->sizeof_rxdesc_space, &priv->rxdesc_phy_dma_addr );
        if( priv->rxdesc_space == NULL ){
                printk("%s: Gigabit driver alloc rxdesc_space failed.\n", 
rtdev->name );
-               RTNET_MOD_DEC_USE_COUNT;        /*** RTnet / <kk> ***/
                return -ENOMEM;
        }
 
@@ -1958,8 +1945,6 @@ static int rtl8169_close (struct rtnet_device *rtdev)
 
        //DBG_PRINT("%s: %s() alloc_rxskb_cnt = %d\n", dev->name, __FUNCTION__, 
alloc_rxskb_cnt );      /*** <kk> won't work anymore ***/
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/drivers/smc91111.c 
b/kernel/drivers/net/drivers/smc91111.c
index faabc25..9d280d2 100644
--- a/kernel/drivers/net/drivers/smc91111.c
+++ b/kernel/drivers/net/drivers/smc91111.c
@@ -882,8 +882,6 @@ int __init smc_init(struct rtnet_device *dev)
 
        PRINTK2("CARDNAME:smc_init\n");
 
-       RTNET_SET_MODULE_OWNER(dev);
-
        /*  try a specific location */
        if (base_addr > 0x1ff)
                return smc_probe(dev, base_addr);
@@ -1303,9 +1301,6 @@ static int smc_open(struct rtnet_device *dev)
        memset(dev->priv, 0, (size_t)&((struct smc_local *)0)->irq_handle);
 
        rtnetif_start_queue(dev);
-#ifdef MODULE
-       RTNET_MOD_INC_USE_COUNT;
-#endif
 
        // Setup the default Register Modes
        lp->tcr_cur_mode = TCR_DEFAULT;
@@ -1825,9 +1820,6 @@ static int smc_close(struct rtnet_device *dev)
        smc_shutdown( dev->base_addr );
 
        /* Update the statistics here. */
-#ifdef MODULE
-       RTNET_MOD_DEC_USE_COUNT;
-#endif
 
        return 0;
 }
@@ -1929,7 +1921,6 @@ int __init init_module(void)
        }
        rtdev_alloc_name(devSMC91111, "rteth%d");
        rt_rtdev_connect(devSMC91111, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(devSMC91111);
        devSMC91111->vers = RTDEV_VERS_2_0;
 
        /* copy the parameters from insmod into the device structure */
diff --git a/kernel/drivers/net/drivers/tulip/tulip_core.c 
b/kernel/drivers/net/drivers/tulip/tulip_core.c
index 5ea5828..ca845be 100644
--- a/kernel/drivers/net/drivers/tulip/tulip_core.c
+++ b/kernel/drivers/net/drivers/tulip/tulip_core.c
@@ -487,14 +487,11 @@ tulip_open(/*RTnet*/struct rtnet_device *rtdev)
        struct tulip_private *tp = (struct tulip_private *)rtdev->priv;
        int retval;
 
-       RTNET_MOD_INC_USE_COUNT;
-
        if ((retval = /*RTnet*/rtdm_irq_request(&tp->irq_handle, rtdev->irq,
                                                tulip_interrupt, 0, "rt_tulip",
                                                rtdev))) {
                printk("%s: Unable to install ISR for IRQ %d\n",
                          rtdev->name,rtdev->irq);
-               RTNET_MOD_DEC_USE_COUNT;
                return retval;
        }
 
@@ -753,8 +750,6 @@ static int tulip_close (/*RTnet*/struct rtnet_device *rtdev)
 
        rt_stack_disconnect(rtdev);
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
@@ -1155,7 +1150,6 @@ static int tulip_init_one (struct pci_dev *pdev,
        }
        //rtdev_alloc_name(rtdev, "eth%d");//Done by register_rtdev()
        rt_rtdev_connect(rtdev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(rtdev);
        rtdev->vers = RTDEV_VERS_2_0;
 
        if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
diff --git a/kernel/drivers/net/drivers/via-rhine.c 
b/kernel/drivers/net/drivers/via-rhine.c
index c79f7bc..e23e07b 100644
--- a/kernel/drivers/net/drivers/via-rhine.c
+++ b/kernel/drivers/net/drivers/via-rhine.c
@@ -688,7 +688,6 @@ static int via_rhine_init_one (struct pci_dev *pdev,
        }
        rtdev_alloc_name(dev, "rteth%d");
        rt_rtdev_connect(dev, &RTDEV_manager);
-       RTNET_SET_MODULE_OWNER(dev);
        dev->vers = RTDEV_VERS_2_0;
 /*** RTnet ***/
 
@@ -1155,8 +1154,6 @@ static int via_rhine_open(struct rtnet_device *dev) /*** 
RTnet ***/
        void *ioaddr = (void *)dev->base_addr;
        int i;
 
-       RTNET_MOD_INC_USE_COUNT;
-
        /* Reset the chip. */
        writew(CmdReset, ioaddr + ChipCmd);
 
@@ -1166,7 +1163,6 @@ static int via_rhine_open(struct rtnet_device *dev) /*** 
RTnet ***/
                             RTDM_IRQTYPE_SHARED, "rt_via-rhine", dev);
 /*** RTnet ***/
        if (i) {
-               RTNET_MOD_DEC_USE_COUNT;
                return i;
        }
 
@@ -1176,7 +1172,6 @@ static int via_rhine_open(struct rtnet_device *dev) /*** 
RTnet ***/
 
        i = alloc_ring(dev);
        if (i) {
-               RTNET_MOD_DEC_USE_COUNT;
                return i;
        }
        alloc_rbufs(dev);
@@ -1974,8 +1969,6 @@ static int via_rhine_close(struct rtnet_device *dev) /*** 
RTnet ***/
        free_tbufs(dev);
        free_ring(dev);
 
-       RTNET_MOD_DEC_USE_COUNT;
-
        return 0;
 }
 
diff --git a/kernel/drivers/net/stack/include/rtnet_internal.h 
b/kernel/drivers/net/stack/include/rtnet_internal.h
index bec8aae..9626044 100644
--- a/kernel/drivers/net/stack/include/rtnet_internal.h
+++ b/kernel/drivers/net/stack/include/rtnet_internal.h
@@ -36,9 +36,9 @@
 #define RTNET_ASSERT(expr, func) \
     if (!(expr)) \
     { \
-        rtdm_printk("Assertion failed! %s:%s:%d %s\n", \
-        __FILE__, __FUNCTION__, __LINE__, (#expr)); \
-        func \
+       rtdm_printk("Assertion failed! %s:%s:%d %s\n", \
+       __FILE__, __FUNCTION__, __LINE__, (#expr)); \
+       func \
     }
 #else
 #define RTNET_ASSERT(expr, func)
@@ -87,15 +87,15 @@ extern struct proc_dir_entry *rtnet_proc_root;
     const int max_block_len = MAX_BLOCK_LEN;                            \
     off_t __limit           = count - MAX_BLOCK_LEN;                    \
     int   __len             = 0;                                        \
-                                                                        \
+                                                                       \
     *eof = 1;                                                           \
     if (count < MAX_BLOCK_LEN)                                          \
-        return 0
+       return 0
 
 #define RTNET_PROC_PRINT(fmt, args...)                                  \
     ({                                                                  \
-        __len += snprintf(buf + __len, max_block_len, fmt, ##args);     \
-        (__len <= __limit);                                             \
+       __len += snprintf(buf + __len, max_block_len, fmt, ##args);     \
+       (__len <= __limit);                                             \
     })
 
 #define RTNET_PROC_PRINT_DONE                                           \
@@ -108,86 +108,50 @@ extern struct proc_dir_entry *rtnet_proc_root;
     off_t __pos             = 0;                                        \
     off_t __begin           = 0;                                        \
     int   __len             = 0;                                        \
-                                                                        \
+                                                                       \
     *eof = 1;                                                           \
     if (count < MAX_BLOCK_LEN)                                          \
-        return 0
+       return 0
 
 #define RTNET_PROC_PRINT_EX(fmt, args...)                               \
     ({                                                                  \
-        int len = snprintf(buf + __len, max_block_len, fmt, ##args);    \
-        __len += len;                                                   \
-        __pos += len;                                                   \
-        if (__pos < offset) {                                           \
-            __len = 0;                                                  \
-            __begin = __pos;                                            \
-        }                                                               \
-        if (__pos > __limit)                                            \
-            *eof = 0;                                                   \
-        (__pos <= __limit);                                             \
+       int len = snprintf(buf + __len, max_block_len, fmt, ##args);    \
+       __len += len;                                                   \
+       __pos += len;                                                   \
+       if (__pos < offset) {                                           \
+           __len = 0;                                                  \
+           __begin = __pos;                                            \
+       }                                                               \
+       if (__pos > __limit)                                            \
+           *eof = 0;                                                   \
+       (__pos <= __limit);                                             \
     })
 
 #define RTNET_PROC_PRINT_DONE_EX                                        \
     *start = buf + (offset - __begin);                                  \
     __len -= (offset - __begin);                                        \
     if (__len > count)                                                  \
-        __len = count;                                                  \
+       __len = count;                                                  \
     if (__len < 0)                                                      \
-        __len = 0;                                                      \
+       __len = 0;                                                      \
     return __len;
 
 #endif /* CONFIG_PROC_FS */
 
-
-/* manage module reference counter */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-
-static inline void RTNET_MOD_INC_USE_COUNT_EX(struct module *module)
-{
-    if (!try_module_get(module))
-        WARN_ON(1);
-}
-
-static inline void RTNET_MOD_DEC_USE_COUNT_EX(struct module *module)
-{
-    module_put(module);
-}
-
-#else
-
-static inline void RTNET_MOD_INC_USE_COUNT_EX(struct module *module)
-{
-    __MOD_INC_USE_COUNT(module);
-}
-
-static inline void RTNET_MOD_DEC_USE_COUNT_EX(struct module *module)
-{
-    __MOD_DEC_USE_COUNT(module);
-}
-
-#endif
-
-#define RTNET_MOD_INC_USE_COUNT RTNET_MOD_INC_USE_COUNT_EX(THIS_MODULE)
-#define RTNET_MOD_DEC_USE_COUNT RTNET_MOD_DEC_USE_COUNT_EX(THIS_MODULE)
-
-#define RTNET_SET_MODULE_OWNER(some_struct) \
-    do { (some_struct)->rt_owner = THIS_MODULE; } while (0)
-
-
 #ifndef list_for_each_entry
 #define list_for_each_entry(pos, head, member)                      \
     for (pos = list_entry((head)->next, typeof(*pos), member),      \
-                          prefetch(pos->member.next);               \
-         &pos->member != (head);                                    \
-         pos = list_entry(pos->member.next, typeof(*pos), member),  \
-                          prefetch(pos->member.next))
+                         prefetch(pos->member.next);               \
+        &pos->member != (head);                                    \
+        pos = list_entry(pos->member.next, typeof(*pos), member),  \
+                         prefetch(pos->member.next))
 #endif
 
 
 #ifndef container_of
 #define container_of(ptr, type, member) ({                      \
-        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-        (type *)( (char *)__mptr - offsetof(type,member) );})
+       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
diff --git a/kernel/drivers/net/stack/rtmac/nomac/nomac_module.c 
b/kernel/drivers/net/stack/rtmac/nomac/nomac_module.c
index 5e8f3ba..99ede78 100644
--- a/kernel/drivers/net/stack/rtmac/nomac/nomac_module.c
+++ b/kernel/drivers/net/stack/rtmac/nomac/nomac_module.c
@@ -39,7 +39,7 @@ DEFINE_MUTEX(nomac_nrt_lock);
 
 
 int nomac_proc_read(char *buf, char **start, off_t offset, int count,
-                    int *eof, void *data)
+                   int *eof, void *data)
 {
     struct nomac_priv *entry;
     RTNET_PROC_PRINT_VARS(80);
@@ -48,12 +48,12 @@ int nomac_proc_read(char *buf, char **start, off_t offset, 
int count,
     mutex_lock(&nomac_nrt_lock);
 
     if (!RTNET_PROC_PRINT("Interface       API Device      State\n"))
-        goto done;
+       goto done;
 
     list_for_each_entry(entry, &nomac_devices, list_entry) {
-        if (!RTNET_PROC_PRINT("%-15s %-15s Attached\n", entry->rtdev->name,
-                              entry->api_device.device_name))
-            break;
+       if (!RTNET_PROC_PRINT("%-15s %-15s Attached\n", entry->rtdev->name,
+                             entry->api_device.device_name))
+           break;
     }
 
   done:
@@ -78,9 +78,7 @@ int nomac_attach(struct rtnet_device *rtdev, void *priv)
 
     ret = nomac_dev_init(rtdev, nomac);
     if (ret < 0)
-        return ret;
-
-    RTNET_MOD_INC_USE_COUNT;
+       return ret;
 
 #ifdef CONFIG_PROC_FS
     mutex_lock(&nomac_nrt_lock);
@@ -101,8 +99,6 @@ int nomac_detach(struct rtnet_device *rtdev, void *priv)
     nomac_dev_release(nomac);
 
     /* ... */
-    RTNET_MOD_DEC_USE_COUNT;
-
 #ifdef CONFIG_PROC_FS
     mutex_lock(&nomac_nrt_lock);
     list_del(&nomac->list_entry);
@@ -138,9 +134,9 @@ struct rtmac_disc nomac_disc = {
     detach:         nomac_detach,
 
     ioctls:         {
-        service_name:   "RTmac/NoMAC",
-        ioctl_type:     RTNET_IOC_TYPE_RTMAC_NOMAC,
-        handler:        nomac_ioctl
+       service_name:   "RTmac/NoMAC",
+       ioctl_type:     RTNET_IOC_TYPE_RTMAC_NOMAC,
+       handler:        nomac_ioctl
     },
 
 #ifdef CONFIG_PROC_FS
@@ -159,12 +155,12 @@ int __init nomac_init(void)
 
     ret = nomac_proto_init();
     if (ret < 0)
-        return ret;
+       return ret;
 
     ret = rtmac_disc_register(&nomac_disc);
     if (ret < 0) {
-        nomac_proto_cleanup();
-        return ret;
+       nomac_proto_cleanup();
+       return ret;
     }
 
     return 0;
diff --git a/kernel/drivers/net/stack/rtmac/rtmac_disc.c 
b/kernel/drivers/net/stack/rtmac/rtmac_disc.c
index 704ebd4..b498a87 100644
--- a/kernel/drivers/net/stack/rtmac/rtmac_disc.c
+++ b/kernel/drivers/net/stack/rtmac/rtmac_disc.c
@@ -63,49 +63,59 @@ int rtmac_disc_attach(struct rtnet_device *rtdev, struct 
rtmac_disc *disc)
     RTNET_ASSERT(disc->attach != NULL, return -EINVAL;);
 
     if (rtdev->mac_disc) {
-        printk("RTmac: another discipline for rtdev '%s' active.\n", 
rtdev->name);
-        return -EBUSY;
+       printk("RTmac: another discipline for rtdev '%s' active.\n", 
rtdev->name);
+       return -EBUSY;
     }
 
     if (rtdev->flags & IFF_LOOPBACK)
-        return -EINVAL;
+       return -EINVAL;
 
     if (!try_module_get(disc->owner))
-        return -EIDRM;
+       return -EIDRM;
+
+    if (!rtdev_reference(rtdev)) {
+       ret = -EIDRM;
+       goto err_module_put;
+    }
 
     /* alloc memory */
     priv = kmalloc(sizeof(struct rtmac_priv) + disc->priv_size, GFP_KERNEL);
     if (!priv) {
-        printk("RTmac: kmalloc returned NULL for rtmac!\n");
-        return -ENOMEM;
+       printk("RTmac: kmalloc returned NULL for rtmac!\n");
+       return -ENOMEM;
     }
     priv->orig_start_xmit = rtdev->start_xmit;
 
     /* call attach function of discipline */
     ret = disc->attach(rtdev, priv->disc_priv);
-    if (ret < 0) {
-        kfree(priv);
-        return ret;
-    }
+    if (ret < 0)
+       goto err_kfree_priv;
 
     /* now attach RTmac to device */
     rtdev->mac_disc = disc;
     rtdev->mac_priv = priv;
     rtdev->start_xmit = disc->rt_packet_tx;
     if (disc->get_mtu)
-        rtdev->get_mtu = disc->get_mtu;
+       rtdev->get_mtu = disc->get_mtu;
     rtdev->mac_detach = rtmac_disc_detach;
 
-    RTNET_MOD_INC_USE_COUNT_EX(rtdev->rt_owner);
-    rtdev_reference(rtdev);
-
     /* create the VNIC */
     ret = rtmac_vnic_add(rtdev, disc->vnic_xmit);
     if (ret < 0) {
-        printk("RTmac: Warning, VNIC creation failed for rtdev %s.\n", 
rtdev->name);
+       printk("RTmac: Warning, VNIC creation failed for rtdev %s.\n", 
rtdev->name);
+       goto err_disc_detach;
     }
 
     return 0;
+
+  err_disc_detach:
+    disc->detach(rtdev, priv->disc_priv);
+  err_kfree_priv:
+    kfree(priv);
+    rtdev_dereference(rtdev);
+  err_module_put:
+    mdoule_put(disc->owner);
+    return ret;
 }
 
 
@@ -133,7 +143,7 @@ int rtmac_disc_detach(struct rtnet_device *rtdev)
 
     disc = rtdev->mac_disc;
     if (!disc)
-        return -ENODEV;
+       return -ENODEV;
 
     RTNET_ASSERT(disc->detach != NULL, return -EINVAL;);
 
@@ -142,12 +152,12 @@ int rtmac_disc_detach(struct rtnet_device *rtdev)
 
     ret = rtmac_vnic_unregister(rtdev);
     if (ret < 0)
-        return ret;
+       return ret;
 
     /* call release function of discipline */
     ret = disc->detach(rtdev, priv->disc_priv);
     if (ret < 0)
-        return ret;
+       return ret;
 
     rtmac_vnic_cleanup(rtdev);
 
@@ -160,7 +170,6 @@ int rtmac_disc_detach(struct rtnet_device *rtdev)
     rtdev->mac_priv   = NULL;
     rtdev->mac_detach = NULL;
 
-    RTNET_MOD_DEC_USE_COUNT_EX(rtdev->rt_owner);
     rtdev_dereference(rtdev);
 
     kfree(priv);
@@ -180,10 +189,10 @@ static struct rtmac_disc *rtmac_get_disc_by_name(const 
char *name)
     mutex_lock(&disc_list_lock);
 
     list_for_each(disc, &disc_list) {
-        if (strcmp(((struct rtmac_disc *)disc)->name, name) == 0) {
-            mutex_unlock(&disc_list_lock);
-            return (struct rtmac_disc *)disc;
-        }
+       if (strcmp(((struct rtmac_disc *)disc)->name, name) == 0) {
+           mutex_unlock(&disc_list_lock);
+           return (struct rtmac_disc *)disc;
+       }
     }
 
     mutex_unlock(&disc_list_lock);
@@ -209,19 +218,19 @@ int __rtmac_disc_register(struct rtmac_disc *disc, struct 
module *module)
 
     if (rtmac_get_disc_by_name(disc->name) != NULL)
     {
-        printk("RTmac: discipline '%s' already registered!\n", disc->name);
-        return -EBUSY;
+       printk("RTmac: discipline '%s' already registered!\n", disc->name);
+       return -EBUSY;
     }
 
     ret = rtnet_register_ioctls(&disc->ioctls);
     if (ret < 0)
-        return ret;
+       return ret;
 
 #ifdef CONFIG_PROC_FS
     ret = rtmac_disc_proc_register(disc);
     if (ret < 0) {
-        rtnet_unregister_ioctls(&disc->ioctls);
-        return ret;
+       rtnet_unregister_ioctls(&disc->ioctls);
+       return ret;
     }
 #endif /* CONFIG_PROC_FS */
 
@@ -257,7 +266,7 @@ void rtmac_disc_deregister(struct rtmac_disc *disc)
 
 #ifdef CONFIG_PROC_FS
 int rtmac_proc_read_disc(char *buf, char **start, off_t offset, int count,
-                         int *eof, void *data)
+                        int *eof, void *data)
 {
     struct list_head    *disc;
     RTNET_PROC_PRINT_VARS(80);
@@ -266,13 +275,13 @@ int rtmac_proc_read_disc(char *buf, char **start, off_t 
offset, int count,
     mutex_lock(&disc_list_lock);
 
     if (!RTNET_PROC_PRINT("Name\t\tID\n"))
-        goto done;
+       goto done;
 
     list_for_each(disc, &disc_list) {
-        if (!RTNET_PROC_PRINT("%-15s %04X\n",
-                              ((struct rtmac_disc *)disc)->name,
-                              ntohs(((struct rtmac_disc *)disc)->disc_type)))
-            break;
+       if (!RTNET_PROC_PRINT("%-15s %04X\n",
+                             ((struct rtmac_disc *)disc)->name,
+                             ntohs(((struct rtmac_disc *)disc)->disc_type)))
+           break;
     }
 
   done:
diff --git a/kernel/drivers/net/stack/rtmac/rtmac_vnic.c 
b/kernel/drivers/net/stack/rtmac/rtmac_vnic.c
index 7aa4eda..db1b4c6 100644
--- a/kernel/drivers/net/stack/rtmac/rtmac_vnic.c
+++ b/kernel/drivers/net/stack/rtmac/rtmac_vnic.c
@@ -49,9 +49,9 @@ int rtmac_vnic_rx(struct rtskb *rtskb, u16 type)
 
 
     if (rtskb_acquire(rtskb, pool) != 0) {
-        mac_priv->vnic_stats.rx_dropped++;
-        kfree_rtskb(rtskb);
-        return -1;
+       mac_priv->vnic_stats.rx_dropped++;
+       kfree_rtskb(rtskb);
+       return -1;
     }
 
     rtskb->protocol = type;
@@ -76,52 +76,52 @@ static void rtmac_vnic_signal_handler(rtdm_nrtsig_t 
*nrtsig, void *arg)
 
     while (1)
     {
-        rtskb = rtskb_dequeue(&rx_queue);
-        if (!rtskb)
-            break;
+       rtskb = rtskb_dequeue(&rx_queue);
+       if (!rtskb)
+           break;
 
-        rtdev  = rtskb->rtdev;
-        hdrlen = rtdev->hard_header_len;
+       rtdev  = rtskb->rtdev;
+       hdrlen = rtdev->hard_header_len;
 
-        skb = dev_alloc_skb(hdrlen + rtskb->len + 2);
-        if (skb) {
-            /* the rtskb stamp is useless (different clock), get new one */
+       skb = dev_alloc_skb(hdrlen + rtskb->len + 2);
+       if (skb) {
+           /* the rtskb stamp is useless (different clock), get new one */
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
-            __net_timestamp(skb);
+           __net_timestamp(skb);
 #else
-            do_gettimeofday(&skb->stamp);
+           do_gettimeofday(&skb->stamp);
 #endif
 
-            skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
+           skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
 
-            /* copy Ethernet header */
-            memcpy(skb_put(skb, hdrlen),
-                   rtskb->data - hdrlen - sizeof(struct rtmac_hdr), hdrlen);
+           /* copy Ethernet header */
+           memcpy(skb_put(skb, hdrlen),
+                  rtskb->data - hdrlen - sizeof(struct rtmac_hdr), hdrlen);
 
-            /* patch the protocol field in the original Ethernet header */
-            ((struct ethhdr*)skb->data)->h_proto = rtskb->protocol;
+           /* patch the protocol field in the original Ethernet header */
+           ((struct ethhdr*)skb->data)->h_proto = rtskb->protocol;
 
-            /* copy data */
-            memcpy(skb_put(skb, rtskb->len), rtskb->data, rtskb->len);
+           /* copy data */
+           memcpy(skb_put(skb, rtskb->len), rtskb->data, rtskb->len);
 
-            skb->dev      = rtskb->rtdev->mac_priv->vnic;
-            skb->protocol = eth_type_trans(skb, skb->dev);
+           skb->dev      = rtskb->rtdev->mac_priv->vnic;
+           skb->protocol = eth_type_trans(skb, skb->dev);
 
-            stats = &rtskb->rtdev->mac_priv->vnic_stats;
+           stats = &rtskb->rtdev->mac_priv->vnic_stats;
 
-            kfree_rtskb(rtskb);
+           kfree_rtskb(rtskb);
 
-            stats->rx_packets++;
-            stats->rx_bytes += skb->len;
+           stats->rx_packets++;
+           stats->rx_bytes += skb->len;
 
-            netif_rx(skb);
-        }
-        else {
-            printk("RTmac: VNIC fails to allocate linux skb\n");
-            kfree_rtskb(rtskb);
-        }
+           netif_rx(skb);
+       }
+       else {
+           printk("RTmac: VNIC fails to allocate linux skb\n");
+           kfree_rtskb(rtskb);
+       }
 
-        rtdev_dereference(rtdev);
+       rtdev_dereference(rtdev);
     }
 }
 
@@ -130,8 +130,8 @@ static void rtmac_vnic_signal_handler(rtdm_nrtsig_t 
*nrtsig, void *arg)
 static int rtmac_vnic_copy_mac(struct net_device *dev)
 {
     memcpy(dev->dev_addr,
-           (*(struct rtnet_device **)netdev_priv(dev))->dev_addr,
-           MAX_ADDR_LEN);
+          (*(struct rtnet_device **)netdev_priv(dev))->dev_addr,
+          MAX_ADDR_LEN);
 
     return 0;
 }
@@ -150,34 +150,34 @@ int rtmac_vnic_xmit(struct sk_buff *skb, struct 
net_device *dev)
 
 
     rtskb =
-        alloc_rtskb((skb->len + sizeof(struct rtmac_hdr) + 15) & ~15, pool);
+       alloc_rtskb((skb->len + sizeof(struct rtmac_hdr) + 15) & ~15, pool);
     if (!rtskb)
-        return NETDEV_TX_BUSY;
+       return NETDEV_TX_BUSY;
 
     rtskb_reserve(rtskb, rtdev->hard_header_len + sizeof(struct rtmac_hdr));
 
     data_len = skb->len - dev->hard_header_len;
     memcpy(rtskb_put(rtskb, data_len), skb->data + dev->hard_header_len,
-           data_len);
+          data_len);
 
     res = rtmac_add_header(rtdev, ethernet->h_dest, rtskb,
-                           ntohs(ethernet->h_proto), RTMAC_FLAG_TUNNEL);
+                          ntohs(ethernet->h_proto), RTMAC_FLAG_TUNNEL);
     if (res < 0) {
-        stats->tx_dropped++;
-        kfree_rtskb(rtskb);
-        goto done;
+       stats->tx_dropped++;
+       kfree_rtskb(rtskb);
+       goto done;
     }
 
     RTNET_ASSERT(rtdev->mac_disc->nrt_packet_tx != NULL, kfree_rtskb(rtskb);
-                 goto done;);
+                goto done;);
 
     res = rtdev->mac_disc->nrt_packet_tx(rtskb);
     if (res < 0) {
-        stats->tx_dropped++;
-        kfree_rtskb(rtskb);
+       stats->tx_dropped++;
+       kfree_rtskb(rtskb);
     } else {
-        stats->tx_packets++;
-        stats->tx_bytes += skb->len;
+       stats->tx_packets++;
+       stats->tx_bytes += skb->len;
     }
 
 done:
@@ -197,8 +197,8 @@ static struct net_device_stats *rtmac_vnic_get_stats(struct 
net_device *dev)
 static int rtmac_vnic_change_mtu(struct net_device *dev, int new_mtu)
 {
     if ((new_mtu < 68) ||
-        ((unsigned)new_mtu > 1500 - sizeof(struct rtmac_hdr)))
-        return -EINVAL;
+       ((unsigned)new_mtu > 1500 - sizeof(struct rtmac_hdr)))
+       return -EINVAL;
     dev->mtu = new_mtu;
     return 0;
 }
@@ -219,14 +219,14 @@ void rtmac_vnic_set_max_mtu(struct rtnet_device *rtdev, 
unsigned int max_mtu)
     rtnl_lock();
     if ((vnic->mtu > mac_priv->vnic_max_mtu) || (prev_mtu == 
mac_priv->vnic_max_mtu)) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-        dev_set_mtu(vnic, mac_priv->vnic_max_mtu);
+       dev_set_mtu(vnic, mac_priv->vnic_max_mtu);
 #else   /* LINUX_VERSION_CODE < 2.6.x */
-        if (vnic->flags & IFF_UP) {
-            dev_close(vnic);
-            vnic->mtu = mac_priv->vnic_max_mtu;
-            dev_open(vnic);
-        } else
-            vnic->mtu = mac_priv->vnic_max_mtu;
+       if (vnic->flags & IFF_UP) {
+           dev_close(vnic);
+           vnic->mtu = mac_priv->vnic_max_mtu;
+           dev_open(vnic);
+       } else
+           vnic->mtu = mac_priv->vnic_max_mtu;
 #endif  /* LINUX_VERSION_CODE < 2.6.x */
     }
     rtnl_unlock();
@@ -255,10 +255,6 @@ static void rtmac_vnic_setup(struct net_device *dev)
 #endif /* !HAVE_NET_DEVICE_OPS */
 
     dev->flags           &= ~IFF_MULTICAST;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-    SET_MODULE_OWNER(dev);
-#endif
 }
 
 static int rtmac_vnic_pool_trylock(void *cookie)
@@ -285,7 +281,7 @@ int rtmac_vnic_add(struct rtnet_device *rtdev, 
vnic_xmit_handler vnic_xmit)
 
     /* does the discipline request vnic support? */
     if (!vnic_xmit)
-        return 0;
+       return 0;
 
     mac_priv->vnic = NULL;
     mac_priv->vnic_max_mtu = rtdev->mtu - sizeof(struct rtmac_hdr);
@@ -293,18 +289,18 @@ int rtmac_vnic_add(struct rtnet_device *rtdev, 
vnic_xmit_handler vnic_xmit)
 
     /* create the rtskb pool */
     if (rtskb_pool_init(&mac_priv->vnic_skb_pool,
-                            vnic_rtskbs, &rtmac_vnic_pool_lock_ops,
-                            NULL) < vnic_rtskbs) {
-        res = -ENOMEM;
-        goto error;
+                           vnic_rtskbs, &rtmac_vnic_pool_lock_ops,
+                           NULL) < vnic_rtskbs) {
+       res = -ENOMEM;
+       goto error;
     }
 
     snprintf(buf, sizeof(buf), "vnic%d", rtdev->ifindex-1);
 
     vnic = alloc_netdev(sizeof(struct rtnet_device *), buf, rtmac_vnic_setup);
     if (!vnic) {
-        res = -ENOMEM;
-        goto error;
+       res = -ENOMEM;
+       goto error;
     }
 
 #ifdef HAVE_NET_DEVICE_OPS
@@ -318,7 +314,7 @@ int rtmac_vnic_add(struct rtnet_device *rtdev, 
vnic_xmit_handler vnic_xmit)
 
     res = register_netdev(vnic);
     if (res < 0)
-        goto error;
+       goto error;
 
     mac_priv->vnic = vnic;
 
@@ -337,12 +333,12 @@ int rtmac_vnic_unregister(struct rtnet_device *rtdev)
     int err;
 
     if (mac_priv->vnic) {
-        err = rtskb_pool_release(&mac_priv->vnic_skb_pool);
-        if (err < 0)
-            return err;
-        unregister_netdev(mac_priv->vnic);
-        free_netdev(mac_priv->vnic);
-        mac_priv->vnic = NULL;
+       err = rtskb_pool_release(&mac_priv->vnic_skb_pool);
+       if (err < 0)
+           return err;
+       unregister_netdev(mac_priv->vnic);
+       free_netdev(mac_priv->vnic);
+       mac_priv->vnic = NULL;
     }
 
     return 0;
@@ -352,7 +348,7 @@ int rtmac_vnic_unregister(struct rtnet_device *rtdev)
 
 #ifdef CONFIG_PROC_FS
 int rtmac_proc_read_vnic(char *buf, char **start, off_t offset, int count,
-                         int *eof, void *data)
+                        int *eof, void *data)
 {
     struct rtnet_device *rtdev;
     int                 i;
@@ -361,31 +357,31 @@ int rtmac_proc_read_vnic(char *buf, char **start, off_t 
offset, int count,
 
 
     if (!RTNET_PROC_PRINT("RT-NIC name\tVNIC name\n"))
-        goto done;
+       goto done;
 
     for (i = 1; i <= MAX_RT_DEVICES; i++) {
-        rtdev = rtdev_get_by_index(i);
-        if (rtdev == NULL)
-            continue;
+       rtdev = rtdev_get_by_index(i);
+       if (rtdev == NULL)
+           continue;
 
-        if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
-            rtdev_dereference(rtdev);
-            return -ERESTARTSYS;
-        }
+       if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
+           rtdev_dereference(rtdev);
+           return -ERESTARTSYS;
+       }
 
-        if (rtdev->mac_priv != NULL) {
-            struct rtmac_priv *rtmac;
+       if (rtdev->mac_priv != NULL) {
+           struct rtmac_priv *rtmac;
 
-            rtmac = (struct rtmac_priv *)rtdev->mac_priv;
-            res = RTNET_PROC_PRINT("%-15s %s\n",
-                                    rtdev->name, rtmac->vnic->name);
-        }
+           rtmac = (struct rtmac_priv *)rtdev->mac_priv;
+           res = RTNET_PROC_PRINT("%-15s %s\n",
+                                   rtdev->name, rtmac->vnic->name);
+       }
 
-        mutex_unlock(&rtdev->nrt_lock);
-        rtdev_dereference(rtdev);
+       mutex_unlock(&rtdev->nrt_lock);
+       rtdev_dereference(rtdev);
 
-        if (!res)
-            break;
+       if (!res)
+           break;
     }
 
   done:
@@ -414,7 +410,7 @@ void rtmac_vnic_module_cleanup(void)
     rtdm_nrtsig_destroy(&vnic_signal);
 
     while ((rtskb = rtskb_dequeue(&rx_queue)) != NULL) {
-        rtdev_dereference(rtskb->rtdev);
-        kfree_rtskb(rtskb);
+       rtdev_dereference(rtskb->rtdev);
+       kfree_rtskb(rtskb);
     }
 }
diff --git a/kernel/drivers/net/stack/rtmac/tdma/tdma_module.c 
b/kernel/drivers/net/stack/rtmac/tdma/tdma_module.c
index 8d9cbb1..f33eceb 100644
--- a/kernel/drivers/net/stack/rtmac/tdma/tdma_module.c
+++ b/kernel/drivers/net/stack/rtmac/tdma/tdma_module.c
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(start_timer, "set to non-zero to start RTAI 
timer");
 
 #ifdef CONFIG_PROC_FS
 int tdma_proc_read(char *buf, char **start, off_t offset, int count,
-                    int *eof, void *data)
+                   int *eof, void *data)
 {
     struct rtnet_device *rtdev = NULL;
     struct tdma_priv    *tdma;
@@ -60,64 +60,64 @@ int tdma_proc_read(char *buf, char **start, off_t offset, 
int count,
 
 
     if (!RTNET_PROC_PRINT("Interface       API Device      Operation Mode  "
-                          "Cycle   State\n"))
-        goto done;
+                         "Cycle   State\n"))
+       goto done;
 
     for (d = 1; d <= MAX_RT_DEVICES; d++) {
-        rtdev = rtdev_get_by_index(d);
-        if (!rtdev)
-            continue;
-
-        if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
-            rtdev_dereference(rtdev);
-            rtdev = NULL;
-            break;
-        }
-
-        if (!rtdev->mac_priv)
-            goto unlock_dev;
-        tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
-
-        if (!RTNET_PROC_PRINT("%-15s %-15s ", rtdev->name,
-                              tdma->api_device.device_name))
-            break;
-        if (test_bit(TDMA_FLAG_CALIBRATED, &tdma->flags)) {
+       rtdev = rtdev_get_by_index(d);
+       if (!rtdev)
+           continue;
+
+       if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
+           rtdev_dereference(rtdev);
+           rtdev = NULL;
+           break;
+       }
+
+       if (!rtdev->mac_priv)
+           goto unlock_dev;
+       tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
+
+       if (!RTNET_PROC_PRINT("%-15s %-15s ", rtdev->name,
+                             tdma->api_device.device_name))
+           break;
+       if (test_bit(TDMA_FLAG_CALIBRATED, &tdma->flags)) {
 #ifdef CONFIG_XENO_DRIVERS_NET_TDMA_MASTER
-            if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags) &&
-                !test_bit(TDMA_FLAG_BACKUP_ACTIVE, &tdma->flags))
-                state = "stand-by";
-            else
+           if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags) &&
+               !test_bit(TDMA_FLAG_BACKUP_ACTIVE, &tdma->flags))
+               state = "stand-by";
+           else
 #endif /* CONFIG_XENO_DRIVERS_NET_TDMA_MASTER */
-                state = "active";
-        } else
-            state = "init";
+               state = "active";
+       } else
+           state = "init";
 #ifdef CONFIG_XENO_DRIVERS_NET_TDMA_MASTER
-        if (test_bit(TDMA_FLAG_MASTER, &tdma->flags)) {
-            cycle = tdma->cycle_period + 500;
-            do_div(cycle, 1000);
-            if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
-                if (!RTNET_PROC_PRINT("Backup Master   %-7ld %s\n",
-                                      (unsigned long)cycle, state))
-                    break;
-            } else {
-                if (!RTNET_PROC_PRINT("Master          %-7ld %s\n",
-                                      (unsigned long)cycle, state))
-                    break;
-            }
-        } else
+       if (test_bit(TDMA_FLAG_MASTER, &tdma->flags)) {
+           cycle = tdma->cycle_period + 500;
+           do_div(cycle, 1000);
+           if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
+               if (!RTNET_PROC_PRINT("Backup Master   %-7ld %s\n",
+                                     (unsigned long)cycle, state))
+                   break;
+           } else {
+               if (!RTNET_PROC_PRINT("Master          %-7ld %s\n",
+                                     (unsigned long)cycle, state))
+                   break;
+           }
+       } else
 #endif /* CONFIG_XENO_DRIVERS_NET_TDMA_MASTER */
-            if (!RTNET_PROC_PRINT("Slave           -       %s\n", state))
-                break;
+           if (!RTNET_PROC_PRINT("Slave           -       %s\n", state))
+               break;
 unlock_dev:
-        mutex_unlock(&rtdev->nrt_lock);
-        rtdev_dereference(rtdev);
-        rtdev = NULL;
+       mutex_unlock(&rtdev->nrt_lock);
+       rtdev_dereference(rtdev);
+       rtdev = NULL;
     }
 
 done:
     if (rtdev) {
-        mutex_unlock(&rtdev->nrt_lock);
-        rtdev_dereference(rtdev);
+       mutex_unlock(&rtdev->nrt_lock);
+       rtdev_dereference(rtdev);
     }
     RTNET_PROC_PRINT_DONE;
 }
@@ -125,7 +125,7 @@ done:
 
 
 int tdma_slots_proc_read(char *buf, char **start, off_t offset, int count,
-                         int *eof, void *data)
+                        int *eof, void *data)
 {
     struct rtnet_device *rtdev = NULL;
     struct tdma_priv    *tdma;
@@ -137,77 +137,77 @@ int tdma_slots_proc_read(char *buf, char **start, off_t 
offset, int count,
 
 
     if (!RTNET_PROC_PRINT("Interface       "
-                          "Slots (id[->joint]:offset:phasing/period:size)\n"))
-        goto done;
+                         "Slots (id[->joint]:offset:phasing/period:size)\n"))
+       goto done;
 
     for (d = 1; d <= MAX_RT_DEVICES; d++) {
-        rtdev = rtdev_get_by_index(d);
-        if (!rtdev)
-            continue;
+       rtdev = rtdev_get_by_index(d);
+       if (!rtdev)
+           continue;
 
-        if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
-            rtdev_dereference(rtdev);
-            rtdev = NULL;
-            break;
-        }
+       if (mutex_lock_interruptible(&rtdev->nrt_lock)) {
+           rtdev_dereference(rtdev);
+           rtdev = NULL;
+           break;
+       }
 
-        if (!rtdev->mac_priv)
-            goto unlock_dev;
-        tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
+       if (!rtdev->mac_priv)
+           goto unlock_dev;
+       tdma = (struct tdma_priv *)rtdev->mac_priv->disc_priv;
 
-        if (!RTNET_PROC_PRINT("%-15s ", rtdev->name))
-            break;
+       if (!RTNET_PROC_PRINT("%-15s ", rtdev->name))
+           break;
 
 #ifdef CONFIG_XENO_DRIVERS_NET_TDMA_MASTER
-        if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
-            slot_offset = tdma->backup_sync_inc - tdma->cycle_period + 500;
-            do_div(slot_offset, 1000);
-            if (!RTNET_PROC_PRINT("bak:%ld  ", (unsigned long)slot_offset))
-                break;
-        }
+       if (test_bit(TDMA_FLAG_BACKUP_MASTER, &tdma->flags)) {
+           slot_offset = tdma->backup_sync_inc - tdma->cycle_period + 500;
+           do_div(slot_offset, 1000);
+           if (!RTNET_PROC_PRINT("bak:%ld  ", (unsigned long)slot_offset))
+               break;
+       }
 #endif /* CONFIG_XENO_DRIVERS_NET_TDMA_MASTER */
 
-        if (tdma->slot_table)
-            for (i = 0; i <= tdma->max_slot_id; i++) {
-                slot = tdma->slot_table[i];
-                if (!slot ||
-                    ((i == DEFAULT_NRT_SLOT) &&
-                     (tdma->slot_table[DEFAULT_SLOT] == slot)))
-                    continue;
-
-                if (slot->queue == &slot->local_queue) {
-                    if (!RTNET_PROC_PRINT("%d", i))
-                        goto done;
-                } else
-                    for (jnt_id = 0; jnt_id <= tdma->max_slot_id; jnt_id++)
-                        if (&tdma->slot_table[jnt_id]->local_queue ==
-                            slot->queue) {
-                            if (!RTNET_PROC_PRINT("%d->%d", i, jnt_id))
-                                goto done;
-                            break;
-                        }
-
-                slot_offset = slot->offset + 500;
-                do_div(slot_offset, 1000);
-                if (!RTNET_PROC_PRINT(":%ld:%d/%d:%d  ",
-                        (unsigned long)slot_offset, slot->phasing + 1,
-                        slot->period, slot->mtu))
-                    goto done;
-            }
-
-        if (!RTNET_PROC_PRINT("\n"))
-            break;
+       if (tdma->slot_table)
+           for (i = 0; i <= tdma->max_slot_id; i++) {
+               slot = tdma->slot_table[i];
+               if (!slot ||
+                   ((i == DEFAULT_NRT_SLOT) &&
+                    (tdma->slot_table[DEFAULT_SLOT] == slot)))
+                   continue;
+
+               if (slot->queue == &slot->local_queue) {
+                   if (!RTNET_PROC_PRINT("%d", i))
+                       goto done;
+               } else
+                   for (jnt_id = 0; jnt_id <= tdma->max_slot_id; jnt_id++)
+                       if (&tdma->slot_table[jnt_id]->local_queue ==
+                           slot->queue) {
+                           if (!RTNET_PROC_PRINT("%d->%d", i, jnt_id))
+                               goto done;
+                           break;
+                       }
+
+               slot_offset = slot->offset + 500;
+               do_div(slot_offset, 1000);
+               if (!RTNET_PROC_PRINT(":%ld:%d/%d:%d  ",
+                       (unsigned long)slot_offset, slot->phasing + 1,
+                       slot->period, slot->mtu))
+                   goto done;
+           }
+
+       if (!RTNET_PROC_PRINT("\n"))
+           break;
 
 unlock_dev:
-        mutex_unlock(&rtdev->nrt_lock);
-        rtdev_dereference(rtdev);
-        rtdev = NULL;
+       mutex_unlock(&rtdev->nrt_lock);
+       rtdev_dereference(rtdev);
+       rtdev = NULL;
     }
 
 done:
     if (rtdev) {
-        mutex_unlock(&rtdev->nrt_lock);
-        rtdev_dereference(rtdev);
+       mutex_unlock(&rtdev->nrt_lock);
+       rtdev_dereference(rtdev);
     }
     RTNET_PROC_PRINT_DONE;
 }
@@ -234,14 +234,12 @@ int tdma_attach(struct rtnet_device *rtdev, void *priv)
 
     ret = tdma_dev_init(rtdev, tdma);
     if (ret < 0)
-        goto err_out1;
+       goto err_out1;
 
     ret = rtdm_task_init(&tdma->worker_task, "rtnet-tdma", tdma_worker, tdma,
-                         DEF_WORKER_PRIO, 0);
+                        DEF_WORKER_PRIO, 0);
     if (ret != 0)
-        goto err_out2;
-
-    RTNET_MOD_INC_USE_COUNT;
+       goto err_out2;
 
     return 0;
 
@@ -274,29 +272,27 @@ int tdma_detach(struct rtnet_device *rtdev, void *priv)
 
     err = tdma_dev_release(tdma);
     if (err < 0)
-        return err;
+       return err;
 
     rtdm_task_join_nrt(&tdma->worker_task, 100);
 
     list_for_each_entry_safe(job, tmp, &tdma->first_job->entry, entry) {
-        if (job->id >= 0)
-            tdma_cleanup_slot(tdma, SLOT_JOB(job));
-        else if (job->id == XMIT_RPL_CAL) {
-            __list_del(job->entry.prev, job->entry.next);
-            kfree_rtskb(REPLY_CAL_JOB(job)->reply_rtskb);
-        }
+       if (job->id >= 0)
+           tdma_cleanup_slot(tdma, SLOT_JOB(job));
+       else if (job->id == XMIT_RPL_CAL) {
+           __list_del(job->entry.prev, job->entry.next);
+           kfree_rtskb(REPLY_CAL_JOB(job)->reply_rtskb);
+       }
     }
 
     if (tdma->slot_table)
-        kfree(tdma->slot_table);
+       kfree(tdma->slot_table);
 
 #ifdef CONFIG_XENO_DRIVERS_NET_TDMA_MASTER
     if (test_bit(TDMA_FLAG_MASTER, &tdma->flags))
-        rtskb_pool_release(&tdma->cal_rtskb_pool);
+       rtskb_pool_release(&tdma->cal_rtskb_pool);
 #endif
 
-    RTNET_MOD_DEC_USE_COUNT;
-
     return 0;
 }
 
@@ -327,9 +323,9 @@ struct rtmac_disc tdma_disc = {
     detach:         tdma_detach,
 
     ioctls:         {
-        service_name:   "RTmac/TDMA",
-        ioctl_type:     RTNET_IOC_TYPE_RTMAC_TDMA,
-        handler:        tdma_ioctl
+       service_name:   "RTmac/TDMA",
+       ioctl_type:     RTNET_IOC_TYPE_RTMAC_TDMA,
+       handler:        tdma_ioctl
     },
 
 #ifdef CONFIG_PROC_FS
@@ -345,15 +341,15 @@ int __init tdma_init(void)
 
 
     printk("RTmac/TDMA: init time division multiple access control "
-           "mechanism\n");
+          "mechanism\n");
 
     ret = rtmac_disc_register(&tdma_disc);
     if (ret < 0)
-        return ret;
+       return ret;
 
 #ifdef CONFIG_RTOS_STARTSTOP_TIMER
     if (start_timer)
-        rtos_timer_start();
+       rtos_timer_start();
 #endif
 
     return 0;
@@ -367,7 +363,7 @@ void tdma_release(void)
 
 #ifdef CONFIG_RTOS_STARTSTOP_TIMER
     if (start_timer)
-        rtos_timer_stop();
+       rtos_timer_stop();
 #endif
 
     printk("RTmac/TDMA: unloaded\n");


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to