Browse Source

Staging: epl: run Lindent on *.c files

It's a start, still a mess...

Cc: Daniel Krueger <daniel.krueger@systec-electronic.com>
Cc: Ronald Sieber <Ronald.Sieber@systec-electronic.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Greg Kroah-Hartman 16 years ago
parent
commit
833dfbe746
41 changed files with 13900 additions and 14605 deletions
  1. 436 488
      drivers/staging/epl/Edrv8139.c
  2. 388 461
      drivers/staging/epl/EplApiGeneric.c
  3. 907 964
      drivers/staging/epl/EplApiLinuxKernel.c
  4. 127 154
      drivers/staging/epl/EplApiProcessImage.c
  5. 950 830
      drivers/staging/epl/EplDllk.c
  6. 410 400
      drivers/staging/epl/EplDllkCal.c
  7. 141 146
      drivers/staging/epl/EplDlluCal.c
  8. 478 459
      drivers/staging/epl/EplErrorHandlerk.c
  9. 420 416
      drivers/staging/epl/EplEventk.c
  10. 430 428
      drivers/staging/epl/EplEventu.c
  11. 139 148
      drivers/staging/epl/EplIdentu.c
  12. 381 368
      drivers/staging/epl/EplNmtCnu.c
  13. 479 505
      drivers/staging/epl/EplNmtMnu.c
  14. 1553 1457
      drivers/staging/epl/EplNmtk.c
  15. 0 8
      drivers/staging/epl/EplNmtkCal.c
  16. 375 348
      drivers/staging/epl/EplNmtu.c
  17. 5 11
      drivers/staging/epl/EplNmtuCal.c
  18. 380 450
      drivers/staging/epl/EplObd.c
  19. 0 7
      drivers/staging/epl/EplObdkCal.c
  20. 82 77
      drivers/staging/epl/EplObdu.c
  21. 95 99
      drivers/staging/epl/EplObduCal.c
  22. 360 358
      drivers/staging/epl/EplPdok.c
  23. 12 20
      drivers/staging/epl/EplPdokCal.c
  24. 266 309
      drivers/staging/epl/EplPdou.c
  25. 174 200
      drivers/staging/epl/EplSdoAsndu.c
  26. 404 466
      drivers/staging/epl/EplSdoAsySequ.c
  27. 408 465
      drivers/staging/epl/EplSdoComu.c
  28. 374 405
      drivers/staging/epl/EplSdoUdpu.c
  29. 84 91
      drivers/staging/epl/EplStatusu.c
  30. 138 164
      drivers/staging/epl/EplTimeruLinuxKernel.c
  31. 45 56
      drivers/staging/epl/EplTimeruNull.c
  32. 225 263
      drivers/staging/epl/EplTimeruWin32.c
  33. 869 1021
      drivers/staging/epl/SharedBuff.c
  34. 408 455
      drivers/staging/epl/ShbIpc-LinuxKernel.c
  35. 646 748
      drivers/staging/epl/ShbIpc-Win32.c
  36. 43 56
      drivers/staging/epl/SocketLinuxKernel.c
  37. 248 274
      drivers/staging/epl/TimerHighReskX86.c
  38. 129 143
      drivers/staging/epl/VirtualEthernetLinux.c
  39. 185 225
      drivers/staging/epl/amix86.c
  40. 505 450
      drivers/staging/epl/demo_main.c
  41. 201 212
      drivers/staging/epl/proc_fs.c

File diff suppressed because it is too large
+ 436 - 488
drivers/staging/epl/Edrv8139.c


File diff suppressed because it is too large
+ 388 - 461
drivers/staging/epl/EplApiGeneric.c


+ 907 - 964
drivers/staging/epl/EplApiLinuxKernel.c

@@ -70,7 +70,6 @@
 
 ****************************************************************************/
 
-
 // kernel modul and driver
 
 //#include <linux/version.h>
@@ -103,19 +102,16 @@
 //#include "kernel/EplPdokCal.h"
 #include "proc_fs.h"
 
-
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     // remove ("make invisible") obsolete symbols for kernel versions 2.6
     // and higher
-    #define MOD_INC_USE_COUNT
-    #define MOD_DEC_USE_COUNT
-    #define EXPORT_NO_SYMBOLS
+#define MOD_INC_USE_COUNT
+#define MOD_DEC_USE_COUNT
+#define EXPORT_NO_SYMBOLS
 #else
-    #error "This driver needs a 2.6.x kernel or higher"
+#error "This driver needs a 2.6.x kernel or higher"
 #endif
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -127,19 +123,15 @@
 // Metainformation
 MODULE_LICENSE("Dual BSD/GPL");
 #ifdef MODULE_AUTHOR
-    MODULE_AUTHOR("Daniel.Krueger@SYSTEC-electronic.com");
-    MODULE_DESCRIPTION("EPL API driver");
+MODULE_AUTHOR("Daniel.Krueger@SYSTEC-electronic.com");
+MODULE_DESCRIPTION("EPL API driver");
 #endif
 
-
 //---------------------------------------------------------------------------
 //  Configuration
 //---------------------------------------------------------------------------
 
-
-#define EPLLIN_DRV_NAME     "systec_epl"       // used for <register_chrdev>
-
-
+#define EPLLIN_DRV_NAME     "systec_epl"	// used for <register_chrdev>
 
 //---------------------------------------------------------------------------
 //  Constant definitions
@@ -147,23 +139,22 @@ MODULE_LICENSE("Dual BSD/GPL");
 
 // TracePoint support for realtime-debugging
 #ifdef _DBG_TRACE_POINTS_
-    void  PUBLIC  TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
-    #define TGT_DBG_SIGNAL_TRACE_POINT(p)   TgtDbgSignalTracePoint(p)
+void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
+#define TGT_DBG_SIGNAL_TRACE_POINT(p)   TgtDbgSignalTracePoint(p)
 #else
-    #define TGT_DBG_SIGNAL_TRACE_POINT(p)
+#define TGT_DBG_SIGNAL_TRACE_POINT(p)
 #endif
 
 #define EVENT_STATE_INIT        0
-#define EVENT_STATE_IOCTL       1   // ioctl entered and ready to receive EPL event
-#define EVENT_STATE_READY       2   // EPL event can be forwarded to user application
-#define EVENT_STATE_TERM        3   // terminate processing
+#define EVENT_STATE_IOCTL       1	// ioctl entered and ready to receive EPL event
+#define EVENT_STATE_READY       2	// EPL event can be forwarded to user application
+#define EVENT_STATE_TERM        3	// terminate processing
 
 #define EPL_STATE_NOTOPEN       0
 #define EPL_STATE_NOTINIT       1
 #define EPL_STATE_RUNNING       2
 #define EPL_STATE_SHUTDOWN      3
 
-
 //---------------------------------------------------------------------------
 //  Global variables
 //---------------------------------------------------------------------------
@@ -171,73 +162,65 @@ MODULE_LICENSE("Dual BSD/GPL");
 #ifdef CONFIG_DEVFS_FS
 
     // driver major number
-    static int  nDrvMajorNumber_g;
+static int nDrvMajorNumber_g;
 
 #else
 
     // device number (major and minor)
-    static dev_t        nDevNum_g;
-    static struct cdev *pEpl_cdev_g;
+static dev_t nDevNum_g;
+static struct cdev *pEpl_cdev_g;
 
 #endif
 
-
 static volatile unsigned int uiEplState_g = EPL_STATE_NOTOPEN;
 
-static struct semaphore     SemaphoreCbEvent_g; // semaphore for EplLinCbEvent
-static wait_queue_head_t    WaitQueueCbEvent_g; // wait queue EplLinCbEvent
-static wait_queue_head_t    WaitQueueProcess_g; // wait queue for EplApiProcess (user process)
-static wait_queue_head_t    WaitQueueRelease_g; // wait queue for EplLinRelease
-static atomic_t             AtomicEventState_g = ATOMIC_INIT(EVENT_STATE_INIT);
-static tEplApiEventType     EventType_g;        // event type (enum)
-static tEplApiEventArg*     pEventArg_g;        // event argument (union)
-static tEplKernel           RetCbEvent_g;       // return code from event callback function
-static wait_queue_head_t    WaitQueueCbSync_g;  // wait queue EplLinCbSync
-static wait_queue_head_t    WaitQueuePI_In_g;   // wait queue for EplApiProcessImageExchangeIn (user process)
-static atomic_t             AtomicSyncState_g = ATOMIC_INIT(EVENT_STATE_INIT);
-
+static struct semaphore SemaphoreCbEvent_g;	// semaphore for EplLinCbEvent
+static wait_queue_head_t WaitQueueCbEvent_g;	// wait queue EplLinCbEvent
+static wait_queue_head_t WaitQueueProcess_g;	// wait queue for EplApiProcess (user process)
+static wait_queue_head_t WaitQueueRelease_g;	// wait queue for EplLinRelease
+static atomic_t AtomicEventState_g = ATOMIC_INIT(EVENT_STATE_INIT);
+static tEplApiEventType EventType_g;	// event type (enum)
+static tEplApiEventArg *pEventArg_g;	// event argument (union)
+static tEplKernel RetCbEvent_g;	// return code from event callback function
+static wait_queue_head_t WaitQueueCbSync_g;	// wait queue EplLinCbSync
+static wait_queue_head_t WaitQueuePI_In_g;	// wait queue for EplApiProcessImageExchangeIn (user process)
+static atomic_t AtomicSyncState_g = ATOMIC_INIT(EVENT_STATE_INIT);
 
 //---------------------------------------------------------------------------
 //  Local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    void*       m_pUserArg;
-    void*       m_pData;
+typedef struct {
+	void *m_pUserArg;
+	void *m_pData;
 
 } tEplLinSdoBufHeader;
 
-
 //---------------------------------------------------------------------------
 //  Local variables
 //---------------------------------------------------------------------------
 
-
-
 //---------------------------------------------------------------------------
 //  Prototypes of internal functions
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplLinCbEvent(
-    tEplApiEventType        EventType_p,   // IN: event type (enum)
-    tEplApiEventArg*        pEventArg_p,   // IN: event argument (union)
-    void GENERIC*           pUserArg_p);
+tEplKernel PUBLIC EplLinCbEvent(tEplApiEventType EventType_p,	// IN: event type (enum)
+				tEplApiEventArg * pEventArg_p,	// IN: event argument (union)
+				void GENERIC * pUserArg_p);
 
 tEplKernel PUBLIC EplLinCbSync(void);
 
-static int  __init  EplLinInit (void);
-static void __exit  EplLinExit (void);
-
-
-static  int      EplLinOpen    (struct inode* pDeviceFile_p, struct file* pInstance_p);
-static  int      EplLinRelease (struct inode* pDeviceFile_p, struct file* pInstance_p);
-static  ssize_t  EplLinRead    (struct file* pInstance_p, char* pDstBuff_p, size_t BuffSize_p, loff_t* pFileOffs_p);
-static  ssize_t  EplLinWrite   (struct file* pInstance_p, const char* pSrcBuff_p, size_t BuffSize_p, loff_t* pFileOffs_p);
-static  int      EplLinIoctl   (struct inode* pDeviceFile_p, struct file* pInstance_p, unsigned int uiIoctlCmd_p, unsigned long ulArg_p);
-
-
+static int __init EplLinInit(void);
+static void __exit EplLinExit(void);
 
+static int EplLinOpen(struct inode *pDeviceFile_p, struct file *pInstance_p);
+static int EplLinRelease(struct inode *pDeviceFile_p, struct file *pInstance_p);
+static ssize_t EplLinRead(struct file *pInstance_p, char *pDstBuff_p,
+			  size_t BuffSize_p, loff_t * pFileOffs_p);
+static ssize_t EplLinWrite(struct file *pInstance_p, const char *pSrcBuff_p,
+			   size_t BuffSize_p, loff_t * pFileOffs_p);
+static int EplLinIoctl(struct inode *pDeviceFile_p, struct file *pInstance_p,
+		       unsigned int uiIoctlCmd_p, unsigned long ulArg_p);
 
 //---------------------------------------------------------------------------
 //  Kernel Module specific Data Structures
@@ -245,27 +228,19 @@ static  int      EplLinIoctl   (struct inode* pDeviceFile_p, struct file* pInsta
 
 EXPORT_NO_SYMBOLS;
 
-
-
 module_init(EplLinInit);
 module_exit(EplLinExit);
 
-
-
-
-static struct file_operations  EplLinFileOps_g =
-{
-    .owner =     THIS_MODULE,
-    .open =      EplLinOpen,
-    .release =   EplLinRelease,
-    .read =      EplLinRead,
-    .write =     EplLinWrite,
-    .ioctl =     EplLinIoctl,
+static struct file_operations EplLinFileOps_g = {
+	.owner = THIS_MODULE,
+	.open = EplLinOpen,
+	.release = EplLinRelease,
+	.read = EplLinRead,
+	.write = EplLinWrite,
+	.ioctl = EplLinIoctl,
 
 };
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -278,1040 +253,1008 @@ static struct file_operations  EplLinFileOps_g =
 //  -> insmod driver
 //---------------------------------------------------------------------------
 
-static  int  __init  EplLinInit (void)
+static int __init EplLinInit(void)
 {
 
-tEplKernel          EplRet;
-int  iErr;
-int  iRet;
+	tEplKernel EplRet;
+	int iErr;
+	int iRet;
 #ifdef CONFIG_DEVFS_FS
-int  nMinorNumber;
+	int nMinorNumber;
 #endif
 
-    TRACE0("EPL: + EplLinInit...\n");
-    TRACE2("EPL:   Driver build: %s / %s\n", __DATE__, __TIME__);
-
-    iRet = 0;
-
-    // initialize global variables
-    atomic_set(&AtomicEventState_g, EVENT_STATE_INIT);
-    sema_init(&SemaphoreCbEvent_g, 1);
-    init_waitqueue_head(&WaitQueueCbEvent_g);
-    init_waitqueue_head(&WaitQueueProcess_g);
-    init_waitqueue_head(&WaitQueueRelease_g);
+	TRACE0("EPL: + EplLinInit...\n");
+	TRACE2("EPL:   Driver build: %s / %s\n", __DATE__, __TIME__);
 
+	iRet = 0;
 
+	// initialize global variables
+	atomic_set(&AtomicEventState_g, EVENT_STATE_INIT);
+	sema_init(&SemaphoreCbEvent_g, 1);
+	init_waitqueue_head(&WaitQueueCbEvent_g);
+	init_waitqueue_head(&WaitQueueProcess_g);
+	init_waitqueue_head(&WaitQueueRelease_g);
 
 #ifdef CONFIG_DEVFS_FS
 
-    // register character device handler
-    TRACE2("EPL:   Installing Driver '%s', Version %s...\n", EPLLIN_DRV_NAME, EPL_PRODUCT_VERSION);
-    TRACE0("EPL:   (using dynamic major number assignment)\n");
-    nDrvMajorNumber_g = register_chrdev (0, EPLLIN_DRV_NAME, &EplLinFileOps_g);
-    if (nDrvMajorNumber_g != 0)
-    {
-        TRACE2("EPL:   Driver '%s' installed successful, assigned MajorNumber=%d\n", EPLLIN_DRV_NAME, nDrvMajorNumber_g);
-    }
-    else
-    {
-        TRACE1("EPL:   ERROR: Driver '%s' is unable to get a free MajorNumber!\n", EPLLIN_DRV_NAME);
-        iRet = -EIO;
-        goto Exit;
-    }
-
-
-    // create device node in DEVFS
-    nMinorNumber = 0;
-    TRACE1("EPL:   Creating device node '/dev/%s'...\n", EPLLIN_DEV_NAME);
-    iErr = devfs_mk_cdev (MKDEV(nDrvMajorNumber_g, nMinorNumber), S_IFCHR | S_IRUGO | S_IWUGO, EPLLIN_DEV_NAME);
-    if (iErr == 0)
-    {
-        TRACE1("EPL:   Device node '/dev/%s' created successful.\n", EPLLIN_DEV_NAME);
-    }
-    else
-    {
-        TRACE1("EPL:   ERROR: unable to create device node '/dev/%s'\n", EPLLIN_DEV_NAME);
-        iRet = -EIO;
-        goto Exit;
-    }
+	// register character device handler
+	TRACE2("EPL:   Installing Driver '%s', Version %s...\n",
+	       EPLLIN_DRV_NAME, EPL_PRODUCT_VERSION);
+	TRACE0("EPL:   (using dynamic major number assignment)\n");
+	nDrvMajorNumber_g =
+	    register_chrdev(0, EPLLIN_DRV_NAME, &EplLinFileOps_g);
+	if (nDrvMajorNumber_g != 0) {
+		TRACE2
+		    ("EPL:   Driver '%s' installed successful, assigned MajorNumber=%d\n",
+		     EPLLIN_DRV_NAME, nDrvMajorNumber_g);
+	} else {
+		TRACE1
+		    ("EPL:   ERROR: Driver '%s' is unable to get a free MajorNumber!\n",
+		     EPLLIN_DRV_NAME);
+		iRet = -EIO;
+		goto Exit;
+	}
+
+	// create device node in DEVFS
+	nMinorNumber = 0;
+	TRACE1("EPL:   Creating device node '/dev/%s'...\n", EPLLIN_DEV_NAME);
+	iErr =
+	    devfs_mk_cdev(MKDEV(nDrvMajorNumber_g, nMinorNumber),
+			  S_IFCHR | S_IRUGO | S_IWUGO, EPLLIN_DEV_NAME);
+	if (iErr == 0) {
+		TRACE1("EPL:   Device node '/dev/%s' created successful.\n",
+		       EPLLIN_DEV_NAME);
+	} else {
+		TRACE1("EPL:   ERROR: unable to create device node '/dev/%s'\n",
+		       EPLLIN_DEV_NAME);
+		iRet = -EIO;
+		goto Exit;
+	}
 
 #else
 
-    // register character device handler
-    // only one Minor required
-    TRACE2("EPL:   Installing Driver '%s', Version %s...\n", EPLLIN_DRV_NAME, EPL_PRODUCT_VERSION);
-    iRet = alloc_chrdev_region (&nDevNum_g, 0, 1, EPLLIN_DRV_NAME);
-    if (iRet == 0)
-    {
-        TRACE2("EPL:   Driver '%s' installed successful, assigned MajorNumber=%d\n", EPLLIN_DRV_NAME, MAJOR(nDevNum_g));
-    }
-    else
-    {
-        TRACE1("EPL:   ERROR: Driver '%s' is unable to get a free MajorNumber!\n", EPLLIN_DRV_NAME);
-        iRet = -EIO;
-        goto Exit;
-    }
-
-    // register cdev structure
-    pEpl_cdev_g = cdev_alloc();
-    pEpl_cdev_g->ops = &EplLinFileOps_g;
-    pEpl_cdev_g->owner = THIS_MODULE;
-    iErr = cdev_add (pEpl_cdev_g, nDevNum_g, 1);
-    if (iErr)
-    {
-        TRACE2("EPL:   ERROR %d: Driver '%s' could not be added!\n", iErr, EPLLIN_DRV_NAME);
-        iRet = -EIO;
-        goto Exit;
-    }
-
+	// register character device handler
+	// only one Minor required
+	TRACE2("EPL:   Installing Driver '%s', Version %s...\n",
+	       EPLLIN_DRV_NAME, EPL_PRODUCT_VERSION);
+	iRet = alloc_chrdev_region(&nDevNum_g, 0, 1, EPLLIN_DRV_NAME);
+	if (iRet == 0) {
+		TRACE2
+		    ("EPL:   Driver '%s' installed successful, assigned MajorNumber=%d\n",
+		     EPLLIN_DRV_NAME, MAJOR(nDevNum_g));
+	} else {
+		TRACE1
+		    ("EPL:   ERROR: Driver '%s' is unable to get a free MajorNumber!\n",
+		     EPLLIN_DRV_NAME);
+		iRet = -EIO;
+		goto Exit;
+	}
+
+	// register cdev structure
+	pEpl_cdev_g = cdev_alloc();
+	pEpl_cdev_g->ops = &EplLinFileOps_g;
+	pEpl_cdev_g->owner = THIS_MODULE;
+	iErr = cdev_add(pEpl_cdev_g, nDevNum_g, 1);
+	if (iErr) {
+		TRACE2("EPL:   ERROR %d: Driver '%s' could not be added!\n",
+		       iErr, EPLLIN_DRV_NAME);
+		iRet = -EIO;
+		goto Exit;
+	}
 #endif
 
-    // create device node in PROCFS
-    EplRet = EplLinProcInit();
-    if (EplRet != kEplSuccessful)
-    {
-        goto Exit;
-    }
+	// create device node in PROCFS
+	EplRet = EplLinProcInit();
+	if (EplRet != kEplSuccessful) {
+		goto Exit;
+	}
 
+      Exit:
 
-Exit:
-
-    TRACE1("EPL: - EplLinInit (iRet=%d)\n", iRet);
-    return (iRet);
+	TRACE1("EPL: - EplLinInit (iRet=%d)\n", iRet);
+	return (iRet);
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Remove Driver
 //---------------------------------------------------------------------------
 //  -> rmmod driver
 //---------------------------------------------------------------------------
 
-static void  __exit  EplLinExit (void)
+static void __exit EplLinExit(void)
 {
 
-tEplKernel          EplRet;
+	tEplKernel EplRet;
 
-    // delete instance for all modules
+	// delete instance for all modules
 //    EplRet = EplApiShutdown();
 //    printk("EplApiShutdown():  0x%X\n", EplRet);
 
-    // deinitialize proc fs
-    EplRet = EplLinProcFree();
-    printk("EplLinProcFree():        0x%X\n", EplRet);
-
-
-    TRACE0("EPL: + EplLinExit...\n");
+	// deinitialize proc fs
+	EplRet = EplLinProcFree();
+	printk("EplLinProcFree():        0x%X\n", EplRet);
 
+	TRACE0("EPL: + EplLinExit...\n");
 
 #ifdef CONFIG_DEVFS_FS
 
-    // remove device node from DEVFS
-    devfs_remove (EPLLIN_DEV_NAME);
-    TRACE1("EPL:   Device node '/dev/%s' removed.\n", EPLLIN_DEV_NAME);
+	// remove device node from DEVFS
+	devfs_remove(EPLLIN_DEV_NAME);
+	TRACE1("EPL:   Device node '/dev/%s' removed.\n", EPLLIN_DEV_NAME);
 
-    // unregister character device handler
-    unregister_chrdev (nDrvMajorNumber_g, EPLLIN_DRV_NAME);
+	// unregister character device handler
+	unregister_chrdev(nDrvMajorNumber_g, EPLLIN_DRV_NAME);
 
 #else
 
-    // remove cdev structure
-    cdev_del(pEpl_cdev_g);
+	// remove cdev structure
+	cdev_del(pEpl_cdev_g);
 
-    // unregister character device handler
-    unregister_chrdev_region (nDevNum_g, 1);
+	// unregister character device handler
+	unregister_chrdev_region(nDevNum_g, 1);
 
 #endif
 
-    TRACE1("EPL:   Driver '%s' removed.\n", EPLLIN_DRV_NAME);
+	TRACE1("EPL:   Driver '%s' removed.\n", EPLLIN_DRV_NAME);
 
-
-    TRACE0("EPL: - EplLinExit\n");
+	TRACE0("EPL: - EplLinExit\n");
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Open Driver
 //---------------------------------------------------------------------------
 //  -> open("/dev/driver", O_RDWR)...
 //---------------------------------------------------------------------------
 
-static int  EplLinOpen (
-    struct inode* pDeviceFile_p,    // information about the device to open
-    struct file* pInstance_p)       // information about driver instance
+static int EplLinOpen(struct inode *pDeviceFile_p,	// information about the device to open
+		      struct file *pInstance_p)	// information about driver instance
 {
 
-int  iRet;
+	int iRet;
 
+	TRACE0("EPL: + EplLinOpen...\n");
 
-    TRACE0("EPL: + EplLinOpen...\n");
+	MOD_INC_USE_COUNT;
 
-    MOD_INC_USE_COUNT;
+	if (uiEplState_g != EPL_STATE_NOTOPEN) {	// stack already initialized
+		iRet = -EALREADY;
+	} else {
+		atomic_set(&AtomicEventState_g, EVENT_STATE_INIT);
+		sema_init(&SemaphoreCbEvent_g, 1);
+		init_waitqueue_head(&WaitQueueCbEvent_g);
+		init_waitqueue_head(&WaitQueueProcess_g);
+		init_waitqueue_head(&WaitQueueRelease_g);
+		atomic_set(&AtomicSyncState_g, EVENT_STATE_INIT);
+		init_waitqueue_head(&WaitQueueCbSync_g);
+		init_waitqueue_head(&WaitQueuePI_In_g);
 
-    if (uiEplState_g != EPL_STATE_NOTOPEN)
-    {   // stack already initialized
-        iRet = -EALREADY;
-    }
-    else
-    {
-        atomic_set(&AtomicEventState_g, EVENT_STATE_INIT);
-        sema_init(&SemaphoreCbEvent_g, 1);
-        init_waitqueue_head(&WaitQueueCbEvent_g);
-        init_waitqueue_head(&WaitQueueProcess_g);
-        init_waitqueue_head(&WaitQueueRelease_g);
-        atomic_set(&AtomicSyncState_g, EVENT_STATE_INIT);
-        init_waitqueue_head(&WaitQueueCbSync_g);
-        init_waitqueue_head(&WaitQueuePI_In_g);
+		uiEplState_g = EPL_STATE_NOTINIT;
+		iRet = 0;
+	}
 
-        uiEplState_g = EPL_STATE_NOTINIT;
-        iRet = 0;
-    }
-
-    TRACE1("EPL: - EplLinOpen (iRet=%d)\n", iRet);
-    return (iRet);
+	TRACE1("EPL: - EplLinOpen (iRet=%d)\n", iRet);
+	return (iRet);
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Close Driver
 //---------------------------------------------------------------------------
 //  -> close(device)...
 //---------------------------------------------------------------------------
 
-static int  EplLinRelease (
-    struct inode* pDeviceFile_p,    // information about the device to open
-    struct file* pInstance_p)       // information about driver instance
+static int EplLinRelease(struct inode *pDeviceFile_p,	// information about the device to open
+			 struct file *pInstance_p)	// information about driver instance
 {
 
-tEplKernel          EplRet = kEplSuccessful;
-int  iRet;
-
-
-    TRACE0("EPL: + EplLinRelease...\n");
+	tEplKernel EplRet = kEplSuccessful;
+	int iRet;
 
-    if (uiEplState_g != EPL_STATE_NOTINIT)
-    {
-        // pass control to sync kernel thread, but signal termination
-        atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
-        wake_up_interruptible(&WaitQueueCbSync_g);
-        wake_up_interruptible(&WaitQueuePI_In_g);
+	TRACE0("EPL: + EplLinRelease...\n");
 
-        // pass control to event queue kernel thread
-        atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
-        wake_up_interruptible(&WaitQueueCbEvent_g);
+	if (uiEplState_g != EPL_STATE_NOTINIT) {
+		// pass control to sync kernel thread, but signal termination
+		atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
+		wake_up_interruptible(&WaitQueueCbSync_g);
+		wake_up_interruptible(&WaitQueuePI_In_g);
 
-        if (uiEplState_g == EPL_STATE_RUNNING)
-        {   // post NmtEventSwitchOff
-            EplRet = EplApiExecNmtCommand(kEplNmtEventSwitchOff);
+		// pass control to event queue kernel thread
+		atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
+		wake_up_interruptible(&WaitQueueCbEvent_g);
 
-        }
+		if (uiEplState_g == EPL_STATE_RUNNING) {	// post NmtEventSwitchOff
+			EplRet = EplApiExecNmtCommand(kEplNmtEventSwitchOff);
 
-        if (EplRet == kEplSuccessful)
-        {
-            TRACE0("EPL:   waiting for NMT_GS_OFF\n");
-            wait_event_interruptible(WaitQueueRelease_g,
-                                        (uiEplState_g == EPL_STATE_SHUTDOWN));
-        }
-        else
-        {   // post NmtEventSwitchOff failed
-            TRACE0("EPL:   event post failed\n");
-        }
+		}
 
-        // $$$ d.k.: What if waiting was interrupted by signal?
+		if (EplRet == kEplSuccessful) {
+			TRACE0("EPL:   waiting for NMT_GS_OFF\n");
+			wait_event_interruptible(WaitQueueRelease_g,
+						 (uiEplState_g ==
+						  EPL_STATE_SHUTDOWN));
+		} else {	// post NmtEventSwitchOff failed
+			TRACE0("EPL:   event post failed\n");
+		}
 
-        TRACE0("EPL:   call EplApiShutdown()\n");
-        // EPL stack can be safely shut down
-        // delete instance for all EPL modules
-        EplRet = EplApiShutdown();
-        printk("EplApiShutdown():  0x%X\n", EplRet);
-    }
+		// $$$ d.k.: What if waiting was interrupted by signal?
 
-    uiEplState_g = EPL_STATE_NOTOPEN;
-    iRet = 0;
+		TRACE0("EPL:   call EplApiShutdown()\n");
+		// EPL stack can be safely shut down
+		// delete instance for all EPL modules
+		EplRet = EplApiShutdown();
+		printk("EplApiShutdown():  0x%X\n", EplRet);
+	}
 
+	uiEplState_g = EPL_STATE_NOTOPEN;
+	iRet = 0;
 
-    MOD_DEC_USE_COUNT;
+	MOD_DEC_USE_COUNT;
 
-
-    TRACE1("EPL: - EplLinRelease (iRet=%d)\n", iRet);
-    return (iRet);
+	TRACE1("EPL: - EplLinRelease (iRet=%d)\n", iRet);
+	return (iRet);
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Read Data from Driver
 //---------------------------------------------------------------------------
 //  -> read(...)
 //---------------------------------------------------------------------------
 
-static ssize_t  EplLinRead (
-    struct file* pInstance_p,       // information about driver instance
-    char* pDstBuff_p,               // address of buffer to fill with data
-    size_t BuffSize_p,              // length of the buffer
-    loff_t* pFileOffs_p)            // offset in the file
+static ssize_t EplLinRead(struct file *pInstance_p,	// information about driver instance
+			  char *pDstBuff_p,	// address of buffer to fill with data
+			  size_t BuffSize_p,	// length of the buffer
+			  loff_t * pFileOffs_p)	// offset in the file
 {
 
-int  iRet;
-
-
-    TRACE0("EPL: + EplLinRead...\n");
+	int iRet;
 
+	TRACE0("EPL: + EplLinRead...\n");
 
-    TRACE0("EPL:   Sorry, this operation isn't supported.\n");
-    iRet = -EINVAL;
+	TRACE0("EPL:   Sorry, this operation isn't supported.\n");
+	iRet = -EINVAL;
 
-
-    TRACE1("EPL: - EplLinRead (iRet=%d)\n", iRet);
-    return (iRet);
+	TRACE1("EPL: - EplLinRead (iRet=%d)\n", iRet);
+	return (iRet);
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Write Data to Driver
 //---------------------------------------------------------------------------
 //  -> write(...)
 //---------------------------------------------------------------------------
 
-static ssize_t  EplLinWrite (
-    struct file* pInstance_p,       // information about driver instance
-    const char* pSrcBuff_p,         // address of buffer to get data from
-    size_t BuffSize_p,              // length of the buffer
-    loff_t* pFileOffs_p)            // offset in the file
+static ssize_t EplLinWrite(struct file *pInstance_p,	// information about driver instance
+			   const char *pSrcBuff_p,	// address of buffer to get data from
+			   size_t BuffSize_p,	// length of the buffer
+			   loff_t * pFileOffs_p)	// offset in the file
 {
 
-int  iRet;
-
-
-    TRACE0("EPL: + EplLinWrite...\n");
+	int iRet;
 
+	TRACE0("EPL: + EplLinWrite...\n");
 
-    TRACE0("EPL:   Sorry, this operation isn't supported.\n");
-    iRet = -EINVAL;
+	TRACE0("EPL:   Sorry, this operation isn't supported.\n");
+	iRet = -EINVAL;
 
-
-    TRACE1("EPL: - EplLinWrite (iRet=%d)\n", iRet);
-    return (iRet);
+	TRACE1("EPL: - EplLinWrite (iRet=%d)\n", iRet);
+	return (iRet);
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //  Generic Access to Driver
 //---------------------------------------------------------------------------
 //  -> ioctl(...)
 //---------------------------------------------------------------------------
 
-static int  EplLinIoctl (
-    struct inode* pDeviceFile_p,    // information about the device to open
-    struct file* pInstance_p,       // information about driver instance
-    unsigned int uiIoctlCmd_p,      // Ioctl command to execute
-    unsigned long ulArg_p)          // Ioctl command specific argument/parameter
+static int EplLinIoctl(struct inode *pDeviceFile_p,	// information about the device to open
+		       struct file *pInstance_p,	// information about driver instance
+		       unsigned int uiIoctlCmd_p,	// Ioctl command to execute
+		       unsigned long ulArg_p)	// Ioctl command specific argument/parameter
 {
 
-tEplKernel          EplRet;
-int  iErr;
-int  iRet;
-
+	tEplKernel EplRet;
+	int iErr;
+	int iRet;
 
 //    TRACE1("EPL: + EplLinIoctl (uiIoctlCmd_p=%d)...\n", uiIoctlCmd_p);
 
-
-    iRet = -EINVAL;
-
-    switch (uiIoctlCmd_p)
-    {
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_INITIALIZE:
-        {
-        tEplApiInitParam EplApiInitParam;
-
-            iErr = copy_from_user(&EplApiInitParam, (const void*)ulArg_p, sizeof (EplApiInitParam));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            EplApiInitParam.m_pfnCbEvent = EplLinCbEvent;
-            EplApiInitParam.m_pfnCbSync = EplLinCbSync;
-
-            EplRet = EplApiInitialize(&EplApiInitParam);
-
-            uiEplState_g = EPL_STATE_RUNNING;
-
-            iRet = (int) EplRet;
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_SHUTDOWN:
-        {   // shutdown the threads
-
-            // pass control to sync kernel thread, but signal termination
-            atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
-            wake_up_interruptible(&WaitQueueCbSync_g);
-            wake_up_interruptible(&WaitQueuePI_In_g);
-
-            // pass control to event queue kernel thread
-            atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
-            wake_up_interruptible(&WaitQueueCbEvent_g);
-
-            if (uiEplState_g == EPL_STATE_RUNNING)
-            {   // post NmtEventSwitchOff
-                EplRet = EplApiExecNmtCommand(kEplNmtEventSwitchOff);
-
-            }
-
-            iRet = 0;
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_READ_LOCAL_OBJECT:
-        {
-        tEplLinLocalObject  LocalObject;
-        void*               pData;
-
-            iErr = copy_from_user(&LocalObject, (const void*)ulArg_p, sizeof (LocalObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if ((LocalObject.m_pData == NULL) || (LocalObject.m_uiSize == 0))
-            {
-                iRet = (int) kEplApiInvalidParam;
-                goto Exit;
-            }
-
-            pData = vmalloc(LocalObject.m_uiSize);
-            if (pData == NULL)
-            {   // no memory available
-                iRet = -ENOMEM;
-                goto Exit;
-            }
-
-            EplRet = EplApiReadLocalObject(LocalObject.m_uiIndex, LocalObject.m_uiSubindex, pData, &LocalObject.m_uiSize);
-
-            if (EplRet == kEplSuccessful)
-            {
-                iErr = copy_to_user(LocalObject.m_pData, pData, LocalObject.m_uiSize);
-
-                vfree(pData);
-
-                if (iErr != 0)
-                {
-                    iRet = -EIO;
-                    goto Exit;
-                }
-
-                // return actual size (LocalObject.m_uiSize)
-                iErr = put_user(LocalObject.m_uiSize,
-                                (unsigned int*)(ulArg_p + (unsigned long)&LocalObject.m_uiSize - (unsigned long)&LocalObject));
-                if (iErr != 0)
-                {
-                    iRet = -EIO;
-                    goto Exit;
-                }
-
-            }
-            else
-            {
-                vfree(pData);
-            }
-
-            iRet = (int) EplRet;
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_WRITE_LOCAL_OBJECT:
-        {
-        tEplLinLocalObject  LocalObject;
-        void*               pData;
-
-            iErr = copy_from_user(&LocalObject, (const void*)ulArg_p, sizeof (LocalObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if ((LocalObject.m_pData == NULL) || (LocalObject.m_uiSize == 0))
-            {
-                iRet = (int) kEplApiInvalidParam;
-                goto Exit;
-            }
-
-            pData = vmalloc(LocalObject.m_uiSize);
-            if (pData == NULL)
-            {   // no memory available
-                iRet = -ENOMEM;
-                goto Exit;
-            }
-            iErr = copy_from_user(pData, LocalObject.m_pData, LocalObject.m_uiSize);
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            EplRet = EplApiWriteLocalObject(LocalObject.m_uiIndex, LocalObject.m_uiSubindex, pData, LocalObject.m_uiSize);
-
-            vfree(pData);
-
-            iRet = (int) EplRet;
-            break;
-        }
-
-
-        case EPLLIN_CMD_READ_OBJECT:
-        {
-        tEplLinSdoObject        SdoObject;
-        void*                   pData;
-        tEplLinSdoBufHeader*    pBufHeader;
-        tEplSdoComConHdl*       pSdoComConHdl;
-
-            iErr = copy_from_user(&SdoObject, (const void*)ulArg_p, sizeof (SdoObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if ((SdoObject.m_le_pData == NULL) || (SdoObject.m_uiSize == 0))
-            {
-                iRet = (int) kEplApiInvalidParam;
-                goto Exit;
-            }
-
-            pBufHeader = (tEplLinSdoBufHeader*) vmalloc(sizeof (tEplLinSdoBufHeader) + SdoObject.m_uiSize);
-            if (pBufHeader == NULL)
-            {   // no memory available
-                iRet = -ENOMEM;
-                goto Exit;
-            }
-
-            // initiate temporary buffer
-            pBufHeader->m_pUserArg = SdoObject.m_pUserArg;  // original user argument pointer
-            pBufHeader->m_pData = SdoObject.m_le_pData;     // original data pointer from app
-            pData = pBufHeader + sizeof (tEplLinSdoBufHeader);
-
-            if (SdoObject.m_fValidSdoComConHdl != FALSE)
-            {
-                pSdoComConHdl = &SdoObject.m_SdoComConHdl;
-            }
-            else
-            {
-                pSdoComConHdl = NULL;
-            }
-
-            EplRet = EplApiReadObject(pSdoComConHdl, SdoObject.m_uiNodeId, SdoObject.m_uiIndex,
-                                      SdoObject.m_uiSubindex, pData, &SdoObject.m_uiSize,
-                                      SdoObject.m_SdoType, pBufHeader);
-
-            // return actual SDO handle (SdoObject.m_SdoComConHdl)
-            iErr = put_user(SdoObject.m_SdoComConHdl,
-                            (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_SdoComConHdl - (unsigned long)&SdoObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if (EplRet == kEplSuccessful)
-            {
-                iErr = copy_to_user(SdoObject.m_le_pData, pData, SdoObject.m_uiSize);
-
-                vfree(pBufHeader);
-
-                if (iErr != 0)
-                {
-                    iRet = -EIO;
-                    goto Exit;
-                }
-
-                // return actual size (SdoObject.m_uiSize)
-                iErr = put_user(SdoObject.m_uiSize,
-                                (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_uiSize - (unsigned long)&SdoObject));
-                if (iErr != 0)
-                {
-                    iRet = -EIO;
-                    goto Exit;
-                }
-            }
-            else if (EplRet != kEplApiTaskDeferred)
-            {   // error ocurred
-                vfree(pBufHeader);
-                if (iErr != 0)
-                {
-                    iRet = -EIO;
-                    goto Exit;
-                }
-            }
-
-            iRet = (int) EplRet;
-            break;
-        }
-
-
-        case EPLLIN_CMD_WRITE_OBJECT:
-        {
-        tEplLinSdoObject        SdoObject;
-        void*                   pData;
-        tEplLinSdoBufHeader*    pBufHeader;
-        tEplSdoComConHdl*       pSdoComConHdl;
-
-            iErr = copy_from_user(&SdoObject, (const void*)ulArg_p, sizeof (SdoObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if ((SdoObject.m_le_pData == NULL) || (SdoObject.m_uiSize == 0))
-            {
-                iRet = (int) kEplApiInvalidParam;
-                goto Exit;
-            }
-
-            pBufHeader = (tEplLinSdoBufHeader*) vmalloc(sizeof (tEplLinSdoBufHeader) + SdoObject.m_uiSize);
-            if (pBufHeader == NULL)
-            {   // no memory available
-                iRet = -ENOMEM;
-                goto Exit;
-            }
-
-            // initiate temporary buffer
-            pBufHeader->m_pUserArg = SdoObject.m_pUserArg;  // original user argument pointer
-            pBufHeader->m_pData = SdoObject.m_le_pData;     // original data pointer from app
-            pData = pBufHeader + sizeof (tEplLinSdoBufHeader);
-
-            iErr = copy_from_user(pData, SdoObject.m_le_pData, SdoObject.m_uiSize);
-
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if (SdoObject.m_fValidSdoComConHdl != FALSE)
-            {
-                pSdoComConHdl = &SdoObject.m_SdoComConHdl;
-            }
-            else
-            {
-                pSdoComConHdl = NULL;
-            }
-
-            EplRet = EplApiWriteObject(pSdoComConHdl, SdoObject.m_uiNodeId, SdoObject.m_uiIndex,
-                                      SdoObject.m_uiSubindex, pData, SdoObject.m_uiSize,
-                                      SdoObject.m_SdoType, pBufHeader);
-
-            // return actual SDO handle (SdoObject.m_SdoComConHdl)
-            iErr = put_user(SdoObject.m_SdoComConHdl,
-                            (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_SdoComConHdl - (unsigned long)&SdoObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if (EplRet != kEplApiTaskDeferred)
-            {   // succeeded or error ocurred, but task not deferred
-                vfree(pBufHeader);
-            }
-
-            iRet = (int) EplRet;
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_FREE_SDO_CHANNEL:
-        {
-            // forward SDO handle to EPL stack
-            EplRet = EplApiFreeSdoChannel((tEplSdoComConHdl)ulArg_p);
-
-            iRet = (int) EplRet;
-            break;
-        }
-
+	iRet = -EINVAL;
+
+	switch (uiIoctlCmd_p) {
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_INITIALIZE:
+		{
+			tEplApiInitParam EplApiInitParam;
+
+			iErr =
+			    copy_from_user(&EplApiInitParam,
+					   (const void *)ulArg_p,
+					   sizeof(EplApiInitParam));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			EplApiInitParam.m_pfnCbEvent = EplLinCbEvent;
+			EplApiInitParam.m_pfnCbSync = EplLinCbSync;
+
+			EplRet = EplApiInitialize(&EplApiInitParam);
+
+			uiEplState_g = EPL_STATE_RUNNING;
+
+			iRet = (int)EplRet;
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_SHUTDOWN:
+		{		// shutdown the threads
+
+			// pass control to sync kernel thread, but signal termination
+			atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
+			wake_up_interruptible(&WaitQueueCbSync_g);
+			wake_up_interruptible(&WaitQueuePI_In_g);
+
+			// pass control to event queue kernel thread
+			atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
+			wake_up_interruptible(&WaitQueueCbEvent_g);
+
+			if (uiEplState_g == EPL_STATE_RUNNING) {	// post NmtEventSwitchOff
+				EplRet =
+				    EplApiExecNmtCommand(kEplNmtEventSwitchOff);
+
+			}
+
+			iRet = 0;
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_READ_LOCAL_OBJECT:
+		{
+			tEplLinLocalObject LocalObject;
+			void *pData;
+
+			iErr =
+			    copy_from_user(&LocalObject, (const void *)ulArg_p,
+					   sizeof(LocalObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if ((LocalObject.m_pData == NULL)
+			    || (LocalObject.m_uiSize == 0)) {
+				iRet = (int)kEplApiInvalidParam;
+				goto Exit;
+			}
+
+			pData = vmalloc(LocalObject.m_uiSize);
+			if (pData == NULL) {	// no memory available
+				iRet = -ENOMEM;
+				goto Exit;
+			}
+
+			EplRet =
+			    EplApiReadLocalObject(LocalObject.m_uiIndex,
+						  LocalObject.m_uiSubindex,
+						  pData, &LocalObject.m_uiSize);
+
+			if (EplRet == kEplSuccessful) {
+				iErr =
+				    copy_to_user(LocalObject.m_pData, pData,
+						 LocalObject.m_uiSize);
+
+				vfree(pData);
+
+				if (iErr != 0) {
+					iRet = -EIO;
+					goto Exit;
+				}
+				// return actual size (LocalObject.m_uiSize)
+				iErr = put_user(LocalObject.m_uiSize,
+						(unsigned int *)(ulArg_p +
+								 (unsigned long)
+								 &LocalObject.
+								 m_uiSize -
+								 (unsigned long)
+								 &LocalObject));
+				if (iErr != 0) {
+					iRet = -EIO;
+					goto Exit;
+				}
+
+			} else {
+				vfree(pData);
+			}
+
+			iRet = (int)EplRet;
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_WRITE_LOCAL_OBJECT:
+		{
+			tEplLinLocalObject LocalObject;
+			void *pData;
+
+			iErr =
+			    copy_from_user(&LocalObject, (const void *)ulArg_p,
+					   sizeof(LocalObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if ((LocalObject.m_pData == NULL)
+			    || (LocalObject.m_uiSize == 0)) {
+				iRet = (int)kEplApiInvalidParam;
+				goto Exit;
+			}
+
+			pData = vmalloc(LocalObject.m_uiSize);
+			if (pData == NULL) {	// no memory available
+				iRet = -ENOMEM;
+				goto Exit;
+			}
+			iErr =
+			    copy_from_user(pData, LocalObject.m_pData,
+					   LocalObject.m_uiSize);
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			EplRet =
+			    EplApiWriteLocalObject(LocalObject.m_uiIndex,
+						   LocalObject.m_uiSubindex,
+						   pData, LocalObject.m_uiSize);
+
+			vfree(pData);
+
+			iRet = (int)EplRet;
+			break;
+		}
+
+	case EPLLIN_CMD_READ_OBJECT:
+		{
+			tEplLinSdoObject SdoObject;
+			void *pData;
+			tEplLinSdoBufHeader *pBufHeader;
+			tEplSdoComConHdl *pSdoComConHdl;
+
+			iErr =
+			    copy_from_user(&SdoObject, (const void *)ulArg_p,
+					   sizeof(SdoObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if ((SdoObject.m_le_pData == NULL)
+			    || (SdoObject.m_uiSize == 0)) {
+				iRet = (int)kEplApiInvalidParam;
+				goto Exit;
+			}
+
+			pBufHeader =
+			    (tEplLinSdoBufHeader *)
+			    vmalloc(sizeof(tEplLinSdoBufHeader) +
+				    SdoObject.m_uiSize);
+			if (pBufHeader == NULL) {	// no memory available
+				iRet = -ENOMEM;
+				goto Exit;
+			}
+			// initiate temporary buffer
+			pBufHeader->m_pUserArg = SdoObject.m_pUserArg;	// original user argument pointer
+			pBufHeader->m_pData = SdoObject.m_le_pData;	// original data pointer from app
+			pData = pBufHeader + sizeof(tEplLinSdoBufHeader);
+
+			if (SdoObject.m_fValidSdoComConHdl != FALSE) {
+				pSdoComConHdl = &SdoObject.m_SdoComConHdl;
+			} else {
+				pSdoComConHdl = NULL;
+			}
+
+			EplRet =
+			    EplApiReadObject(pSdoComConHdl,
+					     SdoObject.m_uiNodeId,
+					     SdoObject.m_uiIndex,
+					     SdoObject.m_uiSubindex, pData,
+					     &SdoObject.m_uiSize,
+					     SdoObject.m_SdoType, pBufHeader);
+
+			// return actual SDO handle (SdoObject.m_SdoComConHdl)
+			iErr = put_user(SdoObject.m_SdoComConHdl,
+					(unsigned int *)(ulArg_p +
+							 (unsigned long)
+							 &SdoObject.
+							 m_SdoComConHdl -
+							 (unsigned long)
+							 &SdoObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if (EplRet == kEplSuccessful) {
+				iErr =
+				    copy_to_user(SdoObject.m_le_pData, pData,
+						 SdoObject.m_uiSize);
+
+				vfree(pBufHeader);
+
+				if (iErr != 0) {
+					iRet = -EIO;
+					goto Exit;
+				}
+				// return actual size (SdoObject.m_uiSize)
+				iErr = put_user(SdoObject.m_uiSize,
+						(unsigned int *)(ulArg_p +
+								 (unsigned long)
+								 &SdoObject.
+								 m_uiSize -
+								 (unsigned long)
+								 &SdoObject));
+				if (iErr != 0) {
+					iRet = -EIO;
+					goto Exit;
+				}
+			} else if (EplRet != kEplApiTaskDeferred) {	// error ocurred
+				vfree(pBufHeader);
+				if (iErr != 0) {
+					iRet = -EIO;
+					goto Exit;
+				}
+			}
+
+			iRet = (int)EplRet;
+			break;
+		}
+
+	case EPLLIN_CMD_WRITE_OBJECT:
+		{
+			tEplLinSdoObject SdoObject;
+			void *pData;
+			tEplLinSdoBufHeader *pBufHeader;
+			tEplSdoComConHdl *pSdoComConHdl;
+
+			iErr =
+			    copy_from_user(&SdoObject, (const void *)ulArg_p,
+					   sizeof(SdoObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if ((SdoObject.m_le_pData == NULL)
+			    || (SdoObject.m_uiSize == 0)) {
+				iRet = (int)kEplApiInvalidParam;
+				goto Exit;
+			}
+
+			pBufHeader =
+			    (tEplLinSdoBufHeader *)
+			    vmalloc(sizeof(tEplLinSdoBufHeader) +
+				    SdoObject.m_uiSize);
+			if (pBufHeader == NULL) {	// no memory available
+				iRet = -ENOMEM;
+				goto Exit;
+			}
+			// initiate temporary buffer
+			pBufHeader->m_pUserArg = SdoObject.m_pUserArg;	// original user argument pointer
+			pBufHeader->m_pData = SdoObject.m_le_pData;	// original data pointer from app
+			pData = pBufHeader + sizeof(tEplLinSdoBufHeader);
+
+			iErr =
+			    copy_from_user(pData, SdoObject.m_le_pData,
+					   SdoObject.m_uiSize);
+
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if (SdoObject.m_fValidSdoComConHdl != FALSE) {
+				pSdoComConHdl = &SdoObject.m_SdoComConHdl;
+			} else {
+				pSdoComConHdl = NULL;
+			}
+
+			EplRet =
+			    EplApiWriteObject(pSdoComConHdl,
+					      SdoObject.m_uiNodeId,
+					      SdoObject.m_uiIndex,
+					      SdoObject.m_uiSubindex, pData,
+					      SdoObject.m_uiSize,
+					      SdoObject.m_SdoType, pBufHeader);
+
+			// return actual SDO handle (SdoObject.m_SdoComConHdl)
+			iErr = put_user(SdoObject.m_SdoComConHdl,
+					(unsigned int *)(ulArg_p +
+							 (unsigned long)
+							 &SdoObject.
+							 m_SdoComConHdl -
+							 (unsigned long)
+							 &SdoObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if (EplRet != kEplApiTaskDeferred) {	// succeeded or error ocurred, but task not deferred
+				vfree(pBufHeader);
+			}
+
+			iRet = (int)EplRet;
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_FREE_SDO_CHANNEL:
+		{
+			// forward SDO handle to EPL stack
+			EplRet =
+			    EplApiFreeSdoChannel((tEplSdoComConHdl) ulArg_p);
+
+			iRet = (int)EplRet;
+			break;
+		}
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_MN_TRIGGER_STATE_CHANGE:
-        {
-        tEplLinNodeCmdObject        NodeCmdObject;
-
-            iErr = copy_from_user(&NodeCmdObject, (const void*)ulArg_p, sizeof (NodeCmdObject));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            EplRet = EplApiMnTriggerStateChange(NodeCmdObject.m_uiNodeId,
-                                                NodeCmdObject.m_NodeCommand);
-            iRet = (int) EplRet;
-            break;
-        }
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_MN_TRIGGER_STATE_CHANGE:
+		{
+			tEplLinNodeCmdObject NodeCmdObject;
+
+			iErr =
+			    copy_from_user(&NodeCmdObject,
+					   (const void *)ulArg_p,
+					   sizeof(NodeCmdObject));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			EplRet =
+			    EplApiMnTriggerStateChange(NodeCmdObject.m_uiNodeId,
+						       NodeCmdObject.
+						       m_NodeCommand);
+			iRet = (int)EplRet;
+			break;
+		}
 #endif
 
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_GET_EVENT:
-        {
-        tEplLinEvent         Event;
-
-            // save event structure
-            iErr = copy_from_user(&Event, (const void*)ulArg_p, sizeof (Event));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            // save return code from application's event callback function
-            RetCbEvent_g = Event.m_RetCbEvent;
-
-            if (RetCbEvent_g == kEplShutdown)
-            {
-                // pass control to event queue kernel thread, but signal termination
-                atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
-                wake_up_interruptible(&WaitQueueCbEvent_g);
-                // exit with error -> EplApiProcess() will leave the infinite loop
-                iRet = 1;
-                goto Exit;
-            }
-
-            // pass control to event queue kernel thread
-            atomic_set(&AtomicEventState_g, EVENT_STATE_IOCTL);
-            wake_up_interruptible(&WaitQueueCbEvent_g);
-
-            // fall asleep itself in own wait queue
-            iErr = wait_event_interruptible(WaitQueueProcess_g,
-                                            (atomic_read(&AtomicEventState_g) == EVENT_STATE_READY)
-                                            || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM));
-            if (iErr != 0)
-            {   // waiting was interrupted by signal
-                // pass control to event queue kernel thread, but signal termination
-                atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
-                wake_up_interruptible(&WaitQueueCbEvent_g);
-                // exit with this error -> EplApiProcess() will leave the infinite loop
-                iRet = iErr;
-                goto Exit;
-            }
-            else if (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)
-            {   // termination in progress
-                // pass control to event queue kernel thread, but signal termination
-                wake_up_interruptible(&WaitQueueCbEvent_g);
-                // exit with this error -> EplApiProcess() will leave the infinite loop
-                iRet = 1;
-                goto Exit;
-            }
-
-            // copy event to user space
-            iErr = copy_to_user(Event.m_pEventType, &EventType_g, sizeof (EventType_g));
-            if (iErr != 0)
-            {   // not all data could be copied
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            // $$$ d.k. perform SDO event processing
-            if (EventType_g == kEplApiEventSdo)
-            {
-            void*               pData;
-            tEplLinSdoBufHeader*    pBufHeader;
-
-                pBufHeader = (tEplLinSdoBufHeader*) pEventArg_g->m_Sdo.m_pUserArg;
-                pData = pBufHeader + sizeof (tEplLinSdoBufHeader);
-
-                if (pEventArg_g->m_Sdo.m_SdoAccessType == kEplSdoAccessTypeRead)
-                {
-                    // copy read data to user space
-                    iErr = copy_to_user(pBufHeader->m_pData, pData, pEventArg_g->m_Sdo.m_uiTransferredByte);
-                    if (iErr != 0)
-                    {   // not all data could be copied
-                        iRet = -EIO;
-                        goto Exit;
-                    }
-                }
-                pEventArg_g->m_Sdo.m_pUserArg = pBufHeader->m_pUserArg;
-                vfree(pBufHeader);
-            }
-
-            iErr = copy_to_user(Event.m_pEventArg, pEventArg_g, min(sizeof (tEplApiEventArg), Event.m_uiEventArgSize));
-            if (iErr != 0)
-            {   // not all data could be copied
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            // return to EplApiProcess(), which will call the application's event callback function
-            iRet = 0;
-
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_PI_SETUP:
-        {
-            EplRet = EplApiProcessImageSetup();
-            iRet = (int) EplRet;
-
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_PI_IN:
-        {
-        tEplApiProcessImage ProcessImageIn;
-
-            // save process image structure
-            iErr = copy_from_user(&ProcessImageIn, (const void*)ulArg_p, sizeof (ProcessImageIn));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            // pass control to event queue kernel thread
-            atomic_set(&AtomicSyncState_g, EVENT_STATE_IOCTL);
-
-            // fall asleep itself in own wait queue
-            iErr = wait_event_interruptible(WaitQueuePI_In_g,
-                                            (atomic_read(&AtomicSyncState_g) == EVENT_STATE_READY)
-                                            || (atomic_read(&AtomicSyncState_g) == EVENT_STATE_TERM));
-            if (iErr != 0)
-            {   // waiting was interrupted by signal
-                // pass control to sync kernel thread, but signal termination
-                atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
-                wake_up_interruptible(&WaitQueueCbSync_g);
-                // exit with this error -> application will leave the infinite loop
-                iRet = iErr;
-                goto Exit;
-            }
-            else if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_TERM)
-            {   // termination in progress
-                // pass control to sync kernel thread, but signal termination
-                wake_up_interruptible(&WaitQueueCbSync_g);
-                // exit with this error -> application will leave the infinite loop
-                iRet = 1;
-                goto Exit;
-            }
-
-            // exchange process image
-            EplRet = EplApiProcessImageExchangeIn(&ProcessImageIn);
-
-            // return to EplApiProcessImageExchangeIn()
-            iRet = (int) EplRet;
-
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_PI_OUT:
-        {
-        tEplApiProcessImage ProcessImageOut;
-
-            // save process image structure
-            iErr = copy_from_user(&ProcessImageOut, (const void*)ulArg_p, sizeof (ProcessImageOut));
-            if (iErr != 0)
-            {
-                iRet = -EIO;
-                goto Exit;
-            }
-
-            if (atomic_read(&AtomicSyncState_g) != EVENT_STATE_READY)
-            {
-                iRet = (int) kEplInvalidOperation;
-                goto Exit;
-            }
-
-            // exchange process image
-            EplRet = EplApiProcessImageExchangeOut(&ProcessImageOut);
-
-            // pass control to sync kernel thread
-            atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
-            wake_up_interruptible(&WaitQueueCbSync_g);
-
-            // return to EplApiProcessImageExchangeout()
-            iRet = (int) EplRet;
-
-            break;
-        }
-
-
-        // ----------------------------------------------------------
-        case EPLLIN_CMD_NMT_COMMAND:
-        {
-            // forward NMT command to EPL stack
-            EplRet = EplApiExecNmtCommand((tEplNmtEvent)ulArg_p);
-
-            iRet = (int) EplRet;
-
-            break;
-        }
-
-
-
-        // ----------------------------------------------------------
-        default:
-        {
-            break;
-        }
-    }
-
-
-Exit:
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_GET_EVENT:
+		{
+			tEplLinEvent Event;
+
+			// save event structure
+			iErr =
+			    copy_from_user(&Event, (const void *)ulArg_p,
+					   sizeof(Event));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+			// save return code from application's event callback function
+			RetCbEvent_g = Event.m_RetCbEvent;
+
+			if (RetCbEvent_g == kEplShutdown) {
+				// pass control to event queue kernel thread, but signal termination
+				atomic_set(&AtomicEventState_g,
+					   EVENT_STATE_TERM);
+				wake_up_interruptible(&WaitQueueCbEvent_g);
+				// exit with error -> EplApiProcess() will leave the infinite loop
+				iRet = 1;
+				goto Exit;
+			}
+			// pass control to event queue kernel thread
+			atomic_set(&AtomicEventState_g, EVENT_STATE_IOCTL);
+			wake_up_interruptible(&WaitQueueCbEvent_g);
+
+			// fall asleep itself in own wait queue
+			iErr = wait_event_interruptible(WaitQueueProcess_g,
+							(atomic_read
+							 (&AtomicEventState_g)
+							 == EVENT_STATE_READY)
+							||
+							(atomic_read
+							 (&AtomicEventState_g)
+							 == EVENT_STATE_TERM));
+			if (iErr != 0) {	// waiting was interrupted by signal
+				// pass control to event queue kernel thread, but signal termination
+				atomic_set(&AtomicEventState_g,
+					   EVENT_STATE_TERM);
+				wake_up_interruptible(&WaitQueueCbEvent_g);
+				// exit with this error -> EplApiProcess() will leave the infinite loop
+				iRet = iErr;
+				goto Exit;
+			} else if (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM) {	// termination in progress
+				// pass control to event queue kernel thread, but signal termination
+				wake_up_interruptible(&WaitQueueCbEvent_g);
+				// exit with this error -> EplApiProcess() will leave the infinite loop
+				iRet = 1;
+				goto Exit;
+			}
+			// copy event to user space
+			iErr =
+			    copy_to_user(Event.m_pEventType, &EventType_g,
+					 sizeof(EventType_g));
+			if (iErr != 0) {	// not all data could be copied
+				iRet = -EIO;
+				goto Exit;
+			}
+			// $$$ d.k. perform SDO event processing
+			if (EventType_g == kEplApiEventSdo) {
+				void *pData;
+				tEplLinSdoBufHeader *pBufHeader;
+
+				pBufHeader =
+				    (tEplLinSdoBufHeader *) pEventArg_g->m_Sdo.
+				    m_pUserArg;
+				pData =
+				    pBufHeader + sizeof(tEplLinSdoBufHeader);
+
+				if (pEventArg_g->m_Sdo.m_SdoAccessType ==
+				    kEplSdoAccessTypeRead) {
+					// copy read data to user space
+					iErr =
+					    copy_to_user(pBufHeader->m_pData,
+							 pData,
+							 pEventArg_g->m_Sdo.
+							 m_uiTransferredByte);
+					if (iErr != 0) {	// not all data could be copied
+						iRet = -EIO;
+						goto Exit;
+					}
+				}
+				pEventArg_g->m_Sdo.m_pUserArg =
+				    pBufHeader->m_pUserArg;
+				vfree(pBufHeader);
+			}
+
+			iErr =
+			    copy_to_user(Event.m_pEventArg, pEventArg_g,
+					 min(sizeof(tEplApiEventArg),
+					     Event.m_uiEventArgSize));
+			if (iErr != 0) {	// not all data could be copied
+				iRet = -EIO;
+				goto Exit;
+			}
+			// return to EplApiProcess(), which will call the application's event callback function
+			iRet = 0;
+
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_PI_SETUP:
+		{
+			EplRet = EplApiProcessImageSetup();
+			iRet = (int)EplRet;
+
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_PI_IN:
+		{
+			tEplApiProcessImage ProcessImageIn;
+
+			// save process image structure
+			iErr =
+			    copy_from_user(&ProcessImageIn,
+					   (const void *)ulArg_p,
+					   sizeof(ProcessImageIn));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+			// pass control to event queue kernel thread
+			atomic_set(&AtomicSyncState_g, EVENT_STATE_IOCTL);
+
+			// fall asleep itself in own wait queue
+			iErr = wait_event_interruptible(WaitQueuePI_In_g,
+							(atomic_read
+							 (&AtomicSyncState_g) ==
+							 EVENT_STATE_READY)
+							||
+							(atomic_read
+							 (&AtomicSyncState_g) ==
+							 EVENT_STATE_TERM));
+			if (iErr != 0) {	// waiting was interrupted by signal
+				// pass control to sync kernel thread, but signal termination
+				atomic_set(&AtomicSyncState_g,
+					   EVENT_STATE_TERM);
+				wake_up_interruptible(&WaitQueueCbSync_g);
+				// exit with this error -> application will leave the infinite loop
+				iRet = iErr;
+				goto Exit;
+			} else if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_TERM) {	// termination in progress
+				// pass control to sync kernel thread, but signal termination
+				wake_up_interruptible(&WaitQueueCbSync_g);
+				// exit with this error -> application will leave the infinite loop
+				iRet = 1;
+				goto Exit;
+			}
+			// exchange process image
+			EplRet = EplApiProcessImageExchangeIn(&ProcessImageIn);
+
+			// return to EplApiProcessImageExchangeIn()
+			iRet = (int)EplRet;
+
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_PI_OUT:
+		{
+			tEplApiProcessImage ProcessImageOut;
+
+			// save process image structure
+			iErr =
+			    copy_from_user(&ProcessImageOut,
+					   (const void *)ulArg_p,
+					   sizeof(ProcessImageOut));
+			if (iErr != 0) {
+				iRet = -EIO;
+				goto Exit;
+			}
+
+			if (atomic_read(&AtomicSyncState_g) !=
+			    EVENT_STATE_READY) {
+				iRet = (int)kEplInvalidOperation;
+				goto Exit;
+			}
+			// exchange process image
+			EplRet =
+			    EplApiProcessImageExchangeOut(&ProcessImageOut);
+
+			// pass control to sync kernel thread
+			atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM);
+			wake_up_interruptible(&WaitQueueCbSync_g);
+
+			// return to EplApiProcessImageExchangeout()
+			iRet = (int)EplRet;
+
+			break;
+		}
+
+		// ----------------------------------------------------------
+	case EPLLIN_CMD_NMT_COMMAND:
+		{
+			// forward NMT command to EPL stack
+			EplRet = EplApiExecNmtCommand((tEplNmtEvent) ulArg_p);
+
+			iRet = (int)EplRet;
+
+			break;
+		}
+
+		// ----------------------------------------------------------
+	default:
+		{
+			break;
+		}
+	}
+
+      Exit:
 
 //    TRACE1("EPL: - EplLinIoctl (iRet=%d)\n", iRet);
-    return (iRet);
+	return (iRet);
 
 }
 
-
-
-
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
 //                                                                         //
 //=========================================================================//
 
-
-tEplKernel PUBLIC EplLinCbEvent(
-    tEplApiEventType        EventType_p,   // IN: event type (enum)
-    tEplApiEventArg*        pEventArg_p,   // IN: event argument (union)
-    void GENERIC*           pUserArg_p)
+tEplKernel PUBLIC EplLinCbEvent(tEplApiEventType EventType_p,	// IN: event type (enum)
+				tEplApiEventArg * pEventArg_p,	// IN: event argument (union)
+				void GENERIC * pUserArg_p)
 {
-tEplKernel          EplRet = kEplSuccessful;
-int  iErr;
-
-    // block any further call to this function, i.e. enter critical section
-    iErr = down_interruptible(&SemaphoreCbEvent_g);
-    if (iErr != 0)
-    {   // waiting was interrupted by signal
-        EplRet = kEplShutdown;
-        goto Exit;
-    }
-
-    // wait for EplApiProcess() to call ioctl
-    // normally it should be waiting already for us to pass a new event
-    iErr = wait_event_interruptible(WaitQueueCbEvent_g,
-                                    (atomic_read(&AtomicEventState_g) == EVENT_STATE_IOCTL)
-                                    || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM));
-    if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM))
-    {   // waiting was interrupted by signal
-        EplRet = kEplShutdown;
-        goto LeaveCriticalSection;
-    }
-
-    // save event information for ioctl
-    EventType_g = EventType_p;
-    pEventArg_g = pEventArg_p;
-
-    // pass control to application's event callback function, i.e. EplApiProcess()
-    atomic_set(&AtomicEventState_g, EVENT_STATE_READY);
-    wake_up_interruptible(&WaitQueueProcess_g);
-
-    // now, the application's event callback function processes the event
-
-    // wait for completion of application's event callback function, i.e. EplApiProcess() calls ioctl again
-    iErr = wait_event_interruptible(WaitQueueCbEvent_g,
-                                    (atomic_read(&AtomicEventState_g) == EVENT_STATE_IOCTL)
-                                    || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM));
-    if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM))
-    {   // waiting was interrupted by signal
-        EplRet = kEplShutdown;
-        goto LeaveCriticalSection;
-    }
-
-    // read return code from application's event callback function
-    EplRet = RetCbEvent_g;
-
-
-LeaveCriticalSection:
-    up(&SemaphoreCbEvent_g);
-
-Exit:
-    // check if NMT_GS_OFF is reached
-    if (EventType_p == kEplApiEventNmtStateChange)
-    {
-        if (pEventArg_p->m_NmtStateChange.m_NewNmtState == kEplNmtGsOff)
-        {   // NMT state machine was shut down
-            TRACE0("EPL:   EplLinCbEvent(NMT_GS_OFF)\n");
-            uiEplState_g = EPL_STATE_SHUTDOWN;
-            atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
-            wake_up(&WaitQueueRelease_g);
-        }
-        else
-        {   // NMT state machine is running
-            uiEplState_g = EPL_STATE_RUNNING;
-        }
-    }
-
-
-    return EplRet;
+	tEplKernel EplRet = kEplSuccessful;
+	int iErr;
+
+	// block any further call to this function, i.e. enter critical section
+	iErr = down_interruptible(&SemaphoreCbEvent_g);
+	if (iErr != 0) {	// waiting was interrupted by signal
+		EplRet = kEplShutdown;
+		goto Exit;
+	}
+	// wait for EplApiProcess() to call ioctl
+	// normally it should be waiting already for us to pass a new event
+	iErr = wait_event_interruptible(WaitQueueCbEvent_g,
+					(atomic_read(&AtomicEventState_g) ==
+					 EVENT_STATE_IOCTL)
+					|| (atomic_read(&AtomicEventState_g) ==
+					    EVENT_STATE_TERM));
+	if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)) {	// waiting was interrupted by signal
+		EplRet = kEplShutdown;
+		goto LeaveCriticalSection;
+	}
+	// save event information for ioctl
+	EventType_g = EventType_p;
+	pEventArg_g = pEventArg_p;
+
+	// pass control to application's event callback function, i.e. EplApiProcess()
+	atomic_set(&AtomicEventState_g, EVENT_STATE_READY);
+	wake_up_interruptible(&WaitQueueProcess_g);
+
+	// now, the application's event callback function processes the event
+
+	// wait for completion of application's event callback function, i.e. EplApiProcess() calls ioctl again
+	iErr = wait_event_interruptible(WaitQueueCbEvent_g,
+					(atomic_read(&AtomicEventState_g) ==
+					 EVENT_STATE_IOCTL)
+					|| (atomic_read(&AtomicEventState_g) ==
+					    EVENT_STATE_TERM));
+	if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)) {	// waiting was interrupted by signal
+		EplRet = kEplShutdown;
+		goto LeaveCriticalSection;
+	}
+	// read return code from application's event callback function
+	EplRet = RetCbEvent_g;
+
+      LeaveCriticalSection:
+	up(&SemaphoreCbEvent_g);
+
+      Exit:
+	// check if NMT_GS_OFF is reached
+	if (EventType_p == kEplApiEventNmtStateChange) {
+		if (pEventArg_p->m_NmtStateChange.m_NewNmtState == kEplNmtGsOff) {	// NMT state machine was shut down
+			TRACE0("EPL:   EplLinCbEvent(NMT_GS_OFF)\n");
+			uiEplState_g = EPL_STATE_SHUTDOWN;
+			atomic_set(&AtomicEventState_g, EVENT_STATE_TERM);
+			wake_up(&WaitQueueRelease_g);
+		} else {	// NMT state machine is running
+			uiEplState_g = EPL_STATE_RUNNING;
+		}
+	}
+
+	return EplRet;
 }
 
-
 tEplKernel PUBLIC EplLinCbSync(void)
 {
-tEplKernel          EplRet = kEplSuccessful;
-int  iErr;
-
-    // check if user process waits for sync
-    if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_IOCTL)
-    {
-        // pass control to application, i.e. EplApiProcessImageExchangeIn()
-        atomic_set(&AtomicSyncState_g, EVENT_STATE_READY);
-        wake_up_interruptible(&WaitQueuePI_In_g);
-
-        // now, the application processes the sync event
-
-        // wait for call of EplApiProcessImageExchangeOut()
-        iErr = wait_event_interruptible(WaitQueueCbSync_g,
-                                        (atomic_read(&AtomicSyncState_g) == EVENT_STATE_IOCTL)
-                                        || (atomic_read(&AtomicSyncState_g) == EVENT_STATE_TERM));
-        if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_IOCTL))
-        {   // waiting was interrupted by signal or application called wrong function
-            EplRet = kEplShutdown;
-        }
-    }
-    else
-    {   // application is currently not waiting for sync
-        // continue without interruption
-        // TPDO are set valid by caller (i.e. EplEventkProcess())
-    }
-
-    TGT_DBG_SIGNAL_TRACE_POINT(1);
-
-    return EplRet;
+	tEplKernel EplRet = kEplSuccessful;
+	int iErr;
+
+	// check if user process waits for sync
+	if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_IOCTL) {
+		// pass control to application, i.e. EplApiProcessImageExchangeIn()
+		atomic_set(&AtomicSyncState_g, EVENT_STATE_READY);
+		wake_up_interruptible(&WaitQueuePI_In_g);
+
+		// now, the application processes the sync event
+
+		// wait for call of EplApiProcessImageExchangeOut()
+		iErr = wait_event_interruptible(WaitQueueCbSync_g,
+						(atomic_read(&AtomicSyncState_g)
+						 == EVENT_STATE_IOCTL)
+						||
+						(atomic_read(&AtomicSyncState_g)
+						 == EVENT_STATE_TERM));
+		if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_IOCTL)) {	// waiting was interrupted by signal or application called wrong function
+			EplRet = kEplShutdown;
+		}
+	} else {		// application is currently not waiting for sync
+		// continue without interruption
+		// TPDO are set valid by caller (i.e. EplEventkProcess())
+	}
+
+	TGT_DBG_SIGNAL_TRACE_POINT(1);
+
+	return EplRet;
 }
 
-
-
 // EOF
-

+ 127 - 154
drivers/staging/epl/EplApiProcessImage.c

@@ -75,7 +75,6 @@
 #include <asm/uaccess.h>
 #endif
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -100,7 +99,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -114,7 +112,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -130,36 +127,33 @@
 //---------------------------------------------------------------------------
 
 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
-    typedef struct
-    {
-        #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
-            BYTE        m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
-        #endif
-        #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
-            BYTE        m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
-        #endif
+typedef struct {
+#if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
+	BYTE m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
+#endif
+#if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
+	BYTE m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
+#endif
 
-    } tEplApiProcessImageInstance;
+} tEplApiProcessImageInstance;
 
 //---------------------------------------------------------------------------
 // local vars
 //---------------------------------------------------------------------------
 
-static tEplApiProcessImageInstance  EplApiProcessImageInstance_g;
+static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
 #endif
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
 //                                                                         //
 //=========================================================================//
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplApiProcessImageSetup()
@@ -177,125 +171,101 @@ static tEplApiProcessImageInstance  EplApiProcessImageInstance_g;
 
 tEplKernel PUBLIC EplApiProcessImageSetup(void)
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 #if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
-unsigned int    uiVarEntries;
-tEplObdSize     ObdSize;
+	unsigned int uiVarEntries;
+	tEplObdSize ObdSize;
 #endif
 
 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
-    ObdSize = 1;
-    Ret = EplApiLinkObject(
-                            0x2000,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
-    ObdSize = 1;
-    Ret = EplApiLinkObject(
-                            0x2001,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 2;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2010,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 2;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2011,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 4;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2020,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 4;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2021,
-                            EplApiProcessImageInstance_g.m_abProcessImageInput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
+	ObdSize = 1;
+	Ret = EplApiLinkObject(0x2000,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
+
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
+	ObdSize = 1;
+	Ret = EplApiLinkObject(0x2001,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 2;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
+	Ret = EplApiLinkObject(0x2010,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 2;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
+	Ret = EplApiLinkObject(0x2011,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 4;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
+	Ret = EplApiLinkObject(0x2020,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 4;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
+	Ret = EplApiLinkObject(0x2021,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageInput, &uiVarEntries, &ObdSize,
+			       1);
 #endif
 
 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
-    ObdSize = 1;
-    Ret = EplApiLinkObject(
-                            0x2030,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
-    ObdSize = 1;
-    Ret = EplApiLinkObject(
-                            0x2031,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 2;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2040,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 2;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2041,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 4;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2050,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
-
-    ObdSize = 4;
-    uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
-    Ret = EplApiLinkObject(
-                            0x2051,
-                            EplApiProcessImageInstance_g.m_abProcessImageOutput,
-                            &uiVarEntries,
-                            &ObdSize,
-                            1);
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
+	ObdSize = 1;
+	Ret = EplApiLinkObject(0x2030,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
+
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
+	ObdSize = 1;
+	Ret = EplApiLinkObject(0x2031,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 2;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
+	Ret = EplApiLinkObject(0x2040,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 2;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
+	Ret = EplApiLinkObject(0x2041,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 4;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
+	Ret = EplApiLinkObject(0x2050,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
+
+	ObdSize = 4;
+	uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
+	Ret = EplApiLinkObject(0x2051,
+			       EplApiProcessImageInstance_g.
+			       m_abProcessImageOutput, &uiVarEntries, &ObdSize,
+			       1);
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //----------------------------------------------------------------------------
@@ -310,26 +280,29 @@ tEplObdSize     ObdSize;
 // State:
 //----------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage* pPI_p)
+tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage * pPI_p)
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
 #if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
-    #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-        copy_to_user(pPI_p->m_pImage,
-            EplApiProcessImageInstance_g.m_abProcessImageInput,
-            min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
-    #else
-        EPL_MEMCPY(pPI_p->m_pImage,
-            EplApiProcessImageInstance_g.m_abProcessImageInput,
-            min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
-    #endif
+#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
+	copy_to_user(pPI_p->m_pImage,
+		     EplApiProcessImageInstance_g.m_abProcessImageInput,
+		     min(pPI_p->m_uiSize,
+			 sizeof(EplApiProcessImageInstance_g.
+				m_abProcessImageInput)));
+#else
+	EPL_MEMCPY(pPI_p->m_pImage,
+		   EplApiProcessImageInstance_g.m_abProcessImageInput,
+		   min(pPI_p->m_uiSize,
+		       sizeof(EplApiProcessImageInstance_g.
+			      m_abProcessImageInput)));
+#endif
 #endif
 
-    return Ret;
+	return Ret;
 }
 
-
 //----------------------------------------------------------------------------
 // Function:    EplApiProcessImageExchangeOut()
 //
@@ -342,33 +315,33 @@ tEplKernel      Ret = kEplSuccessful;
 // State:
 //----------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage* pPI_p)
+tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage * pPI_p)
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
 #if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
-    #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-        copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
-            pPI_p->m_pImage,
-            min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
-    #else
-        EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
-            pPI_p->m_pImage,
-            min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
-    #endif
+#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
+	copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
+		       pPI_p->m_pImage,
+		       min(pPI_p->m_uiSize,
+			   sizeof(EplApiProcessImageInstance_g.
+				  m_abProcessImageOutput)));
+#else
+	EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
+		   pPI_p->m_pImage,
+		   min(pPI_p->m_uiSize,
+		       sizeof(EplApiProcessImageInstance_g.
+			      m_abProcessImageOutput)));
+#endif
 #endif
 
-    return Ret;
+	return Ret;
 }
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
 //                                                                         //
 //=========================================================================//
 
-
-
 // EOF
-

File diff suppressed because it is too large
+ 950 - 830
drivers/staging/epl/EplDllk.c


File diff suppressed because it is too large
+ 410 - 400
drivers/staging/epl/EplDllkCal.c


+ 141 - 146
drivers/staging/epl/EplDlluCal.c

@@ -78,7 +78,6 @@
 #include "kernel/EplDllkCal.h"
 #endif
 
-
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
 
 /***************************************************************************/
@@ -105,7 +104,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -119,7 +117,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -134,9 +131,8 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    tEplDlluCbAsnd  m_apfnDlluCbAsnd[EPL_DLL_MAX_ASND_SERVICE_ID];
+typedef struct {
+	tEplDlluCbAsnd m_apfnDlluCbAsnd[EPL_DLL_MAX_ASND_SERVICE_ID];
 
 } tEplDlluCalInstance;
 
@@ -146,13 +142,15 @@ typedef struct
 
 // if no dynamic memory allocation shall be used
 // define structures statically
-static tEplDlluCalInstance     EplDlluCalInstance_g;
+static tEplDlluCalInstance EplDlluCalInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p);
+static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId
+						   ServiceId_p,
+						   tEplDllAsndFilter Filter_p);
 
 //=========================================================================//
 //                                                                         //
@@ -177,12 +175,12 @@ static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceI
 
 tEplKernel EplDlluCalAddInstance()
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof(EplDlluCalInstance_g));
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -202,15 +200,14 @@ tEplKernel      Ret = kEplSuccessful;
 
 tEplKernel EplDlluCalDelInstance()
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof(EplDlluCalInstance_g));
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplDlluCalProcess
@@ -228,37 +225,40 @@ tEplKernel      Ret = kEplSuccessful;
 
 tEplKernel EplDlluCalProcess(tEplEvent * pEvent_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplMsgType     MsgType;
-unsigned int    uiAsndServiceId;
-tEplFrameInfo   FrameInfo;
-
-    if (pEvent_p->m_EventType == kEplEventTypeAsndRx)
-    {
-        FrameInfo.m_pFrame = (tEplFrame*) pEvent_p->m_pArg;
-        FrameInfo.m_uiFrameSize = pEvent_p->m_uiSize;
-        // extract NetTime
-        FrameInfo.m_NetTime = pEvent_p->m_NetTime;
-
-        MsgType = (tEplMsgType)AmiGetByteFromLe(&FrameInfo.m_pFrame->m_le_bMessageType);
-        if (MsgType != kEplMsgTypeAsnd)
-        {
-            Ret = kEplInvalidOperation;
-            goto Exit;
-        }
-
-        uiAsndServiceId = (unsigned int) AmiGetByteFromLe(&FrameInfo.m_pFrame->m_Data.m_Asnd.m_le_bServiceId);
-        if (uiAsndServiceId < EPL_DLL_MAX_ASND_SERVICE_ID)
-        {   // ASnd service ID is valid
-            if (EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId] != NULL)
-            {   // handler was registered
-                Ret = EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId](&FrameInfo);
-            }
-        }
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	tEplMsgType MsgType;
+	unsigned int uiAsndServiceId;
+	tEplFrameInfo FrameInfo;
+
+	if (pEvent_p->m_EventType == kEplEventTypeAsndRx) {
+		FrameInfo.m_pFrame = (tEplFrame *) pEvent_p->m_pArg;
+		FrameInfo.m_uiFrameSize = pEvent_p->m_uiSize;
+		// extract NetTime
+		FrameInfo.m_NetTime = pEvent_p->m_NetTime;
+
+		MsgType =
+		    (tEplMsgType) AmiGetByteFromLe(&FrameInfo.m_pFrame->
+						   m_le_bMessageType);
+		if (MsgType != kEplMsgTypeAsnd) {
+			Ret = kEplInvalidOperation;
+			goto Exit;
+		}
+
+		uiAsndServiceId =
+		    (unsigned int)AmiGetByteFromLe(&FrameInfo.m_pFrame->m_Data.
+						   m_Asnd.m_le_bServiceId);
+		if (uiAsndServiceId < EPL_DLL_MAX_ASND_SERVICE_ID) {	// ASnd service ID is valid
+			if (EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId] != NULL) {	// handler was registered
+				Ret =
+				    EplDlluCalInstance_g.
+				    m_apfnDlluCbAsnd[uiAsndServiceId]
+				    (&FrameInfo);
+			}
+		}
+	}
+
+      Exit:
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -279,26 +279,26 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p, tEplDlluCbAsnd pfnDlluCbAsnd_p, tEplDllAsndFilter Filter_p)
+tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p,
+				    tEplDlluCbAsnd pfnDlluCbAsnd_p,
+				    tEplDllAsndFilter Filter_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-
-    if (ServiceId_p < tabentries (EplDlluCalInstance_g.m_apfnDlluCbAsnd))
-    {
-        // memorize function pointer
-        EplDlluCalInstance_g.m_apfnDlluCbAsnd[ServiceId_p] = pfnDlluCbAsnd_p;
+	tEplKernel Ret = kEplSuccessful;
 
-        if (pfnDlluCbAsnd_p == NULL)
-        {   // close filter
-            Filter_p = kEplDllAsndFilterNone;
-        }
+	if (ServiceId_p < tabentries(EplDlluCalInstance_g.m_apfnDlluCbAsnd)) {
+		// memorize function pointer
+		EplDlluCalInstance_g.m_apfnDlluCbAsnd[ServiceId_p] =
+		    pfnDlluCbAsnd_p;
 
-        // set filter in DLL module in kernel part
-        Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p);
+		if (pfnDlluCbAsnd_p == NULL) {	// close filter
+			Filter_p = kEplDllAsndFilterNone;
+		}
+		// set filter in DLL module in kernel part
+		Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p);
 
-    }
+	}
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -319,21 +319,21 @@ tEplKernel  Ret = kEplSuccessful;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p)
+tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo_p,
+			       tEplDllAsyncReqPriority Priority_p)
 {
-tEplKernel  Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
-    pFrameInfo_p->m_uiFrameSize += 14;  // add size of ethernet header
-    Ret = EplDllkCalAsyncSend(pFrameInfo_p, Priority_p);
+	pFrameInfo_p->m_uiFrameSize += 14;	// add size of ethernet header
+	Ret = EplDllkCalAsyncSend(pFrameInfo_p, Priority_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
-
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
 
 //---------------------------------------------------------------------------
@@ -354,43 +354,42 @@ tEplKernel  Ret = kEplSuccessful;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p)
+tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p,
+				  unsigned int uiNodeId_p, BYTE bSoaFlag1_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-
-    // add node to appropriate request queue
-    switch (Service_p)
-    {
-        case kEplDllReqServiceIdent:
-        case kEplDllReqServiceStatus:
-        {
-        tEplEvent   Event;
-        tEplDllCalIssueRequest  IssueReq;
-
-            Event.m_EventSink = kEplEventSinkDllkCal;
-            Event.m_EventType = kEplEventTypeDllkIssueReq;
-            IssueReq.m_Service = Service_p;
-            IssueReq.m_uiNodeId = uiNodeId_p;
-            IssueReq.m_bSoaFlag1 = bSoaFlag1_p;
-            Event.m_pArg = &IssueReq;
-            Event.m_uiSize = sizeof (IssueReq);
-
-            Ret = EplEventuPost(&Event);
-            break;
-        }
-
-        default:
-        {
-            Ret = kEplDllInvalidParam;
-            goto Exit;
-        }
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+
+	// add node to appropriate request queue
+	switch (Service_p) {
+	case kEplDllReqServiceIdent:
+	case kEplDllReqServiceStatus:
+		{
+			tEplEvent Event;
+			tEplDllCalIssueRequest IssueReq;
+
+			Event.m_EventSink = kEplEventSinkDllkCal;
+			Event.m_EventType = kEplEventTypeDllkIssueReq;
+			IssueReq.m_Service = Service_p;
+			IssueReq.m_uiNodeId = uiNodeId_p;
+			IssueReq.m_bSoaFlag1 = bSoaFlag1_p;
+			Event.m_pArg = &IssueReq;
+			Event.m_uiSize = sizeof(IssueReq);
+
+			Ret = EplEventuPost(&Event);
+			break;
+		}
+
+	default:
+		{
+			Ret = kEplDllInvalidParam;
+			goto Exit;
+		}
+	}
+
+      Exit:
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplDlluCalAddNode()
@@ -408,20 +407,19 @@ Exit:
 
 tEplKernel EplDlluCalAddNode(tEplDllNodeInfo * pNodeInfo_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-tEplEvent   Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
-    Event.m_EventSink = kEplEventSinkDllkCal;
-    Event.m_EventType = kEplEventTypeDllkAddNode;
-    Event.m_pArg = pNodeInfo_p;
-    Event.m_uiSize = sizeof (tEplDllNodeInfo);
+	Event.m_EventSink = kEplEventSinkDllkCal;
+	Event.m_EventType = kEplEventTypeDllkAddNode;
+	Event.m_pArg = pNodeInfo_p;
+	Event.m_uiSize = sizeof(tEplDllNodeInfo);
 
-    Ret = EplEventuPost(&Event);
+	Ret = EplEventuPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplDlluCalDeleteNode()
@@ -439,20 +437,19 @@ tEplEvent   Event;
 
 tEplKernel EplDlluCalDeleteNode(unsigned int uiNodeId_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-tEplEvent   Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
-    Event.m_EventSink = kEplEventSinkDllkCal;
-    Event.m_EventType = kEplEventTypeDllkDelNode;
-    Event.m_pArg = &uiNodeId_p;
-    Event.m_uiSize = sizeof (uiNodeId_p);
+	Event.m_EventSink = kEplEventSinkDllkCal;
+	Event.m_EventType = kEplEventTypeDllkDelNode;
+	Event.m_pArg = &uiNodeId_p;
+	Event.m_uiSize = sizeof(uiNodeId_p);
 
-    Ret = EplEventuPost(&Event);
+	Ret = EplEventuPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplDlluCalSoftDeleteNode()
@@ -470,23 +467,21 @@ tEplEvent   Event;
 
 tEplKernel EplDlluCalSoftDeleteNode(unsigned int uiNodeId_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-tEplEvent   Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
-    Event.m_EventSink = kEplEventSinkDllkCal;
-    Event.m_EventType = kEplEventTypeDllkSoftDelNode;
-    Event.m_pArg = &uiNodeId_p;
-    Event.m_uiSize = sizeof (uiNodeId_p);
+	Event.m_EventSink = kEplEventSinkDllkCal;
+	Event.m_EventType = kEplEventTypeDllkSoftDelNode;
+	Event.m_pArg = &uiNodeId_p;
+	Event.m_uiSize = sizeof(uiNodeId_p);
 
-    Ret = EplEventuPost(&Event);
+	Ret = EplEventuPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
-
 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -509,26 +504,26 @@ tEplEvent   Event;
 //
 //---------------------------------------------------------------------------
 
-static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p)
+static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId
+						   ServiceId_p,
+						   tEplDllAsndFilter Filter_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-tEplEvent   Event;
-tEplDllCalAsndServiceIdFilter   ServFilter;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
+	tEplDllCalAsndServiceIdFilter ServFilter;
 
-    Event.m_EventSink = kEplEventSinkDllkCal;
-    Event.m_EventType = kEplEventTypeDllkServFilter;
-    ServFilter.m_ServiceId = ServiceId_p;
-    ServFilter.m_Filter = Filter_p;
-    Event.m_pArg = &ServFilter;
-    Event.m_uiSize = sizeof (ServFilter);
+	Event.m_EventSink = kEplEventSinkDllkCal;
+	Event.m_EventType = kEplEventTypeDllkServFilter;
+	ServFilter.m_ServiceId = ServiceId_p;
+	ServFilter.m_Filter = Filter_p;
+	Event.m_pArg = &ServFilter;
+	Event.m_uiSize = sizeof(ServFilter);
 
-    Ret = EplEventuPost(&Event);
+	Ret = EplEventuPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
-
 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
 
 // EOF
-

File diff suppressed because it is too large
+ 478 - 459
drivers/staging/epl/EplErrorHandlerk.c


File diff suppressed because it is too large
+ 420 - 416
drivers/staging/epl/EplEventk.c


File diff suppressed because it is too large
+ 430 - 428
drivers/staging/epl/EplEventu.c


+ 139 - 148
drivers/staging/epl/EplIdentu.c

@@ -95,7 +95,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -109,7 +108,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -124,10 +122,9 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    tEplIdentResponse*   m_apIdentResponse[254];    // the IdentResponse are managed dynamically
-    tEplIdentuCbResponse m_apfnCbResponse[254];
+typedef struct {
+	tEplIdentResponse *m_apIdentResponse[254];	// the IdentResponse are managed dynamically
+	tEplIdentuCbResponse m_apfnCbResponse[254];
 
 } tEplIdentuInstance;
 
@@ -135,7 +132,7 @@ typedef struct
 // local vars
 //---------------------------------------------------------------------------
 
-static tEplIdentuInstance   EplIdentuInstance_g;
+static tEplIdentuInstance EplIdentuInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
@@ -169,14 +166,13 @@ static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p);
 
 EPLDLLEXPORT tEplKernel PUBLIC EplIdentuInit()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = EplIdentuAddInstance();
+	Ret = EplIdentuAddInstance();
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuAddInstance
@@ -197,21 +193,23 @@ tEplKernel Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplIdentuAddInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof(EplIdentuInstance_g));
 
-    // register IdentResponse callback function
-    Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, EplIdentuCbIdentResponse, kEplDllAsndFilterAny);
+	// register IdentResponse callback function
+	Ret =
+	    EplDlluCalRegAsndService(kEplDllAsndIdentResponse,
+				     EplIdentuCbIdentResponse,
+				     kEplDllAsndFilterAny);
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuDelInstance
@@ -232,20 +230,21 @@ tEplKernel Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplIdentuDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // deregister IdentResponse callback function
-    Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, NULL, kEplDllAsndFilterNone);
+	// deregister IdentResponse callback function
+	Ret =
+	    EplDlluCalRegAsndService(kEplDllAsndIdentResponse, NULL,
+				     kEplDllAsndFilterNone);
 
-    Ret = EplIdentuReset();
+	Ret = EplIdentuReset();
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuReset
@@ -266,26 +265,25 @@ tEplKernel  Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplIdentuReset()
 {
-tEplKernel  Ret;
-int         iIndex;
+	tEplKernel Ret;
+	int iIndex;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    for (iIndex = 0; iIndex < tabentries (EplIdentuInstance_g.m_apIdentResponse); iIndex++)
-    {
-        if (EplIdentuInstance_g.m_apIdentResponse[iIndex] != NULL)
-        {   // free memory
-            EPL_FREE(EplIdentuInstance_g.m_apIdentResponse[iIndex]);
-        }
-    }
+	for (iIndex = 0;
+	     iIndex < tabentries(EplIdentuInstance_g.m_apIdentResponse);
+	     iIndex++) {
+		if (EplIdentuInstance_g.m_apIdentResponse[iIndex] != NULL) {	// free memory
+			EPL_FREE(EplIdentuInstance_g.m_apIdentResponse[iIndex]);
+		}
+	}
 
-    EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
+	EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof(EplIdentuInstance_g));
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuGetIdentResponse
@@ -302,31 +300,28 @@ int         iIndex;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplIdentuGetIdentResponse(
-                                    unsigned int        uiNodeId_p,
-                                    tEplIdentResponse** ppIdentResponse_p)
+tEplKernel PUBLIC EplIdentuGetIdentResponse(unsigned int uiNodeId_p,
+					    tEplIdentResponse **
+					    ppIdentResponse_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // decrement node ID, because array is zero based
-    uiNodeId_p--;
-    if (uiNodeId_p < tabentries (EplIdentuInstance_g.m_apIdentResponse))
-    {
-        *ppIdentResponse_p = EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p];
-    }
-    else
-    {   // invalid node ID specified
-        *ppIdentResponse_p = NULL;
-        Ret = kEplInvalidNodeId;
-    }
+	// decrement node ID, because array is zero based
+	uiNodeId_p--;
+	if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apIdentResponse)) {
+		*ppIdentResponse_p =
+		    EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p];
+	} else {		// invalid node ID specified
+		*ppIdentResponse_p = NULL;
+		Ret = kEplInvalidNodeId;
+	}
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuRequestIdentResponse
@@ -343,42 +338,38 @@ tEplKernel  Ret;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplIdentuRequestIdentResponse(
-                                    unsigned int        uiNodeId_p,
-                                    tEplIdentuCbResponse pfnCbResponse_p)
+tEplKernel PUBLIC EplIdentuRequestIdentResponse(unsigned int uiNodeId_p,
+						tEplIdentuCbResponse
+						pfnCbResponse_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // decrement node ID, because array is zero based
-    uiNodeId_p--;
-    if (uiNodeId_p < tabentries (EplIdentuInstance_g.m_apfnCbResponse))
-    {
+	// decrement node ID, because array is zero based
+	uiNodeId_p--;
+	if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) {
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-        if (EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL)
-        {   // request already issued (maybe by someone else)
-            Ret = kEplInvalidOperation;
-        }
-        else
-        {
-            EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] = pfnCbResponse_p;
-            Ret = EplDlluCalIssueRequest(kEplDllReqServiceIdent, (uiNodeId_p + 1), 0xFF);
-        }
+		if (EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL) {	// request already issued (maybe by someone else)
+			Ret = kEplInvalidOperation;
+		} else {
+			EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] =
+			    pfnCbResponse_p;
+			Ret =
+			    EplDlluCalIssueRequest(kEplDllReqServiceIdent,
+						   (uiNodeId_p + 1), 0xFF);
+		}
 #else
-        Ret = kEplInvalidOperation;
+		Ret = kEplInvalidOperation;
 #endif
-    }
-    else
-    {   // invalid node ID specified
-        Ret = kEplInvalidNodeId;
-    }
+	} else {		// invalid node ID specified
+		Ret = kEplInvalidNodeId;
+	}
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplIdentuGetRunningRequests
@@ -399,20 +390,17 @@ tEplKernel  Ret;
 
 EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void)
 {
-DWORD       dwReqs = 0;
-unsigned int    uiIndex;
-
-    for (uiIndex = 0; uiIndex < 32; uiIndex++)
-    {
-        if (EplIdentuInstance_g.m_apfnCbResponse[uiIndex] != NULL)
-        {
-            dwReqs |= (1 << uiIndex);
-        }
-    }
-
-    return dwReqs;
-}
+	DWORD dwReqs = 0;
+	unsigned int uiIndex;
 
+	for (uiIndex = 0; uiIndex < 32; uiIndex++) {
+		if (EplIdentuInstance_g.m_apfnCbResponse[uiIndex] != NULL) {
+			dwReqs |= (1 << uiIndex);
+		}
+	}
+
+	return dwReqs;
+}
 
 //=========================================================================//
 //                                                                         //
@@ -440,58 +428,61 @@ unsigned int    uiIndex;
 
 static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-unsigned int    uiNodeId;
-unsigned int    uiIndex;
-tEplIdentuCbResponse    pfnCbResponse;
-
-    uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
-
-    uiIndex = uiNodeId - 1;
-
-    if (uiIndex < tabentries (EplIdentuInstance_g.m_apfnCbResponse))
-    {
-        // memorize pointer to callback function
-        pfnCbResponse = EplIdentuInstance_g.m_apfnCbResponse[uiIndex];
-        // reset callback function pointer so that caller may issue next request immediately
-        EplIdentuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
-
-        if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_IDENTRES)
-        {   // IdentResponse not received or it has invalid size
-            if (pfnCbResponse == NULL)
-            {   // response was not requested
-                goto Exit;
-            }
-            Ret = pfnCbResponse(uiNodeId, NULL);
-        }
-        else
-        {   // IdentResponse received
-            if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL)
-            {   // memory for IdentResponse must be allocated
-                EplIdentuInstance_g.m_apIdentResponse[uiIndex] = EPL_MALLOC(sizeof (tEplIdentResponse));
-                if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL)
-                {   // malloc failed
-                    if (pfnCbResponse == NULL)
-                    {   // response was not requested
-                        goto Exit;
-                    }
-                    Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_IdentResponse);
-                    goto Exit;
-                }
-            }
-            // copy IdentResponse to instance structure
-            EPL_MEMCPY(EplIdentuInstance_g.m_apIdentResponse[uiIndex], &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_IdentResponse, sizeof(tEplIdentResponse));
-            if (pfnCbResponse == NULL)
-            {   // response was not requested
-                goto Exit;
-            }
-            Ret = pfnCbResponse(uiNodeId, EplIdentuInstance_g.m_apIdentResponse[uiIndex]);
-        }
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	unsigned int uiNodeId;
+	unsigned int uiIndex;
+	tEplIdentuCbResponse pfnCbResponse;
+
+	uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
+
+	uiIndex = uiNodeId - 1;
+
+	if (uiIndex < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) {
+		// memorize pointer to callback function
+		pfnCbResponse = EplIdentuInstance_g.m_apfnCbResponse[uiIndex];
+		// reset callback function pointer so that caller may issue next request immediately
+		EplIdentuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
+
+		if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_IDENTRES) {	// IdentResponse not received or it has invalid size
+			if (pfnCbResponse == NULL) {	// response was not requested
+				goto Exit;
+			}
+			Ret = pfnCbResponse(uiNodeId, NULL);
+		} else {	// IdentResponse received
+			if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) {	// memory for IdentResponse must be allocated
+				EplIdentuInstance_g.m_apIdentResponse[uiIndex] =
+				    EPL_MALLOC(sizeof(tEplIdentResponse));
+				if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) {	// malloc failed
+					if (pfnCbResponse == NULL) {	// response was not requested
+						goto Exit;
+					}
+					Ret =
+					    pfnCbResponse(uiNodeId,
+							  &pFrameInfo_p->
+							  m_pFrame->m_Data.
+							  m_Asnd.m_Payload.
+							  m_IdentResponse);
+					goto Exit;
+				}
+			}
+			// copy IdentResponse to instance structure
+			EPL_MEMCPY(EplIdentuInstance_g.
+				   m_apIdentResponse[uiIndex],
+				   &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.
+				   m_Payload.m_IdentResponse,
+				   sizeof(tEplIdentResponse));
+			if (pfnCbResponse == NULL) {	// response was not requested
+				goto Exit;
+			}
+			Ret =
+			    pfnCbResponse(uiNodeId,
+					  EplIdentuInstance_g.
+					  m_apIdentResponse[uiIndex]);
+		}
+	}
+
+      Exit:
+	return Ret;
 }
 
 // EOF
-

+ 381 - 368
drivers/staging/epl/EplNmtCnu.c

@@ -90,10 +90,9 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    unsigned int                m_uiNodeId;
-    tEplNmtuCheckEventCallback  m_pfnCheckEventCb;
+typedef struct {
+	unsigned int m_uiNodeId;
+	tEplNmtuCheckEventCallback m_pfnCheckEventCb;
 
 } tEplNmtCnuInstance;
 
@@ -101,7 +100,7 @@ typedef struct
 // modul globale vars
 //---------------------------------------------------------------------------
 
-static tEplNmtCnuInstance   EplNmtCnuInstance_g;
+static tEplNmtCnuInstance EplNmtCnuInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
@@ -109,12 +108,10 @@ static tEplNmtCnuInstance   EplNmtCnuInstance_g;
 
 static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p);
 
-static BOOL EplNmtCnuNodeIdList(BYTE* pbNmtCommandDate_p);
+static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p);
 
 static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p);
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -140,11 +137,11 @@ static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p);
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuInit(unsigned int uiNodeId_p)
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = EplNmtCnuAddInstance(uiNodeId_p);
+	Ret = EplNmtCnuAddInstance(uiNodeId_p);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -166,25 +163,24 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuAddInstance(unsigned int uiNodeId_p)
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof (EplNmtCnuInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof(EplNmtCnuInstance_g));
 
-    // save nodeid
-    EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
+	// save nodeid
+	EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
 
-    // register callback-function for NMT-commands
+	// register callback-function for NMT-commands
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
-                                   EplNmtCnuCommandCb,
-                                   kEplDllAsndFilterLocal);
+	Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
+				       EplNmtCnuCommandCb,
+				       kEplDllAsndFilterLocal);
 #endif
 
-
-    return Ret;
+	return Ret;
 
 }
 
@@ -207,18 +203,17 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuDelInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    // deregister callback function from DLL
-    Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
-                                   NULL,
-                                   kEplDllAsndFilterNone);
+	// deregister callback function from DLL
+	Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
+				       NULL, kEplDllAsndFilterNone);
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -239,49 +234,50 @@ tEplKernel Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(
-                                    unsigned int uiNodeId_p,
-                                    tEplNmtCommand NmtCommand_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(unsigned int uiNodeId_p,
+						       tEplNmtCommand
+						       NmtCommand_p)
 {
-tEplKernel      Ret;
-tEplFrameInfo   NmtRequestFrameInfo;
-tEplFrame       NmtRequestFrame;
-
-
-    Ret = kEplSuccessful;
-
-    // build frame
-    EPL_MEMSET(&NmtRequestFrame.m_be_abDstMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abDstMac)); // set by DLL
-    EPL_MEMSET(&NmtRequestFrame.m_be_abSrcMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abSrcMac)); // set by DLL
-    AmiSetWordToBe(&NmtRequestFrame.m_be_wEtherType, EPL_C_DLL_ETHERTYPE_EPL);
-    AmiSetByteToLe(&NmtRequestFrame.m_le_bDstNodeId, (BYTE) EPL_C_ADR_MN_DEF_NODE_ID); // node id of the MN
-    AmiSetByteToLe(&NmtRequestFrame.m_le_bMessageType, (BYTE)kEplMsgTypeAsnd);
-    AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_le_bServiceId, (BYTE) kEplDllAsndNmtRequest);
-    AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bNmtCommandId,
-        (BYTE)NmtCommand_p);
-    AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bTargetNodeId,
-        (BYTE)uiNodeId_p); // target for the nmt command
-    EPL_MEMSET(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_abNmtCommandData[0], 0x00, sizeof(NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_abNmtCommandData));
-
-
-
-    // build info-structure
-    NmtRequestFrameInfo.m_NetTime.m_dwNanoSec = 0;
-    NmtRequestFrameInfo.m_NetTime.m_dwSec = 0;
-    NmtRequestFrameInfo.m_pFrame = &NmtRequestFrame;
-    NmtRequestFrameInfo.m_uiFrameSize = EPL_C_DLL_MINSIZE_NMTREQ; // sizeof(NmtRequestFrame);
-
-    // send NMT-Request
+	tEplKernel Ret;
+	tEplFrameInfo NmtRequestFrameInfo;
+	tEplFrame NmtRequestFrame;
+
+	Ret = kEplSuccessful;
+
+	// build frame
+	EPL_MEMSET(&NmtRequestFrame.m_be_abDstMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abDstMac));	// set by DLL
+	EPL_MEMSET(&NmtRequestFrame.m_be_abSrcMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abSrcMac));	// set by DLL
+	AmiSetWordToBe(&NmtRequestFrame.m_be_wEtherType,
+		       EPL_C_DLL_ETHERTYPE_EPL);
+	AmiSetByteToLe(&NmtRequestFrame.m_le_bDstNodeId, (BYTE) EPL_C_ADR_MN_DEF_NODE_ID);	// node id of the MN
+	AmiSetByteToLe(&NmtRequestFrame.m_le_bMessageType,
+		       (BYTE) kEplMsgTypeAsnd);
+	AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_le_bServiceId,
+		       (BYTE) kEplDllAsndNmtRequest);
+	AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.
+		       m_NmtRequestService.m_le_bNmtCommandId,
+		       (BYTE) NmtCommand_p);
+	AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bTargetNodeId, (BYTE) uiNodeId_p);	// target for the nmt command
+	EPL_MEMSET(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.
+		   m_le_abNmtCommandData[0], 0x00,
+		   sizeof(NmtRequestFrame.m_Data.m_Asnd.m_Payload.
+			  m_NmtRequestService.m_le_abNmtCommandData));
+
+	// build info-structure
+	NmtRequestFrameInfo.m_NetTime.m_dwNanoSec = 0;
+	NmtRequestFrameInfo.m_NetTime.m_dwSec = 0;
+	NmtRequestFrameInfo.m_pFrame = &NmtRequestFrame;
+	NmtRequestFrameInfo.m_uiFrameSize = EPL_C_DLL_MINSIZE_NMTREQ;	// sizeof(NmtRequestFrame);
+
+	// send NMT-Request
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo,    // pointer to frameinfo
-                           kEplDllAsyncReqPrioNmt); // priority
+	Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo,	// pointer to frameinfo
+				  kEplDllAsyncReqPrioNmt);	// priority
 #endif
 
-
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplNmtCnuRegisterStateChangeCb
@@ -301,17 +297,18 @@ tEplFrame       NmtRequestFrame;
 //
 //---------------------------------------------------------------------------
 
-EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuRegisterCheckEventCb(
-            tEplNmtuCheckEventCallback pfnEplNmtCheckEventCb_p)
+EPLDLLEXPORT tEplKernel PUBLIC
+EplNmtCnuRegisterCheckEventCb(tEplNmtuCheckEventCallback
+			      pfnEplNmtCheckEventCb_p)
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // save callback-function in modul global var
-    EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
+	// save callback-function in modul global var
+	EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
 
-    return Ret;
+	return Ret;
 
 }
 
@@ -321,7 +318,6 @@ tEplKernel Ret;
 //                                                                         //
 //=========================================================================//
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplNmtCnuCommandCb
@@ -341,273 +337,290 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplNmtCommand  NmtCommand;
-BOOL            fNodeIdInList;
-tEplNmtEvent    NmtEvent = kEplNmtEventNoEvent;
-
-
-    if(pFrameInfo_p == NULL)
-    {
-        Ret = kEplNmtInvalidFramePointer;
-        goto Exit;
-    }
-
-    NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
-
-    // check NMT-Command
-    switch(NmtCommand)
-    {
-
-        //------------------------------------------------------------------------
-        // plain NMT state commands
-        case kEplNmtCmdStartNode:
-        {   // send NMT-Event to state maschine kEplNmtEventStartNode
-            NmtEvent = kEplNmtEventStartNode;
-            break;
-        }
-
-        case kEplNmtCmdStopNode:
-        {   // send NMT-Event to state maschine kEplNmtEventStopNode
-            NmtEvent = kEplNmtEventStopNode;
-            break;
-        }
-
-        case kEplNmtCmdEnterPreOperational2:
-        {   // send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
-            NmtEvent = kEplNmtEventEnterPreOperational2;
-            break;
-        }
-
-        case kEplNmtCmdEnableReadyToOperate:
-        {   // send NMT-Event to state maschine kEplNmtEventEnableReadyToOperate
-            NmtEvent = kEplNmtEventEnableReadyToOperate;
-            break;
-        }
-
-        case kEplNmtCmdResetNode:
-        {   // send NMT-Event to state maschine kEplNmtEventResetNode
-            NmtEvent = kEplNmtEventResetNode;
-            break;
-        }
-
-        case kEplNmtCmdResetCommunication:
-        {   // send NMT-Event to state maschine kEplNmtEventResetCom
-            NmtEvent = kEplNmtEventResetCom;
-            break;
-        }
-
-        case kEplNmtCmdResetConfiguration:
-        {   // send NMT-Event to state maschine kEplNmtEventResetConfig
-            NmtEvent = kEplNmtEventResetConfig;
-            break;
-        }
-
-        case kEplNmtCmdSwReset:
-        {   // send NMT-Event to state maschine kEplNmtEventSwReset
-            NmtEvent = kEplNmtEventSwReset;
-            break;
-        }
-
-        //------------------------------------------------------------------------
-        // extended NMT state commands
-
-        case kEplNmtCmdStartNodeEx:
-        {
-            // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&(pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]));
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventStartNode;
-            }
-            break;
-        }
-
-        case kEplNmtCmdStopNodeEx:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventStopNode;
-            }
-            break;
-        }
-
-        case kEplNmtCmdEnterPreOperational2Ex:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventEnterPreOperational2;
-            }
-            break;
-        }
-
-        case kEplNmtCmdEnableReadyToOperateEx:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventEnableReadyToOperate;
-            }
-            break;
-        }
-
-        case kEplNmtCmdResetNodeEx:
-        {// check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventResetNode;
-            }
-            break;
-        }
-
-        case kEplNmtCmdResetCommunicationEx:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventResetCom;
-            }
-            break;
-        }
-
-        case kEplNmtCmdResetConfigurationEx:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventResetConfig;
-            }
-            break;
-        }
-
-        case kEplNmtCmdSwResetEx:
-        {   // check if own nodeid is in EPL node list
-            fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
-            if(fNodeIdInList != FALSE)
-            {   // own nodeid in list
-                // send event to process command
-                NmtEvent = kEplNmtEventSwReset;
-            }
-            break;
-        }
-
-        //------------------------------------------------------------------------
-        // NMT managing commands
-
-        // TODO: add functions to process managing command (optional)
-
-        case kEplNmtCmdNetHostNameSet:
-        {
-            break;
-        }
-
-        case kEplNmtCmdFlushArpEntry:
-        {
-            break;
-        }
-
-        //------------------------------------------------------------------------
-        // NMT info services
-
-        // TODO: forward event with infos to the application (optional)
-
-        case kEplNmtCmdPublishConfiguredCN:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishActiveCN:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishPreOperational1:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishPreOperational2:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishReadyToOperate:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishOperational:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishStopped:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishEmergencyNew:
-        {
-            break;
-        }
-
-        case kEplNmtCmdPublishTime:
-        {
-            break;
-        }
-
-        //-----------------------------------------------------------------------
-        // error from MN
-        // -> requested command not supported by MN
-        case kEplNmtCmdInvalidService:
-        {
-
-            // TODO: errorevent to application
-            break;
-        }
-
-        //------------------------------------------------------------------------
-        // default
-        default:
-        {
-            Ret = kEplNmtUnknownCommand;
-            goto Exit;
-        }
-
-    }// end of switch(NmtCommand)
-
-    if (NmtEvent != kEplNmtEventNoEvent)
-    {
-        if (EplNmtCnuInstance_g.m_pfnCheckEventCb != NULL)
-        {
-            Ret = EplNmtCnuInstance_g.m_pfnCheckEventCb(NmtEvent);
-            if (Ret == kEplReject)
-            {
-                Ret = kEplSuccessful;
-                goto Exit;
-            }
-            else if (Ret != kEplSuccessful)
-            {
-                goto Exit;
-            }
-        }
+	tEplKernel Ret = kEplSuccessful;
+	tEplNmtCommand NmtCommand;
+	BOOL fNodeIdInList;
+	tEplNmtEvent NmtEvent = kEplNmtEventNoEvent;
+
+	if (pFrameInfo_p == NULL) {
+		Ret = kEplNmtInvalidFramePointer;
+		goto Exit;
+	}
+
+	NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
+
+	// check NMT-Command
+	switch (NmtCommand) {
+
+		//------------------------------------------------------------------------
+		// plain NMT state commands
+	case kEplNmtCmdStartNode:
+		{		// send NMT-Event to state maschine kEplNmtEventStartNode
+			NmtEvent = kEplNmtEventStartNode;
+			break;
+		}
+
+	case kEplNmtCmdStopNode:
+		{		// send NMT-Event to state maschine kEplNmtEventStopNode
+			NmtEvent = kEplNmtEventStopNode;
+			break;
+		}
+
+	case kEplNmtCmdEnterPreOperational2:
+		{		// send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
+			NmtEvent = kEplNmtEventEnterPreOperational2;
+			break;
+		}
+
+	case kEplNmtCmdEnableReadyToOperate:
+		{		// send NMT-Event to state maschine kEplNmtEventEnableReadyToOperate
+			NmtEvent = kEplNmtEventEnableReadyToOperate;
+			break;
+		}
+
+	case kEplNmtCmdResetNode:
+		{		// send NMT-Event to state maschine kEplNmtEventResetNode
+			NmtEvent = kEplNmtEventResetNode;
+			break;
+		}
+
+	case kEplNmtCmdResetCommunication:
+		{		// send NMT-Event to state maschine kEplNmtEventResetCom
+			NmtEvent = kEplNmtEventResetCom;
+			break;
+		}
+
+	case kEplNmtCmdResetConfiguration:
+		{		// send NMT-Event to state maschine kEplNmtEventResetConfig
+			NmtEvent = kEplNmtEventResetConfig;
+			break;
+		}
+
+	case kEplNmtCmdSwReset:
+		{		// send NMT-Event to state maschine kEplNmtEventSwReset
+			NmtEvent = kEplNmtEventSwReset;
+			break;
+		}
+
+		//------------------------------------------------------------------------
+		// extended NMT state commands
+
+	case kEplNmtCmdStartNodeEx:
+		{
+			// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&
+						(pFrameInfo_p->m_pFrame->m_Data.
+						 m_Asnd.m_Payload.
+						 m_NmtCommandService.
+						 m_le_abNmtCommandData[0]));
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventStartNode;
+			}
+			break;
+		}
+
+	case kEplNmtCmdStopNodeEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventStopNode;
+			}
+			break;
+		}
+
+	case kEplNmtCmdEnterPreOperational2Ex:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventEnterPreOperational2;
+			}
+			break;
+		}
+
+	case kEplNmtCmdEnableReadyToOperateEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventEnableReadyToOperate;
+			}
+			break;
+		}
+
+	case kEplNmtCmdResetNodeEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventResetNode;
+			}
+			break;
+		}
+
+	case kEplNmtCmdResetCommunicationEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventResetCom;
+			}
+			break;
+		}
+
+	case kEplNmtCmdResetConfigurationEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventResetConfig;
+			}
+			break;
+		}
+
+	case kEplNmtCmdSwResetEx:
+		{		// check if own nodeid is in EPL node list
+			fNodeIdInList =
+			    EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
+						m_Asnd.m_Payload.
+						m_NmtCommandService.
+						m_le_abNmtCommandData[0]);
+			if (fNodeIdInList != FALSE) {	// own nodeid in list
+				// send event to process command
+				NmtEvent = kEplNmtEventSwReset;
+			}
+			break;
+		}
+
+		//------------------------------------------------------------------------
+		// NMT managing commands
+
+		// TODO: add functions to process managing command (optional)
+
+	case kEplNmtCmdNetHostNameSet:
+		{
+			break;
+		}
+
+	case kEplNmtCmdFlushArpEntry:
+		{
+			break;
+		}
+
+		//------------------------------------------------------------------------
+		// NMT info services
+
+		// TODO: forward event with infos to the application (optional)
+
+	case kEplNmtCmdPublishConfiguredCN:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishActiveCN:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishPreOperational1:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishPreOperational2:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishReadyToOperate:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishOperational:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishStopped:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishEmergencyNew:
+		{
+			break;
+		}
+
+	case kEplNmtCmdPublishTime:
+		{
+			break;
+		}
+
+		//-----------------------------------------------------------------------
+		// error from MN
+		// -> requested command not supported by MN
+	case kEplNmtCmdInvalidService:
+		{
+
+			// TODO: errorevent to application
+			break;
+		}
+
+		//------------------------------------------------------------------------
+		// default
+	default:
+		{
+			Ret = kEplNmtUnknownCommand;
+			goto Exit;
+		}
+
+	}			// end of switch(NmtCommand)
+
+	if (NmtEvent != kEplNmtEventNoEvent) {
+		if (EplNmtCnuInstance_g.m_pfnCheckEventCb != NULL) {
+			Ret = EplNmtCnuInstance_g.m_pfnCheckEventCb(NmtEvent);
+			if (Ret == kEplReject) {
+				Ret = kEplSuccessful;
+				goto Exit;
+			} else if (Ret != kEplSuccessful) {
+				goto Exit;
+			}
+		}
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
-        Ret = EplNmtuNmtEvent(NmtEvent);
+		Ret = EplNmtuNmtEvent(NmtEvent);
 #endif
-    }
+	}
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
@@ -631,14 +644,18 @@ Exit:
 //---------------------------------------------------------------------------
 static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p)
 {
-tEplNmtCommand          NmtCommand;
-tEplNmtCommandService*  pNmtCommandService;
+	tEplNmtCommand NmtCommand;
+	tEplNmtCommandService *pNmtCommandService;
 
-    pNmtCommandService = &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService;
+	pNmtCommandService =
+	    &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.
+	    m_NmtCommandService;
 
-    NmtCommand = (tEplNmtCommand)AmiGetByteFromLe(&pNmtCommandService->m_le_bNmtCommandId);
+	NmtCommand =
+	    (tEplNmtCommand) AmiGetByteFromLe(&pNmtCommandService->
+					      m_le_bNmtCommandId);
 
-    return NmtCommand;
+	return NmtCommand;
 }
 
 //---------------------------------------------------------------------------
@@ -659,33 +676,29 @@ tEplNmtCommandService*  pNmtCommandService;
 // State:
 //
 //---------------------------------------------------------------------------
-static BOOL EplNmtCnuNodeIdList(BYTE* pbNmtCommandDate_p)
+static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p)
 {
-BOOL            fNodeIdInList;
-unsigned int    uiByteOffset;
-BYTE            bBitOffset;
-BYTE            bNodeListByte;
-
-    // get byte-offset of the own nodeid in NodeIdList
-    // devide though 8
-    uiByteOffset = (unsigned int)(EplNmtCnuInstance_g.m_uiNodeId >> 3);
-    // get bitoffset
-    bBitOffset = (BYTE) EplNmtCnuInstance_g.m_uiNodeId % 8;
-
-    bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
-    if((bNodeListByte & bBitOffset) == 0)
-    {
-        fNodeIdInList = FALSE;
-    }
-    else
-    {
-        fNodeIdInList = TRUE;
-    }
-
-return  fNodeIdInList;
+	BOOL fNodeIdInList;
+	unsigned int uiByteOffset;
+	BYTE bBitOffset;
+	BYTE bNodeListByte;
+
+	// get byte-offset of the own nodeid in NodeIdList
+	// devide though 8
+	uiByteOffset = (unsigned int)(EplNmtCnuInstance_g.m_uiNodeId >> 3);
+	// get bitoffset
+	bBitOffset = (BYTE) EplNmtCnuInstance_g.m_uiNodeId % 8;
+
+	bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
+	if ((bNodeListByte & bBitOffset) == 0) {
+		fNodeIdInList = FALSE;
+	} else {
+		fNodeIdInList = TRUE;
+	}
+
+	return fNodeIdInList;
 }
 
 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
 
 // EOF
-

File diff suppressed because it is too large
+ 479 - 505
drivers/staging/epl/EplNmtMnu.c


File diff suppressed because it is too large
+ 1553 - 1457
drivers/staging/epl/EplNmtk.c


+ 0 - 8
drivers/staging/epl/EplNmtkCal.c

@@ -71,11 +71,9 @@
 
 #include "kernel/EplNmtkCal.h"
 
-
 // TODO: init function needed to prepare EplNmtkGetNmtState for
 //       io-controll-call from EplNmtuCal-Modul
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -100,8 +98,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -126,7 +122,6 @@
 //
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -151,7 +146,4 @@
 //
 //---------------------------------------------------------------------------
 
-
-
 // EOF
-

+ 375 - 348
drivers/staging/epl/EplNmtu.c

@@ -68,7 +68,6 @@
 
 ****************************************************************************/
 
-
 #include "EplInc.h"
 #include "user/EplNmtu.h"
 #include "user/EplObdu.h"
@@ -94,10 +93,9 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    tEplNmtuStateChangeCallback     m_pfnNmtChangeCb;
-    tEplTimerHdl                    m_TimerHdl;
+typedef struct {
+	tEplNmtuStateChangeCallback m_pfnNmtChangeCb;
+	tEplTimerHdl m_TimerHdl;
 
 } tEplNmtuInstance;
 
@@ -136,11 +134,11 @@ static tEplNmtuInstance EplNmtuInstance_g;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtuInit()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = EplNmtuAddInstance();
+	Ret = EplNmtuAddInstance();
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -162,13 +160,13 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtuAddInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
+	EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
 
-    return Ret;
+	return Ret;
 
 }
 
@@ -191,16 +189,16 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtuDelInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
+	EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
 
-    // delete timer
-    Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
+	// delete timer
+	Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
 
-    return Ret;
+	return Ret;
 
 }
 
@@ -223,20 +221,19 @@ tEplKernel Ret;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplNmtuNmtEvent(tEplNmtEvent NmtEvent_p)
 {
-tEplKernel  Ret;
-tEplEvent   Event;
-
-    Event.m_EventSink = kEplEventSinkNmtk;
-    Event.m_NetTime.m_dwNanoSec = 0;
-    Event.m_NetTime.m_dwSec = 0;
-    Event.m_EventType = kEplEventTypeNmtEvent;
-    Event.m_pArg = &NmtEvent_p;
-    Event.m_uiSize = sizeof(NmtEvent_p);
+	tEplKernel Ret;
+	tEplEvent Event;
 
-    Ret = EplEventuPost(&Event);
+	Event.m_EventSink = kEplEventSinkNmtk;
+	Event.m_NetTime.m_dwNanoSec = 0;
+	Event.m_NetTime.m_dwSec = 0;
+	Event.m_EventType = kEplEventTypeNmtEvent;
+	Event.m_pArg = &NmtEvent_p;
+	Event.m_uiSize = sizeof(NmtEvent_p);
 
+	Ret = EplEventuPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -258,16 +255,16 @@ tEplEvent   Event;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplNmtState PUBLIC EplNmtuGetNmtState()
 {
-tEplNmtState    NmtState;
+	tEplNmtState NmtState;
 
-    // $$$ call function of communication abstraction layer
+	// $$$ call function of communication abstraction layer
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
-    NmtState = EplNmtkGetNmtState();
+	NmtState = EplNmtkGetNmtState();
 #else
-    NmtState = 0;
+	NmtState = 0;
 #endif
 
-    return NmtState;
+	return NmtState;
 }
 
 //---------------------------------------------------------------------------
@@ -287,335 +284,366 @@ tEplNmtState    NmtState;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplNmtuProcessEvent(
-            tEplEvent* pEplEvent_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplNmtuProcessEvent(tEplEvent * pEplEvent_p)
 {
-tEplKernel  Ret;
-
-    Ret = kEplSuccessful;
-
-    // process event
-    switch(pEplEvent_p->m_EventType)
-    {
-        // state change of NMT-Module
-        case kEplEventTypeNmtStateChange:
-        {
-        tEplEventNmtStateChange* pNmtStateChange;
-
-            // delete timer
-            Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
-
-            pNmtStateChange = (tEplEventNmtStateChange*)pEplEvent_p->m_pArg;
-
-            // call cb-functions to inform higher layer
-            if(EplNmtuInstance_g.m_pfnNmtChangeCb != NULL)
-            {
-                Ret = EplNmtuInstance_g.m_pfnNmtChangeCb(*pNmtStateChange);
-            }
-
-            if (Ret == kEplSuccessful)
-            {   // everything is OK, so switch to next state if necessary
-                switch (pNmtStateChange->m_NewNmtState)
-                {
-                    // EPL stack is not running
-                    case kEplNmtGsOff:
-                        break;
-
-                    // first init of the hardware
-                    case kEplNmtGsInitialising:
-                    {
-                        Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetApp);
-                        break;
-                    }
-
-                    // init of the manufacturer-specific profile area and the
-                    // standardised device profile area
-                    case kEplNmtGsResetApplication:
-                    {
-                        Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetCom);
-                        break;
-                    }
-
-                    // init of the communication profile area
-                    case kEplNmtGsResetCommunication:
-                    {
-                        Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetConfig);
-                        break;
-                    }
-
-                    // build the configuration with infos from OD
-                    case kEplNmtGsResetConfiguration:
-                    {
-                    unsigned int uiNodeId;
-
-                        // get node ID from OD
+	tEplKernel Ret;
+
+	Ret = kEplSuccessful;
+
+	// process event
+	switch (pEplEvent_p->m_EventType) {
+		// state change of NMT-Module
+	case kEplEventTypeNmtStateChange:
+		{
+			tEplEventNmtStateChange *pNmtStateChange;
+
+			// delete timer
+			Ret =
+			    EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
+
+			pNmtStateChange =
+			    (tEplEventNmtStateChange *) pEplEvent_p->m_pArg;
+
+			// call cb-functions to inform higher layer
+			if (EplNmtuInstance_g.m_pfnNmtChangeCb != NULL) {
+				Ret =
+				    EplNmtuInstance_g.
+				    m_pfnNmtChangeCb(*pNmtStateChange);
+			}
+
+			if (Ret == kEplSuccessful) {	// everything is OK, so switch to next state if necessary
+				switch (pNmtStateChange->m_NewNmtState) {
+					// EPL stack is not running
+				case kEplNmtGsOff:
+					break;
+
+					// first init of the hardware
+				case kEplNmtGsInitialising:
+					{
+						Ret =
+						    EplNmtuNmtEvent
+						    (kEplNmtEventEnterResetApp);
+						break;
+					}
+
+					// init of the manufacturer-specific profile area and the
+					// standardised device profile area
+				case kEplNmtGsResetApplication:
+					{
+						Ret =
+						    EplNmtuNmtEvent
+						    (kEplNmtEventEnterResetCom);
+						break;
+					}
+
+					// init of the communication profile area
+				case kEplNmtGsResetCommunication:
+					{
+						Ret =
+						    EplNmtuNmtEvent
+						    (kEplNmtEventEnterResetConfig);
+						break;
+					}
+
+					// build the configuration with infos from OD
+				case kEplNmtGsResetConfiguration:
+					{
+						unsigned int uiNodeId;
+
+						// get node ID from OD
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
-                        uiNodeId = EplObduGetNodeId(EPL_MCO_PTR_INSTANCE_PTR);
+						uiNodeId =
+						    EplObduGetNodeId
+						    (EPL_MCO_PTR_INSTANCE_PTR);
 #else
-                        uiNodeId = 0;
+						uiNodeId = 0;
 #endif
-                        //check node ID if not should be master or slave
-                        if (uiNodeId == EPL_C_ADR_MN_DEF_NODE_ID)
-                        {   // node shall be MN
+						//check node ID if not should be master or slave
+						if (uiNodeId == EPL_C_ADR_MN_DEF_NODE_ID) {	// node shall be MN
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-                            Ret = EplNmtuNmtEvent(kEplNmtEventEnterMsNotActive);
+							Ret =
+							    EplNmtuNmtEvent
+							    (kEplNmtEventEnterMsNotActive);
 #else
-                            TRACE0("EplNmtuProcess(): no MN functionality implemented\n");
+							TRACE0
+							    ("EplNmtuProcess(): no MN functionality implemented\n");
 #endif
-                        }
-                        else
-                        {   // node shall be CN
-                            Ret = EplNmtuNmtEvent(kEplNmtEventEnterCsNotActive);
-                        }
-                        break;
-                    }
-
-                    //-----------------------------------------------------------
-                    // CN part of the state machine
-
-                    // node listens for EPL-Frames and check timeout
-                    case kEplNmtCsNotActive:
-                    {
-                    DWORD           dwBuffer;
-                    tEplObdSize     ObdSize;
-                    tEplTimerArg    TimerArg;
-
-                        // create timer to switch automatically to BasicEthernet if no MN available in network
-
-                        // read NMT_CNBasicEthernetTimerout_U32 from OD
-                        ObdSize = sizeof(dwBuffer);
+						} else {	// node shall be CN
+							Ret =
+							    EplNmtuNmtEvent
+							    (kEplNmtEventEnterCsNotActive);
+						}
+						break;
+					}
+
+					//-----------------------------------------------------------
+					// CN part of the state machine
+
+					// node listens for EPL-Frames and check timeout
+				case kEplNmtCsNotActive:
+					{
+						DWORD dwBuffer;
+						tEplObdSize ObdSize;
+						tEplTimerArg TimerArg;
+
+						// create timer to switch automatically to BasicEthernet if no MN available in network
+
+						// read NMT_CNBasicEthernetTimerout_U32 from OD
+						ObdSize = sizeof(dwBuffer);
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
-                        Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
-                                                0x1F99,
-                                                0x00,
-                                                &dwBuffer,
-                                                &ObdSize);
+						Ret =
+						    EplObduReadEntry
+						    (EPL_MCO_PTR_INSTANCE_PTR_
+						     0x1F99, 0x00, &dwBuffer,
+						     &ObdSize);
 #else
-                        Ret = kEplObdIndexNotExist;
+						Ret = kEplObdIndexNotExist;
 #endif
-                        if(Ret != kEplSuccessful)
-                        {
-                            break;
-                        }
-                        if (dwBuffer != 0)
-                        {   // BasicEthernet is enabled
-                            // convert us into ms
-                            dwBuffer = dwBuffer / 1000;
-                            if (dwBuffer == 0)
-                            {   // timer was below one ms
-                                // set one ms
-                                dwBuffer = 1;
-                            }
-                            TimerArg.m_EventSink = kEplEventSinkNmtk;
-                            TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerBasicEthernet;
-                            Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
-                            // potential error is forwarded to event queue which generates error event
-                        }
-                        break;
-                    }
-
-                    // node processes only async frames
-                    case kEplNmtCsPreOperational1:
-                    {
-                        break;
-                    }
-
-                    // node processes isochronous and asynchronous frames
-                    case kEplNmtCsPreOperational2:
-                    {
-                        Ret = EplNmtuNmtEvent(kEplNmtEventEnterReadyToOperate);
-                        break;
-                    }
-
-                    // node should be configured und application is ready
-                    case kEplNmtCsReadyToOperate:
-                    {
-                        break;
-                    }
-
-                    // normal work state
-                    case kEplNmtCsOperational:
-                    {
-                        break;
-                    }
-
-                    // node stopped by MN
-                    // -> only process asynchronous frames
-                    case kEplNmtCsStopped:
-                    {
-                        break;
-                    }
-
-                    // no EPL cycle
-                    // -> normal ethernet communication
-                    case kEplNmtCsBasicEthernet:
-                    {
-                        break;
-                    }
-
-                    //-----------------------------------------------------------
-                    // MN part of the state machine
+						if (Ret != kEplSuccessful) {
+							break;
+						}
+						if (dwBuffer != 0) {	// BasicEthernet is enabled
+							// convert us into ms
+							dwBuffer =
+							    dwBuffer / 1000;
+							if (dwBuffer == 0) {	// timer was below one ms
+								// set one ms
+								dwBuffer = 1;
+							}
+							TimerArg.m_EventSink =
+							    kEplEventSinkNmtk;
+							TimerArg.m_ulArg =
+							    (unsigned long)
+							    kEplNmtEventTimerBasicEthernet;
+							Ret =
+							    EplTimeruModifyTimerMs
+							    (&EplNmtuInstance_g.
+							     m_TimerHdl,
+							     (unsigned long)
+							     dwBuffer,
+							     TimerArg);
+							// potential error is forwarded to event queue which generates error event
+						}
+						break;
+					}
+
+					// node processes only async frames
+				case kEplNmtCsPreOperational1:
+					{
+						break;
+					}
+
+					// node processes isochronous and asynchronous frames
+				case kEplNmtCsPreOperational2:
+					{
+						Ret =
+						    EplNmtuNmtEvent
+						    (kEplNmtEventEnterReadyToOperate);
+						break;
+					}
+
+					// node should be configured und application is ready
+				case kEplNmtCsReadyToOperate:
+					{
+						break;
+					}
+
+					// normal work state
+				case kEplNmtCsOperational:
+					{
+						break;
+					}
+
+					// node stopped by MN
+					// -> only process asynchronous frames
+				case kEplNmtCsStopped:
+					{
+						break;
+					}
+
+					// no EPL cycle
+					// -> normal ethernet communication
+				case kEplNmtCsBasicEthernet:
+					{
+						break;
+					}
+
+					//-----------------------------------------------------------
+					// MN part of the state machine
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-                    // node listens for EPL-Frames and check timeout
-                    case kEplNmtMsNotActive:
-                    {
-                    DWORD           dwBuffer;
-                    tEplObdSize     ObdSize;
-                    tEplTimerArg    TimerArg;
-
-                        // create timer to switch automatically to BasicEthernet/PreOp1 if no other MN active in network
-
-                        // check NMT_StartUp_U32.Bit13
-                        // read NMT_StartUp_U32 from OD
-                        ObdSize = sizeof(dwBuffer);
+					// node listens for EPL-Frames and check timeout
+				case kEplNmtMsNotActive:
+					{
+						DWORD dwBuffer;
+						tEplObdSize ObdSize;
+						tEplTimerArg TimerArg;
+
+						// create timer to switch automatically to BasicEthernet/PreOp1 if no other MN active in network
+
+						// check NMT_StartUp_U32.Bit13
+						// read NMT_StartUp_U32 from OD
+						ObdSize = sizeof(dwBuffer);
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
-                        Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
-                                                0x1F80,
-                                                0x00,
-                                                &dwBuffer,
-                                                &ObdSize);
+						Ret =
+						    EplObduReadEntry
+						    (EPL_MCO_PTR_INSTANCE_PTR_
+						     0x1F80, 0x00, &dwBuffer,
+						     &ObdSize);
 #else
-                        Ret = kEplObdIndexNotExist;
+						Ret = kEplObdIndexNotExist;
 #endif
-                        if(Ret != kEplSuccessful)
-                        {
-                            break;
-                        }
-
-                        if((dwBuffer & EPL_NMTST_BASICETHERNET) == 0)
-                        {   // NMT_StartUp_U32.Bit13 == 0
-                            // new state PreOperational1
-                            TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerMsPreOp1;
-                        }
-                        else
-                        {   // NMT_StartUp_U32.Bit13 == 1
-                            // new state BasicEthernet
-                            TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerBasicEthernet;
-                        }
-
-                        // read NMT_BootTime_REC.MNWaitNotAct_U32 from OD
-                        ObdSize = sizeof(dwBuffer);
+						if (Ret != kEplSuccessful) {
+							break;
+						}
+
+						if ((dwBuffer & EPL_NMTST_BASICETHERNET) == 0) {	// NMT_StartUp_U32.Bit13 == 0
+							// new state PreOperational1
+							TimerArg.m_ulArg =
+							    (unsigned long)
+							    kEplNmtEventTimerMsPreOp1;
+						} else {	// NMT_StartUp_U32.Bit13 == 1
+							// new state BasicEthernet
+							TimerArg.m_ulArg =
+							    (unsigned long)
+							    kEplNmtEventTimerBasicEthernet;
+						}
+
+						// read NMT_BootTime_REC.MNWaitNotAct_U32 from OD
+						ObdSize = sizeof(dwBuffer);
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
-                        Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
-                                                0x1F89,
-                                                0x01,
-                                                &dwBuffer,
-                                                &ObdSize);
+						Ret =
+						    EplObduReadEntry
+						    (EPL_MCO_PTR_INSTANCE_PTR_
+						     0x1F89, 0x01, &dwBuffer,
+						     &ObdSize);
 #else
-                        Ret = kEplObdIndexNotExist;
+						Ret = kEplObdIndexNotExist;
 #endif
-                        if(Ret != kEplSuccessful)
-                        {
-                            break;
-                        }
-                        // convert us into ms
-                        dwBuffer = dwBuffer / 1000;
-                        if (dwBuffer == 0)
-                        {   // timer was below one ms
-                            // set one ms
-                            dwBuffer = 1;
-                        }
-                        TimerArg.m_EventSink = kEplEventSinkNmtk;
-                        Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
-                        // potential error is forwarded to event queue which generates error event
-                        break;
-                    }
-
-                    // node processes only async frames
-                    case kEplNmtMsPreOperational1:
-                    {
-                    DWORD           dwBuffer = 0;
-                    tEplObdSize     ObdSize;
-                    tEplTimerArg    TimerArg;
-
-                        // create timer to switch automatically to PreOp2 if MN identified all mandatory CNs
-
-                        // read NMT_BootTime_REC.MNWaitPreOp1_U32 from OD
-                        ObdSize = sizeof(dwBuffer);
+						if (Ret != kEplSuccessful) {
+							break;
+						}
+						// convert us into ms
+						dwBuffer = dwBuffer / 1000;
+						if (dwBuffer == 0) {	// timer was below one ms
+							// set one ms
+							dwBuffer = 1;
+						}
+						TimerArg.m_EventSink =
+						    kEplEventSinkNmtk;
+						Ret =
+						    EplTimeruModifyTimerMs
+						    (&EplNmtuInstance_g.
+						     m_TimerHdl,
+						     (unsigned long)dwBuffer,
+						     TimerArg);
+						// potential error is forwarded to event queue which generates error event
+						break;
+					}
+
+					// node processes only async frames
+				case kEplNmtMsPreOperational1:
+					{
+						DWORD dwBuffer = 0;
+						tEplObdSize ObdSize;
+						tEplTimerArg TimerArg;
+
+						// create timer to switch automatically to PreOp2 if MN identified all mandatory CNs
+
+						// read NMT_BootTime_REC.MNWaitPreOp1_U32 from OD
+						ObdSize = sizeof(dwBuffer);
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
-                        Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
-                                                0x1F89,
-                                                0x03,
-                                                &dwBuffer,
-                                                &ObdSize);
-                        if(Ret != kEplSuccessful)
-                        {
-                            // ignore error, because this timeout is optional
-                            dwBuffer = 0;
-                        }
+						Ret =
+						    EplObduReadEntry
+						    (EPL_MCO_PTR_INSTANCE_PTR_
+						     0x1F89, 0x03, &dwBuffer,
+						     &ObdSize);
+						if (Ret != kEplSuccessful) {
+							// ignore error, because this timeout is optional
+							dwBuffer = 0;
+						}
 #endif
-                        if (dwBuffer == 0)
-                        {   // delay is deactivated
-                            // immediately post timer event
-                            Ret = EplNmtuNmtEvent(kEplNmtEventTimerMsPreOp2);
-                            break;
-                        }
-                        // convert us into ms
-                        dwBuffer = dwBuffer / 1000;
-                        if (dwBuffer == 0)
-                        {   // timer was below one ms
-                            // set one ms
-                            dwBuffer = 1;
-                        }
-                        TimerArg.m_EventSink = kEplEventSinkNmtk;
-                        TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerMsPreOp2;
-                        Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
-                        // potential error is forwarded to event queue which generates error event
-                        break;
-                    }
-
-                    // node processes isochronous and asynchronous frames
-                    case kEplNmtMsPreOperational2:
-                    {
-                        break;
-                    }
-
-                    // node should be configured und application is ready
-                    case kEplNmtMsReadyToOperate:
-                    {
-                        break;
-                    }
-
-                    // normal work state
-                    case kEplNmtMsOperational:
-                    {
-                        break;
-                    }
-
-                    // no EPL cycle
-                    // -> normal ethernet communication
-                    case kEplNmtMsBasicEthernet:
-                    {
-                        break;
-                    }
+						if (dwBuffer == 0) {	// delay is deactivated
+							// immediately post timer event
+							Ret =
+							    EplNmtuNmtEvent
+							    (kEplNmtEventTimerMsPreOp2);
+							break;
+						}
+						// convert us into ms
+						dwBuffer = dwBuffer / 1000;
+						if (dwBuffer == 0) {	// timer was below one ms
+							// set one ms
+							dwBuffer = 1;
+						}
+						TimerArg.m_EventSink =
+						    kEplEventSinkNmtk;
+						TimerArg.m_ulArg =
+						    (unsigned long)
+						    kEplNmtEventTimerMsPreOp2;
+						Ret =
+						    EplTimeruModifyTimerMs
+						    (&EplNmtuInstance_g.
+						     m_TimerHdl,
+						     (unsigned long)dwBuffer,
+						     TimerArg);
+						// potential error is forwarded to event queue which generates error event
+						break;
+					}
+
+					// node processes isochronous and asynchronous frames
+				case kEplNmtMsPreOperational2:
+					{
+						break;
+					}
+
+					// node should be configured und application is ready
+				case kEplNmtMsReadyToOperate:
+					{
+						break;
+					}
+
+					// normal work state
+				case kEplNmtMsOperational:
+					{
+						break;
+					}
+
+					// no EPL cycle
+					// -> normal ethernet communication
+				case kEplNmtMsBasicEthernet:
+					{
+						break;
+					}
 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
 
-                    default:
-                    {
-                        TRACE1("EplNmtuProcess(): unhandled NMT state 0x%X\n", pNmtStateChange->m_NewNmtState);
-                    }
-                }
-            }
-            else if (Ret == kEplReject)
-            {   // application wants to change NMT state itself
-                // it's OK
-                Ret = kEplSuccessful;
-            }
-
-            EPL_DBGLVL_NMTU_TRACE0("EplNmtuProcessEvent(): NMT-State-Maschine announce change of NMT State\n");
-            break;
-        }
-
-        default:
-        {
-            Ret = kEplNmtInvalidEvent;
-        }
-
-    }
+				default:
+					{
+						TRACE1
+						    ("EplNmtuProcess(): unhandled NMT state 0x%X\n",
+						     pNmtStateChange->
+						     m_NewNmtState);
+					}
+				}
+			} else if (Ret == kEplReject) {	// application wants to change NMT state itself
+				// it's OK
+				Ret = kEplSuccessful;
+			}
+
+			EPL_DBGLVL_NMTU_TRACE0
+			    ("EplNmtuProcessEvent(): NMT-State-Maschine announce change of NMT State\n");
+			break;
+		}
+
+	default:
+		{
+			Ret = kEplNmtInvalidEvent;
+		}
+
+	}
 
 //Exit:
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -636,17 +664,18 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplNmtuRegisterStateChangeCb(
-            tEplNmtuStateChangeCallback pfnEplNmtStateChangeCb_p)
+EPLDLLEXPORT tEplKernel PUBLIC
+EplNmtuRegisterStateChangeCb(tEplNmtuStateChangeCallback
+			     pfnEplNmtStateChangeCb_p)
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // save callback-function in modul global var
-    EplNmtuInstance_g.m_pfnNmtChangeCb = pfnEplNmtStateChangeCb_p;
+	// save callback-function in modul global var
+	EplNmtuInstance_g.m_pfnNmtChangeCb = pfnEplNmtStateChangeCb_p;
 
-    return Ret;
+	return Ret;
 
 }
 
@@ -676,6 +705,4 @@ tEplKernel Ret;
 
 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
 
-
 // EOF
-

+ 5 - 11
drivers/staging/epl/EplNmtuCal.c

@@ -95,9 +95,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -124,14 +121,14 @@
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplNmtState PUBLIC EplNmtkCalGetNmtState()
 {
-tEplNmtState NmtState;
-    // for test direkt call for EplNmtkGetNmtState()
+	tEplNmtState NmtState;
+	// for test direkt call for EplNmtkGetNmtState()
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
-    NmtState = EplNmtkGetNmtState();
+	NmtState = EplNmtkGetNmtState();
 #else
-    NmtState = 0;
+	NmtState = 0;
 #endif
-return NmtState;
+	return NmtState;
 }
 
 //=========================================================================//
@@ -158,7 +155,4 @@ return NmtState;
 //
 //---------------------------------------------------------------------------
 
-
-
 // EOF
-

File diff suppressed because it is too large
+ 380 - 450
drivers/staging/epl/EplObd.c


+ 0 - 7
drivers/staging/epl/EplObdkCal.c

@@ -96,9 +96,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -123,7 +120,6 @@
 //
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -148,7 +144,4 @@
 //
 //---------------------------------------------------------------------------
 
-
-
 // EOF
-

+ 82 - 77
drivers/staging/epl/EplObdu.c

@@ -97,8 +97,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -123,19 +121,18 @@
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry (unsigned int  uiIndex_p,
-                                                unsigned int  uiSubIndex_p,
-                                                void * pSrcData_p,
-                                                tEplObdSize   Size_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry(unsigned int uiIndex_p,
+						 unsigned int uiSubIndex_p,
+						 void *pSrcData_p,
+						 tEplObdSize Size_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
+	Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplObduReadEntry()
@@ -156,19 +153,18 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry (unsigned int        uiIndex_p,
-                                            unsigned int        uiSubIndex_p,
-                                            void *       pDstData_p,
-                                            tEplObdSize* pSize_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry(unsigned int uiIndex_p,
+						unsigned int uiSubIndex_p,
+						void *pDstData_p,
+						tEplObdSize * pSize_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
+	Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplObdAccessOdPart()
@@ -183,14 +179,14 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart (tEplObdPart ObdPart_p,
-                                                    tEplObdDir Direction_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart(tEplObdPart ObdPart_p,
+						   tEplObdDir Direction_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
+	Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -206,13 +202,13 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar (tEplVarParam MEM* pVarParam_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar(tEplVarParam MEM * pVarParam_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalDefineVar(pVarParam_p);
+	Ret = EplObduCalDefineVar(pVarParam_p);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -230,14 +226,14 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT void* PUBLIC EplObduGetObjectDataPtr (unsigned int uiIndex_p,
-                                        unsigned int uiSubIndex_p)
+EPLDLLEXPORT void *PUBLIC EplObduGetObjectDataPtr(unsigned int uiIndex_p,
+						  unsigned int uiSubIndex_p)
 {
-void*   pData;
+	void *pData;
 
-    pData =  EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
+	pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
 
-    return pData;
+	return pData;
 }
 
 //---------------------------------------------------------------------------
@@ -254,13 +250,13 @@ void*   pData;
 //
 //---------------------------------------------------------------------------
 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
-EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd (tEplObdEntryPtr pUserOd_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalRegisterUserOd(pUserOd_p);
+	Ret = EplObduCalRegisterUserOd(pUserOd_p);
 
-    return Ret;
+	return Ret;
 
 }
 #endif
@@ -279,10 +275,11 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
-                                        BYTE bType_p, tEplObdSize ObdSize_p)
+EPLDLLEXPORT void PUBLIC EplObduInitVarEntry(tEplObdVarEntry MEM * pVarEntry_p,
+					     BYTE bType_p,
+					     tEplObdSize ObdSize_p)
 {
-    EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
+	EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
 }
 
 //---------------------------------------------------------------------------
@@ -303,13 +300,13 @@ EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
-                                        unsigned int uiSubIndex_p)
+						   unsigned int uiSubIndex_p)
 {
-tEplObdSize Size;
+	tEplObdSize Size;
 
-    Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
+	Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
 
-    return Size;
+	return Size;
 }
 
 //---------------------------------------------------------------------------
@@ -328,11 +325,11 @@ tEplObdSize Size;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
 {
-unsigned int uiNodeId;
+	unsigned int uiNodeId;
 
-    uiNodeId = EplObduCalGetNodeId();
+	uiNodeId = EplObduCalGetNodeId();
 
-    return uiNodeId;
+	return uiNodeId;
 }
 
 //---------------------------------------------------------------------------
@@ -351,13 +348,13 @@ unsigned int uiNodeId;
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
-                                         tEplObdNodeIdType NodeIdType_p)
+						tEplObdNodeIdType NodeIdType_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
+	Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -377,14 +374,16 @@ tEplKernel  Ret;
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
-                                        unsigned int   uiSubIndex_p,
-                                        tEplObdAccess* pAccessTyp_p)
+						    unsigned int uiSubIndex_p,
+						    tEplObdAccess *
+						    pAccessTyp_p)
 {
-tEplObdAccess AccessType;
+	tEplObdAccess AccessType;
 
-    AccessType = EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
+	AccessType =
+	    EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
 
-    return AccessType;
+	return AccessType;
 }
 
 //---------------------------------------------------------------------------
@@ -411,16 +410,18 @@ tEplObdAccess AccessType;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe (unsigned int        uiIndex_p,
-                                        unsigned int        uiSubIndex_p,
-                                        void *              pDstData_p,
-                                        tEplObdSize *       pSize_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe(unsigned int uiIndex_p,
+						    unsigned int uiSubIndex_p,
+						    void *pDstData_p,
+						    tEplObdSize * pSize_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
+	Ret =
+	    EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
+				    pSize_p);
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -444,16 +445,19 @@ return Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe (unsigned int  uiIndex_p,
-                                        unsigned int  uiSubIndex_p,
-                                        void *        pSrcData_p,
-                                        tEplObdSize   Size_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe(unsigned int uiIndex_p,
+						       unsigned int
+						       uiSubIndex_p,
+						       void *pSrcData_p,
+						       tEplObdSize Size_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
+	Ret =
+	    EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
+				       Size_p);
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -471,17 +475,19 @@ return Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
-                                            unsigned int            uiIndex_p,
-                                            unsigned int            uiSubindex_p,
-                                            tEplObdVarEntry MEM**   ppVarEntry_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
+						     unsigned int uiIndex_p,
+						     unsigned int uiSubindex_p,
+						     tEplObdVarEntry MEM **
+						     ppVarEntry_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
+	Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
 
-return Ret;
+	return Ret;
 }
+
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -509,4 +515,3 @@ return Ret;
 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
 
 // EOF
-

+ 95 - 99
drivers/staging/epl/EplObduCal.c

@@ -74,7 +74,6 @@
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) && (EPL_OBD_USE_KERNEL != FALSE)
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -99,8 +98,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -124,24 +121,22 @@
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry (
-                                                unsigned int  uiIndex_p,
-                                                unsigned int  uiSubIndex_p,
-                                                void * pSrcData_p,
-                                                tEplObdSize   Size_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry(unsigned int uiIndex_p,
+						    unsigned int uiSubIndex_p,
+						    void *pSrcData_p,
+						    tEplObdSize Size_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdWriteEntry(uiIndex_p,uiSubIndex_p,pSrcData_p,Size_p);
+	Ret = EplObdWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplObduCalReadEntry()
@@ -160,24 +155,22 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry (
-                                            unsigned int        uiIndex_p,
-                                            unsigned int        uiSubIndex_p,
-                                            void *       pDstData_p,
-                                            tEplObdSize *pSize_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry(unsigned int uiIndex_p,
+						   unsigned int uiSubIndex_p,
+						   void *pDstData_p,
+						   tEplObdSize * pSize_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
+	Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplObduCalAccessOdPart()
@@ -192,19 +185,18 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart (
-                                                    tEplObdPart ObdPart_p,
-                                                    tEplObdDir Direction_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart(tEplObdPart ObdPart_p,
+						      tEplObdDir Direction_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
+	Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -220,17 +212,18 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar (tEplVarParam MEM* pVarParam_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar(tEplVarParam MEM *
+						   pVarParam_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdDefineVar(pVarParam_p);
+	Ret = EplObdDefineVar(pVarParam_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -247,18 +240,18 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT void* PUBLIC EplObduCalGetObjectDataPtr ( unsigned int uiIndex_p,
-                                        unsigned int uiSubIndex_p)
+EPLDLLEXPORT void *PUBLIC EplObduCalGetObjectDataPtr(unsigned int uiIndex_p,
+						     unsigned int uiSubIndex_p)
 {
-void*   pData;
+	void *pData;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
+	pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
 #else
-    pData = NULL;
+	pData = NULL;
 #endif
 
-    return pData;
+	return pData;
 }
 
 //---------------------------------------------------------------------------
@@ -275,17 +268,18 @@ void*   pData;
 //
 //---------------------------------------------------------------------------
 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd (tEplObdEntryPtr pUserOd_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd(tEplObdEntryPtr
+							pUserOd_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdRegisterUserOd(pUserOd_p);
+	Ret = EplObdRegisterUserOd(pUserOd_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 
 }
 #endif
@@ -304,15 +298,15 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
-                                        BYTE bType_p, tEplObdSize ObdSize_p)
+EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry(tEplObdVarEntry MEM *
+						pVarEntry_p, BYTE bType_p,
+						tEplObdSize ObdSize_p)
 {
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
+	EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
 #endif
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplObduCalGetDataSize()
@@ -331,17 +325,17 @@ EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry (tEplObdVarEntry MEM* pVarEntry_
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplObdSize PUBLIC EplObduCalGetDataSize(unsigned int uiIndex_p,
-                                        unsigned int uiSubIndex_p)
+						      unsigned int uiSubIndex_p)
 {
-tEplObdSize Size;
+	tEplObdSize Size;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
+	Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
 #else
-    Size = 0;
+	Size = 0;
 #endif
 
-    return Size;
+	return Size;
 }
 
 //---------------------------------------------------------------------------
@@ -360,15 +354,15 @@ tEplObdSize Size;
 //---------------------------------------------------------------------------
 EPLDLLEXPORT unsigned int PUBLIC EplObduCalGetNodeId()
 {
-unsigned int uiNodeId;
+	unsigned int uiNodeId;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    uiNodeId = EplObdGetNodeId();
+	uiNodeId = EplObdGetNodeId();
 #else
-    uiNodeId = 0;
+	uiNodeId = 0;
 #endif
 
-    return uiNodeId;
+	return uiNodeId;
 }
 
 //---------------------------------------------------------------------------
@@ -387,17 +381,18 @@ unsigned int uiNodeId;
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSetNodeId(unsigned int uiNodeId_p,
-                                         tEplObdNodeIdType NodeIdType_p)
+						   tEplObdNodeIdType
+						   NodeIdType_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
+	Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -417,19 +412,20 @@ tEplKernel  Ret;
 //
 //---------------------------------------------------------------------------
 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalGetAccessType(unsigned int uiIndex_p,
-                                        unsigned int   uiSubIndex_p,
-                                        tEplObdAccess* pAccessTyp_p)
-
+						       unsigned int
+						       uiSubIndex_p,
+						       tEplObdAccess *
+						       pAccessTyp_p)
 {
-tEplObdAccess AccesType;
+	tEplObdAccess AccesType;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
+	AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
 #else
-    AccesType = 0;
+	AccesType = 0;
 #endif
 
-return AccesType;
+	return AccesType;
 
 }
 
@@ -451,20 +447,21 @@ return AccesType;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe (unsigned int        uiIndex_p,
-                                        unsigned int        uiSubIndex_p,
-                                        void *              pDstData_p,
-                                        tEplObdSize *       pSize_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe(unsigned int uiIndex_p,
+						       unsigned int
+						       uiSubIndex_p,
+						       void *pDstData_p,
+						       tEplObdSize * pSize_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
+	Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -484,19 +481,22 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe (unsigned int  uiIndex_p,
-                                        unsigned int  uiSubIndex_p,
-                                        void *        pSrcData_p,
-                                        tEplObdSize   Size_p)
+EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe(unsigned int
+							  uiIndex_p,
+							  unsigned int
+							  uiSubIndex_p,
+							  void *pSrcData_p,
+							  tEplObdSize Size_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
+	Ret =
+	    EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -514,23 +514,21 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
-                                            unsigned int            uiIndex_p,
-                                            unsigned int            uiSubindex_p,
-                                            tEplObdVarEntry MEM**   ppVarEntry_p)
+EPLDLLEXPORT tEplKernel PUBLIC
+EplObduCalSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
+			 unsigned int uiSubindex_p,
+			 tEplObdVarEntry MEM ** ppVarEntry_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
-    Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
+	Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
 #else
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 #endif
-    return Ret;
+	return Ret;
 }
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -557,6 +555,4 @@ tEplKernel  Ret;
 
 #endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
 
-
 // EOF
-

+ 360 - 358
drivers/staging/epl/EplPdok.c

@@ -82,13 +82,13 @@
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) == 0)
 
-    #error 'ERROR: Missing DLLk-Modul!'
+#error 'ERROR: Missing DLLk-Modul!'
 
 #endif
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
 
-    #error 'ERROR: Missing OBDk-Modul!'
+#error 'ERROR: Missing OBDk-Modul!'
 
 #endif
 /***************************************************************************/
@@ -120,7 +120,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -134,7 +133,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -153,12 +151,10 @@
 // local vars
 //---------------------------------------------------------------------------
 
-
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -183,7 +179,7 @@
 tEplKernel EplPdokAddInstance(void)
 {
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
 //---------------------------------------------------------------------------
@@ -204,10 +200,9 @@ tEplKernel EplPdokAddInstance(void)
 tEplKernel EplPdokDelInstance(void)
 {
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdokCbPdoReceived
@@ -228,27 +223,27 @@ tEplKernel EplPdokDelInstance(void)
 
 tEplKernel EplPdokCbPdoReceived(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplEvent       Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
-    // reset LED
+	// reset LED
 //    MCF_GPIO_PODR_PCIBG &= ~PDO_LED;  // Level
 #endif
 
-    Event.m_EventSink = kEplEventSinkPdok;
-    Event.m_EventType = kEplEventTypePdoRx;
-    // limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
-    Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + 24; // pFrameInfo_p->m_uiFrameSize;
-    Event.m_pArg = pFrameInfo_p->m_pFrame;
-    Ret = EplEventkPost(&Event);
+	Event.m_EventSink = kEplEventSinkPdok;
+	Event.m_EventType = kEplEventTypePdoRx;
+	// limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
+	Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + 24;	// pFrameInfo_p->m_uiFrameSize;
+	Event.m_pArg = pFrameInfo_p->m_pFrame;
+	Ret = EplEventkPost(&Event);
 
 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
-    // set LED
+	// set LED
 //    MCF_GPIO_PODR_PCIBG |= PDO_LED;  // Level
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -271,26 +266,26 @@ tEplEvent       Event;
 
 tEplKernel EplPdokCbPdoTransmitted(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplEvent       Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
-    // reset LED
-    MCF_GPIO_PODR_PCIBG &= ~PDO_LED;  // Level
+	// reset LED
+	MCF_GPIO_PODR_PCIBG &= ~PDO_LED;	// Level
 #endif
 
-    Event.m_EventSink = kEplEventSinkPdok;
-    Event.m_EventType = kEplEventTypePdoTx;
-    Event.m_uiSize = sizeof (tEplFrameInfo);
-    Event.m_pArg = pFrameInfo_p;
-    Ret = EplEventkPost(&Event);
+	Event.m_EventSink = kEplEventSinkPdok;
+	Event.m_EventType = kEplEventTypePdoTx;
+	Event.m_uiSize = sizeof(tEplFrameInfo);
+	Event.m_pArg = pFrameInfo_p;
+	Ret = EplEventkPost(&Event);
 
 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
-    // set LED
-    MCF_GPIO_PODR_PCIBG |= PDO_LED;  // Level
+	// set LED
+	MCF_GPIO_PODR_PCIBG |= PDO_LED;	// Level
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -311,16 +306,16 @@ tEplEvent       Event;
 
 tEplKernel EplPdokCbSoa(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplEvent       Event;
+	tEplKernel Ret = kEplSuccessful;
+	tEplEvent Event;
 
-    Event.m_EventSink = kEplEventSinkPdok;
-    Event.m_EventType = kEplEventTypePdoSoa;
-    Event.m_uiSize = 0;
-    Event.m_pArg = NULL;
-    Ret = EplEventkPost(&Event);
+	Event.m_EventSink = kEplEventSinkPdok;
+	Event.m_EventType = kEplEventTypePdoSoa;
+	Event.m_uiSize = 0;
+	Event.m_pArg = NULL;
+	Ret = EplEventkPost(&Event);
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -343,323 +338,331 @@ tEplEvent       Event;
 
 tEplKernel EplPdokProcess(tEplEvent * pEvent_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-WORD    wPdoSize;
-WORD    wBitOffset;
-WORD    wBitSize;
-WORD    wVarSize;
-QWORD   qwObjectMapping;
-BYTE    bMappSubindex;
-BYTE    bObdSubindex;
-WORD    wObdMappIndex;
-WORD    wObdCommIndex;
-WORD    wPdoId;
-BYTE    bObdData;
-BYTE    bObjectCount;
-BYTE    bFrameData;
-BOOL    fValid;
-tEplObdSize     ObdSize;
-tEplFrame      *pFrame;
-tEplFrameInfo  *pFrameInfo;
-unsigned int    uiNodeId;
-tEplMsgType     MsgType;
-
-    // 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
-    //               TPDO: 0x00=PRes, MN: CnNodeId=PReq
-
-    switch (pEvent_p->m_EventType)
-    {
-        case kEplEventTypePdoRx:  // RPDO received
-            pFrame = (tEplFrame *) pEvent_p->m_pArg;
-
-            // check if received RPDO is valid
-            bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
-            if ((bFrameData & EPL_FRAME_FLAG1_RD) == 0)
-            {   // RPDO invalid
-                goto Exit;
-            }
-
-            // retrieve EPL message type
-            MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
-            if (MsgType == kEplMsgTypePreq)
-            {   // RPDO is PReq frame
-                uiNodeId = EPL_PDO_PREQ_NODE_ID;  // 0x00
-            }
-            else
-            {   // RPDO is PRes frame
-                // retrieve node ID
-                uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
-            }
-
-            // search for appropriate valid RPDO in OD
-            wObdMappIndex = EPL_PDOK_OBD_IDX_RX_MAPP_PARAM;
-            for (wObdCommIndex = EPL_PDOK_OBD_IDX_RX_COMM_PARAM;
-                wObdCommIndex < (EPL_PDOK_OBD_IDX_RX_COMM_PARAM + 0x00FF);
-                wObdCommIndex++, wObdMappIndex++)
-            {
-                ObdSize = 1;
-                // read node ID from OD
-                Ret = EplObdReadEntry(wObdCommIndex, 0x01, &bObdData, &ObdSize);
-                if ((Ret == kEplObdIndexNotExist)
-                    || (Ret == kEplObdSubindexNotExist)
-                    || (Ret == kEplObdIllegalPart))
-                {   // PDO does not exist; last PDO reached
-                    Ret = kEplSuccessful;
-                    goto Exit;
-                }
-                else if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                if (bObdData != uiNodeId)
-                {   // node ID does not equal - wrong PDO, try next PDO in OD
-                    continue;
-                }
-                ObdSize = 1;
-                // read number of mapped objects from OD; this indicates if the PDO is valid
-                Ret = EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount, &ObdSize);
-                if ((Ret == kEplObdIndexNotExist)
-                    || (Ret == kEplObdSubindexNotExist)
-                    || (Ret == kEplObdIllegalPart))
-                {   // PDO does not exist; last PDO reached
-                    Ret = kEplSuccessful;
-                    goto Exit;
-                }
-                else if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                if (bObjectCount == 0)
-                {   // PDO in OD not valid, try next PDO in OD
-                    continue;
-                }
-
-                ObdSize = 1;
-                // check PDO mapping version
-                Ret = EplObdReadEntry(wObdCommIndex, 0x02, &bObdData, &ObdSize);
-                if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                // retrieve PDO version from frame
-                bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion);
-                if ((bObdData & EPL_VERSION_MAIN) != (bFrameData & EPL_VERSION_MAIN))
-                {   // PDO versions do not match
-                    // $$$ raise PDO error
-                    // termiate processing of this RPDO
-                    goto Exit;
-                }
-
-                // valid RPDO found
-
-                // retrieve PDO size
-                wPdoSize = AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
-
-                // process mapping
-                for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
-                {
-                    ObdSize = 8;    // QWORD
-                    // read object mapping from OD
-                    Ret = EplObdReadEntry(wObdMappIndex, bMappSubindex, &qwObjectMapping, &ObdSize);
-                    if (Ret != kEplSuccessful)
-                    {   // other fatal error occured
-                        goto Exit;
-                    }
-
-                    // check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
-                    if (qwObjectMapping == 0)
-                    {   // invalid entry, continue with next entry
-                        continue;
-                    }
-
-                    // decode object mapping
-                    wObdCommIndex = (WORD) (qwObjectMapping & 0x000000000000FFFFLL);
-                    bObdSubindex = (BYTE) ((qwObjectMapping & 0x0000000000FF0000LL) >> 16);
-                    wBitOffset = (WORD) ((qwObjectMapping & 0x0000FFFF00000000LL) >> 32);
-                    wBitSize = (WORD) ((qwObjectMapping & 0xFFFF000000000000LL) >> 48);
-
-                    // check if object exceeds PDO size
-                    if (((wBitOffset + wBitSize) >> 3) > wPdoSize)
-                    {   // wrong object mapping; PDO size is too low
-                        // $$$ raise PDO error
-                        // terminate processing of this RPDO
-                        goto Exit;
-                    }
-
-                    // copy object from RPDO to process/OD variable
-                    ObdSize = wBitSize >> 3;
-                    Ret = EplObdWriteEntryFromLe(wObdCommIndex, bObdSubindex, &pFrame->m_Data.m_Pres.m_le_abPayload[(wBitOffset >> 3)], ObdSize);
-                    if (Ret != kEplSuccessful)
-                    {   // other fatal error occured
-                        goto Exit;
-                    }
-
-                }
-
-                // processing finished successfully
-                goto Exit;
-            }
-            break;
-
-        case kEplEventTypePdoTx:  // TPDO transmitted
-            pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
-            pFrame = pFrameInfo->m_pFrame;
-
-            // set TPDO invalid, so that only fully processed TPDOs are sent as valid
-            bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
-            AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1, (bFrameData & ~EPL_FRAME_FLAG1_RD));
-
-            // retrieve EPL message type
-            MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
-            if (MsgType == kEplMsgTypePres)
-            {   // TPDO is PRes frame
-                uiNodeId = EPL_PDO_PRES_NODE_ID;  // 0x00
-            }
-            else
-            {   // TPDO is PReq frame
-                // retrieve node ID
-                uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bDstNodeId);
-            }
-
-            // search for appropriate valid TPDO in OD
-            wObdMappIndex = EPL_PDOK_OBD_IDX_TX_MAPP_PARAM;
-            wObdCommIndex = EPL_PDOK_OBD_IDX_TX_COMM_PARAM;
-            for (wPdoId = 0; ; wPdoId++, wObdCommIndex++, wObdMappIndex++)
-            {
-                ObdSize = 1;
-                // read node ID from OD
-                Ret = EplObdReadEntry(wObdCommIndex, 0x01, &bObdData, &ObdSize);
-                if ((Ret == kEplObdIndexNotExist)
-                    || (Ret == kEplObdSubindexNotExist)
-                    || (Ret == kEplObdIllegalPart))
-                {   // PDO does not exist; last PDO reached
-                    Ret = kEplSuccessful;
-                    goto Exit;
-                }
-                else if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                if (bObdData != uiNodeId)
-                {   // node ID does not equal - wrong PDO, try next PDO in OD
-                    continue;
-                }
-                ObdSize = 1;
-                // read number of mapped objects from OD; this indicates if the PDO is valid
-                Ret = EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount, &ObdSize);
-                if ((Ret == kEplObdIndexNotExist)
-                    || (Ret == kEplObdSubindexNotExist)
-                    || (Ret == kEplObdIllegalPart))
-                {   // PDO does not exist; last PDO reached
-                    Ret = kEplSuccessful;
-                    goto Exit;
-                }
-                else if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                if (bObjectCount == 0)
-                {   // PDO in OD not valid, try next PDO in OD
-                    continue;
-                }
-
-                // valid TPDO found
-
-                ObdSize = 1;
-                // get PDO mapping version from OD
-                Ret = EplObdReadEntry(wObdCommIndex, 0x02, &bObdData, &ObdSize);
-                if (Ret != kEplSuccessful)
-                {   // other fatal error occured
-                    goto Exit;
-                }
-                // entry read successfully
-                // set PDO version in frame
-                AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion, bObdData);
-
-                // calculate PDO size
-                wPdoSize = 0;
-
-                // process mapping
-                for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
-                {
-                    ObdSize = 8;    // QWORD
-                    // read object mapping from OD
-                    Ret = EplObdReadEntry(wObdMappIndex, bMappSubindex, &qwObjectMapping, &ObdSize);
-                    if (Ret != kEplSuccessful)
-                    {   // other fatal error occured
-                        goto Exit;
-                    }
-
-                    // check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
-                    if (qwObjectMapping == 0)
-                    {   // invalid entry, continue with next entry
-                        continue;
-                    }
-
-                    // decode object mapping
-                    wObdCommIndex = (WORD) (qwObjectMapping & 0x000000000000FFFFLL);
-                    bObdSubindex = (BYTE) ((qwObjectMapping & 0x0000000000FF0000LL) >> 16);
-                    wBitOffset = (WORD) ((qwObjectMapping & 0x0000FFFF00000000LL) >> 32);
-                    wBitSize = (WORD) ((qwObjectMapping & 0xFFFF000000000000LL) >> 48);
-
-                    // calculate max PDO size
-                    ObdSize = wBitSize >> 3;
-                    wVarSize = (wBitOffset >> 3) + (WORD) ObdSize;
-                    if ((unsigned int)(wVarSize + 24) > pFrameInfo->m_uiFrameSize)
-                    {   // TPDO is too short
-                        // $$$ raise PDO error, set Ret
-                        goto Exit;
-                    }
-                    if (wVarSize > wPdoSize)
-                    {   // memorize new PDO size
-                        wPdoSize = wVarSize;
-                    }
-
-                    // copy object from process/OD variable to TPDO
-                    Ret = EplObdReadEntryToLe(wObdCommIndex, bObdSubindex, &pFrame->m_Data.m_Pres.m_le_abPayload[(wBitOffset >> 3)], &ObdSize);
-                    if (Ret != kEplSuccessful)
-                    {   // other fatal error occured
-                        goto Exit;
-                    }
-
-                }
-
-                // set PDO size in frame
-                AmiSetWordToLe(&pFrame->m_Data.m_Pres.m_le_wSize, wPdoSize);
-
-                Ret = EplPdokCalAreTpdosValid(&fValid);
-                if (fValid != FALSE)
-                {
-                    // set TPDO valid
-                    bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
-                    AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1, (bFrameData | EPL_FRAME_FLAG1_RD));
-                }
-
-                // processing finished successfully
-
-                goto Exit;
-            }
-            break;
-
-        case kEplEventTypePdoSoa: // SoA received
-
-            // invalidate TPDOs
-            Ret = EplPdokCalSetTpdosValid(FALSE);
-            break;
-
-        default:
-        {
-            ASSERTMSG(FALSE, "EplPdokProcess(): unhandled event type!\n");
-        }
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	WORD wPdoSize;
+	WORD wBitOffset;
+	WORD wBitSize;
+	WORD wVarSize;
+	QWORD qwObjectMapping;
+	BYTE bMappSubindex;
+	BYTE bObdSubindex;
+	WORD wObdMappIndex;
+	WORD wObdCommIndex;
+	WORD wPdoId;
+	BYTE bObdData;
+	BYTE bObjectCount;
+	BYTE bFrameData;
+	BOOL fValid;
+	tEplObdSize ObdSize;
+	tEplFrame *pFrame;
+	tEplFrameInfo *pFrameInfo;
+	unsigned int uiNodeId;
+	tEplMsgType MsgType;
+
+	// 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
+	//               TPDO: 0x00=PRes, MN: CnNodeId=PReq
+
+	switch (pEvent_p->m_EventType) {
+	case kEplEventTypePdoRx:	// RPDO received
+		pFrame = (tEplFrame *) pEvent_p->m_pArg;
+
+		// check if received RPDO is valid
+		bFrameData =
+		    AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
+		if ((bFrameData & EPL_FRAME_FLAG1_RD) == 0) {	// RPDO invalid
+			goto Exit;
+		}
+		// retrieve EPL message type
+		MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
+		if (MsgType == kEplMsgTypePreq) {	// RPDO is PReq frame
+			uiNodeId = EPL_PDO_PREQ_NODE_ID;	// 0x00
+		} else {	// RPDO is PRes frame
+			// retrieve node ID
+			uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
+		}
+
+		// search for appropriate valid RPDO in OD
+		wObdMappIndex = EPL_PDOK_OBD_IDX_RX_MAPP_PARAM;
+		for (wObdCommIndex = EPL_PDOK_OBD_IDX_RX_COMM_PARAM;
+		     wObdCommIndex < (EPL_PDOK_OBD_IDX_RX_COMM_PARAM + 0x00FF);
+		     wObdCommIndex++, wObdMappIndex++) {
+			ObdSize = 1;
+			// read node ID from OD
+			Ret =
+			    EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
+					    &ObdSize);
+			if ((Ret == kEplObdIndexNotExist)
+			    || (Ret == kEplObdSubindexNotExist)
+			    || (Ret == kEplObdIllegalPart)) {	// PDO does not exist; last PDO reached
+				Ret = kEplSuccessful;
+				goto Exit;
+			} else if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			if (bObdData != uiNodeId) {	// node ID does not equal - wrong PDO, try next PDO in OD
+				continue;
+			}
+			ObdSize = 1;
+			// read number of mapped objects from OD; this indicates if the PDO is valid
+			Ret =
+			    EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
+					    &ObdSize);
+			if ((Ret == kEplObdIndexNotExist)
+			    || (Ret == kEplObdSubindexNotExist)
+			    || (Ret == kEplObdIllegalPart)) {	// PDO does not exist; last PDO reached
+				Ret = kEplSuccessful;
+				goto Exit;
+			} else if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			if (bObjectCount == 0) {	// PDO in OD not valid, try next PDO in OD
+				continue;
+			}
+
+			ObdSize = 1;
+			// check PDO mapping version
+			Ret =
+			    EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
+					    &ObdSize);
+			if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			// retrieve PDO version from frame
+			bFrameData =
+			    AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
+					     m_le_bPdoVersion);
+			if ((bObdData & EPL_VERSION_MAIN) != (bFrameData & EPL_VERSION_MAIN)) {	// PDO versions do not match
+				// $$$ raise PDO error
+				// termiate processing of this RPDO
+				goto Exit;
+			}
+			// valid RPDO found
+
+			// retrieve PDO size
+			wPdoSize =
+			    AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
+
+			// process mapping
+			for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
+			     bMappSubindex++) {
+				ObdSize = 8;	// QWORD
+				// read object mapping from OD
+				Ret =
+				    EplObdReadEntry(wObdMappIndex,
+						    bMappSubindex,
+						    &qwObjectMapping, &ObdSize);
+				if (Ret != kEplSuccessful) {	// other fatal error occured
+					goto Exit;
+				}
+				// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
+				if (qwObjectMapping == 0) {	// invalid entry, continue with next entry
+					continue;
+				}
+				// decode object mapping
+				wObdCommIndex =
+				    (WORD) (qwObjectMapping &
+					    0x000000000000FFFFLL);
+				bObdSubindex =
+				    (BYTE) ((qwObjectMapping &
+					     0x0000000000FF0000LL) >> 16);
+				wBitOffset =
+				    (WORD) ((qwObjectMapping &
+					     0x0000FFFF00000000LL) >> 32);
+				wBitSize =
+				    (WORD) ((qwObjectMapping &
+					     0xFFFF000000000000LL) >> 48);
+
+				// check if object exceeds PDO size
+				if (((wBitOffset + wBitSize) >> 3) > wPdoSize) {	// wrong object mapping; PDO size is too low
+					// $$$ raise PDO error
+					// terminate processing of this RPDO
+					goto Exit;
+				}
+				// copy object from RPDO to process/OD variable
+				ObdSize = wBitSize >> 3;
+				Ret =
+				    EplObdWriteEntryFromLe(wObdCommIndex,
+							   bObdSubindex,
+							   &pFrame->m_Data.
+							   m_Pres.
+							   m_le_abPayload[(wBitOffset >> 3)], ObdSize);
+				if (Ret != kEplSuccessful) {	// other fatal error occured
+					goto Exit;
+				}
+
+			}
+
+			// processing finished successfully
+			goto Exit;
+		}
+		break;
+
+	case kEplEventTypePdoTx:	// TPDO transmitted
+		pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
+		pFrame = pFrameInfo->m_pFrame;
+
+		// set TPDO invalid, so that only fully processed TPDOs are sent as valid
+		bFrameData =
+		    AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
+		AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1,
+			       (bFrameData & ~EPL_FRAME_FLAG1_RD));
+
+		// retrieve EPL message type
+		MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
+		if (MsgType == kEplMsgTypePres) {	// TPDO is PRes frame
+			uiNodeId = EPL_PDO_PRES_NODE_ID;	// 0x00
+		} else {	// TPDO is PReq frame
+			// retrieve node ID
+			uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bDstNodeId);
+		}
+
+		// search for appropriate valid TPDO in OD
+		wObdMappIndex = EPL_PDOK_OBD_IDX_TX_MAPP_PARAM;
+		wObdCommIndex = EPL_PDOK_OBD_IDX_TX_COMM_PARAM;
+		for (wPdoId = 0;; wPdoId++, wObdCommIndex++, wObdMappIndex++) {
+			ObdSize = 1;
+			// read node ID from OD
+			Ret =
+			    EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
+					    &ObdSize);
+			if ((Ret == kEplObdIndexNotExist)
+			    || (Ret == kEplObdSubindexNotExist)
+			    || (Ret == kEplObdIllegalPart)) {	// PDO does not exist; last PDO reached
+				Ret = kEplSuccessful;
+				goto Exit;
+			} else if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			if (bObdData != uiNodeId) {	// node ID does not equal - wrong PDO, try next PDO in OD
+				continue;
+			}
+			ObdSize = 1;
+			// read number of mapped objects from OD; this indicates if the PDO is valid
+			Ret =
+			    EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
+					    &ObdSize);
+			if ((Ret == kEplObdIndexNotExist)
+			    || (Ret == kEplObdSubindexNotExist)
+			    || (Ret == kEplObdIllegalPart)) {	// PDO does not exist; last PDO reached
+				Ret = kEplSuccessful;
+				goto Exit;
+			} else if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			if (bObjectCount == 0) {	// PDO in OD not valid, try next PDO in OD
+				continue;
+			}
+			// valid TPDO found
+
+			ObdSize = 1;
+			// get PDO mapping version from OD
+			Ret =
+			    EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
+					    &ObdSize);
+			if (Ret != kEplSuccessful) {	// other fatal error occured
+				goto Exit;
+			}
+			// entry read successfully
+			// set PDO version in frame
+			AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion,
+				       bObdData);
+
+			// calculate PDO size
+			wPdoSize = 0;
+
+			// process mapping
+			for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
+			     bMappSubindex++) {
+				ObdSize = 8;	// QWORD
+				// read object mapping from OD
+				Ret =
+				    EplObdReadEntry(wObdMappIndex,
+						    bMappSubindex,
+						    &qwObjectMapping, &ObdSize);
+				if (Ret != kEplSuccessful) {	// other fatal error occured
+					goto Exit;
+				}
+				// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
+				if (qwObjectMapping == 0) {	// invalid entry, continue with next entry
+					continue;
+				}
+				// decode object mapping
+				wObdCommIndex =
+				    (WORD) (qwObjectMapping &
+					    0x000000000000FFFFLL);
+				bObdSubindex =
+				    (BYTE) ((qwObjectMapping &
+					     0x0000000000FF0000LL) >> 16);
+				wBitOffset =
+				    (WORD) ((qwObjectMapping &
+					     0x0000FFFF00000000LL) >> 32);
+				wBitSize =
+				    (WORD) ((qwObjectMapping &
+					     0xFFFF000000000000LL) >> 48);
+
+				// calculate max PDO size
+				ObdSize = wBitSize >> 3;
+				wVarSize = (wBitOffset >> 3) + (WORD) ObdSize;
+				if ((unsigned int)(wVarSize + 24) > pFrameInfo->m_uiFrameSize) {	// TPDO is too short
+					// $$$ raise PDO error, set Ret
+					goto Exit;
+				}
+				if (wVarSize > wPdoSize) {	// memorize new PDO size
+					wPdoSize = wVarSize;
+				}
+				// copy object from process/OD variable to TPDO
+				Ret =
+				    EplObdReadEntryToLe(wObdCommIndex,
+							bObdSubindex,
+							&pFrame->m_Data.m_Pres.
+							m_le_abPayload[(wBitOffset >> 3)], &ObdSize);
+				if (Ret != kEplSuccessful) {	// other fatal error occured
+					goto Exit;
+				}
+
+			}
+
+			// set PDO size in frame
+			AmiSetWordToLe(&pFrame->m_Data.m_Pres.m_le_wSize,
+				       wPdoSize);
+
+			Ret = EplPdokCalAreTpdosValid(&fValid);
+			if (fValid != FALSE) {
+				// set TPDO valid
+				bFrameData =
+				    AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
+						     m_le_bFlag1);
+				AmiSetByteToLe(&pFrame->m_Data.m_Pres.
+					       m_le_bFlag1,
+					       (bFrameData |
+						EPL_FRAME_FLAG1_RD));
+			}
+			// processing finished successfully
+
+			goto Exit;
+		}
+		break;
+
+	case kEplEventTypePdoSoa:	// SoA received
+
+		// invalidate TPDOs
+		Ret = EplPdokCalSetTpdosValid(FALSE);
+		break;
+
+	default:
+		{
+			ASSERTMSG(FALSE,
+				  "EplPdokProcess(): unhandled event type!\n");
+		}
+	}
+
+      Exit:
+	return Ret;
 }
 
 //=========================================================================//
@@ -689,4 +692,3 @@ Exit:
 #endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
 
 // EOF
-

+ 12 - 20
drivers/staging/epl/EplPdokCal.c

@@ -72,7 +72,6 @@
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -97,7 +96,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -111,7 +109,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -126,9 +123,8 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    BOOL            m_fTpdosValid;
+typedef struct {
+	BOOL m_fTpdosValid;
 
 } tEplPdokCalInstance;
 
@@ -136,13 +132,12 @@ typedef struct
 // local vars
 //---------------------------------------------------------------------------
 
-static tEplPdokCalInstance  EplPdokCalInstance_g;
+static tEplPdokCalInstance EplPdokCalInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -167,9 +162,9 @@ static tEplPdokCalInstance  EplPdokCalInstance_g;
 tEplKernel EplPdokCalAddInstance(void)
 {
 
-    EPL_MEMSET(&EplPdokCalInstance_g, 0, sizeof(EplPdokCalInstance_g));
+	EPL_MEMSET(&EplPdokCalInstance_g, 0, sizeof(EplPdokCalInstance_g));
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
 //---------------------------------------------------------------------------
@@ -190,10 +185,9 @@ tEplKernel EplPdokCalAddInstance(void)
 tEplKernel EplPdokCalDelInstance(void)
 {
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdokCalSetTpdosValid()
@@ -212,11 +206,11 @@ tEplKernel EplPdokCalDelInstance(void)
 
 tEplKernel EplPdokCalSetTpdosValid(BOOL fValid_p)
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    EplPdokCalInstance_g.m_fTpdosValid = fValid_p;
+	EplPdokCalInstance_g.m_fTpdosValid = fValid_p;
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -236,14 +230,13 @@ tEplKernel      Ret = kEplSuccessful;
 
 tEplKernel EplPdokCalAreTpdosValid(BOOL * pfValid_p)
 {
-tEplKernel      Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    *pfValid_p = EplPdokCalInstance_g.m_fTpdosValid;
+	*pfValid_p = EplPdokCalInstance_g.m_fTpdosValid;
 
-    return Ret;
+	return Ret;
 }
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -271,4 +264,3 @@ tEplKernel      Ret = kEplSuccessful;
 #endif
 
 // EOF
-

+ 266 - 309
drivers/staging/epl/EplPdou.c

@@ -82,7 +82,6 @@
 #error "EPL PDOu module needs EPL module OBDU or OBDK!"
 #endif
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -103,7 +102,6 @@
 #define EPL_PDOU_OBD_IDX_MASK           0xFF00
 #define EPL_PDOU_PDO_ID_MASK            0x00FF
 
-
 //---------------------------------------------------------------------------
 // local types
 //---------------------------------------------------------------------------
@@ -116,7 +114,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -130,7 +127,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -149,25 +145,23 @@
 // local vars
 //---------------------------------------------------------------------------
 
-
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM* pParam_p, unsigned int uiIndex_p);
+static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM * pParam_p,
+					  unsigned int uiIndex_p);
 
 static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
-                                    unsigned int* puiIndex_p,
-                                    unsigned int* puiSubIndex_p,
-                                    unsigned int* puiBitOffset_p,
-                                    unsigned int* puiBitSize_p);
+				       unsigned int *puiIndex_p,
+				       unsigned int *puiSubIndex_p,
+				       unsigned int *puiBitOffset_p,
+				       unsigned int *puiBitSize_p);
 
 static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
-                                       tEplObdAccess AccessType_p,
-                                       DWORD* pdwAbortCode_p,
-                                       unsigned int* puiPdoSize_p);
-
-
+					    tEplObdAccess AccessType_p,
+					    DWORD * pdwAbortCode_p,
+					    unsigned int *puiPdoSize_p);
 
 //=========================================================================//
 //                                                                         //
@@ -193,10 +187,9 @@ static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
 tEplKernel EplPdouAddInstance(void)
 {
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdouDelInstance()
@@ -215,10 +208,9 @@ tEplKernel EplPdouAddInstance(void)
 tEplKernel EplPdouDelInstance(void)
 {
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdouCbObdAccess
@@ -234,170 +226,153 @@ tEplKernel EplPdouDelInstance(void)
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplPdouCbObdAccess(tEplObdCbParam MEM* pParam_p)
+tEplKernel PUBLIC EplPdouCbObdAccess(tEplObdCbParam MEM * pParam_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-unsigned int        uiPdoId;
-unsigned int        uiIndexType;
-tEplObdSize         ObdSize;
-BYTE                bObjectCount;
-QWORD               qwObjectMapping;
-tEplObdAccess       AccessType;
-BYTE                bMappSubindex;
-unsigned int        uiCurPdoSize;
-WORD                wMaxPdoSize;
-unsigned int        uiSubIndex;
-
-    // fetch PDO ID
-    uiPdoId = pParam_p->m_uiIndex & EPL_PDOU_PDO_ID_MASK;
-
-    // fetch object index type
-    uiIndexType = pParam_p->m_uiIndex & EPL_PDOU_OBD_IDX_MASK;
-
-    if (pParam_p->m_ObdEvent != kEplObdEvPreWrite)
-    {   // read accesses, post write events etc. are OK
-        pParam_p->m_dwAbortCode = 0;
-        goto Exit;
-    }
-
-    // check index type
-    switch (uiIndexType)
-    {
-        case EPL_PDOU_OBD_IDX_RX_COMM_PARAM:
-            // RPDO communication parameter accessed
-        case EPL_PDOU_OBD_IDX_TX_COMM_PARAM:
-        {   // TPDO communication parameter accessed
-            Ret = EplPdouCheckPdoValidity(pParam_p,
-                    (EPL_PDOU_OBD_IDX_MAPP_PARAM | pParam_p->m_uiIndex));
-            if (Ret != kEplSuccessful)
-            {   // PDO is valid or does not exist
-                goto Exit;
-            }
-
-            goto Exit;
-        }
-
-        case EPL_PDOU_OBD_IDX_RX_MAPP_PARAM:
-        {   // RPDO mapping parameter accessed
-
-            AccessType = kEplObdAccWrite;
-            break;
-        }
-
-        case EPL_PDOU_OBD_IDX_TX_MAPP_PARAM:
-        {   // TPDO mapping parameter accessed
-
-            AccessType = kEplObdAccRead;
-            break;
-        }
-
-        default:
-        {   // this callback function is only for
-            // PDO mapping and communication parameters
-            pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
-            goto Exit;
-        }
-    }
-
-    // RPDO and TPDO mapping parameter accessed
-
-    if (pParam_p->m_uiSubIndex == 0)
-    {   // object mapping count accessed
-
-        // PDO is enabled or disabled
-        bObjectCount = *((BYTE*) pParam_p->m_pArg);
-
-        if (bObjectCount == 0)
-        {   // PDO shall be disabled
-
-            // that is always possible
-            goto Exit;
-        }
-
-        // PDO shall be enabled
-        // it should have been disabled for this operation
-        Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
-        if (Ret != kEplSuccessful)
-        {   // PDO is valid or does not exist
-            goto Exit;
-        }
-
-        if (AccessType == kEplObdAccWrite)
-        {
-            uiSubIndex = 0x04;  // PReqActPayloadLimit_U16
-        }
-        else
-        {
-            uiSubIndex = 0x05;  // PResActPayloadLimit_U16
-        }
-
-        // fetch maximum PDO size from Object 1F98h: NMT_CycleTiming_REC
-        ObdSize = sizeof (wMaxPdoSize);
-        Ret = EplObduReadEntry(0x1F98, uiSubIndex, &wMaxPdoSize, &ObdSize);
-        if (Ret != kEplSuccessful)
-        {   // other fatal error occured
-            pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
-            goto Exit;
-        }
-
-        // check all objectmappings
-        for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
-        {
-            // read object mapping from OD
-            ObdSize = sizeof (qwObjectMapping); // QWORD
-            Ret = EplObduReadEntry(pParam_p->m_uiIndex,
-                                bMappSubindex, &qwObjectMapping, &ObdSize);
-            if (Ret != kEplSuccessful)
-            {   // other fatal error occured
-                pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
-                goto Exit;
-            }
-
-            // check object mapping
-            Ret = EplPdouCheckObjectMapping(qwObjectMapping,
-                                   AccessType,
-                                   &pParam_p->m_dwAbortCode,
-                                   &uiCurPdoSize);
-            if (Ret != kEplSuccessful)
-            {   // illegal object mapping
-                goto Exit;
-            }
-
-            if (uiCurPdoSize > wMaxPdoSize)
-            {   // mapping exceeds object size
-                pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
-                Ret = kEplPdoVarNotFound;
-            }
-
-
-        }
-
-    }
-    else
-    {   // ObjectMapping
-        Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
-        if (Ret != kEplSuccessful)
-        {   // PDO is valid or does not exist
-            goto Exit;
-        }
-
-        // check existence of object and validity of object length
-
-        qwObjectMapping = *((QWORD*) pParam_p->m_pArg);
-
-        Ret = EplPdouCheckObjectMapping(qwObjectMapping,
-                               AccessType,
-                               &pParam_p->m_dwAbortCode,
-                               &uiCurPdoSize);
-
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	unsigned int uiPdoId;
+	unsigned int uiIndexType;
+	tEplObdSize ObdSize;
+	BYTE bObjectCount;
+	QWORD qwObjectMapping;
+	tEplObdAccess AccessType;
+	BYTE bMappSubindex;
+	unsigned int uiCurPdoSize;
+	WORD wMaxPdoSize;
+	unsigned int uiSubIndex;
+
+	// fetch PDO ID
+	uiPdoId = pParam_p->m_uiIndex & EPL_PDOU_PDO_ID_MASK;
+
+	// fetch object index type
+	uiIndexType = pParam_p->m_uiIndex & EPL_PDOU_OBD_IDX_MASK;
+
+	if (pParam_p->m_ObdEvent != kEplObdEvPreWrite) {	// read accesses, post write events etc. are OK
+		pParam_p->m_dwAbortCode = 0;
+		goto Exit;
+	}
+	// check index type
+	switch (uiIndexType) {
+	case EPL_PDOU_OBD_IDX_RX_COMM_PARAM:
+		// RPDO communication parameter accessed
+	case EPL_PDOU_OBD_IDX_TX_COMM_PARAM:
+		{		// TPDO communication parameter accessed
+			Ret = EplPdouCheckPdoValidity(pParam_p,
+						      (EPL_PDOU_OBD_IDX_MAPP_PARAM
+						       | pParam_p->m_uiIndex));
+			if (Ret != kEplSuccessful) {	// PDO is valid or does not exist
+				goto Exit;
+			}
+
+			goto Exit;
+		}
+
+	case EPL_PDOU_OBD_IDX_RX_MAPP_PARAM:
+		{		// RPDO mapping parameter accessed
+
+			AccessType = kEplObdAccWrite;
+			break;
+		}
+
+	case EPL_PDOU_OBD_IDX_TX_MAPP_PARAM:
+		{		// TPDO mapping parameter accessed
+
+			AccessType = kEplObdAccRead;
+			break;
+		}
+
+	default:
+		{		// this callback function is only for
+			// PDO mapping and communication parameters
+			pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
+			goto Exit;
+		}
+	}
+
+	// RPDO and TPDO mapping parameter accessed
+
+	if (pParam_p->m_uiSubIndex == 0) {	// object mapping count accessed
+
+		// PDO is enabled or disabled
+		bObjectCount = *((BYTE *) pParam_p->m_pArg);
+
+		if (bObjectCount == 0) {	// PDO shall be disabled
+
+			// that is always possible
+			goto Exit;
+		}
+		// PDO shall be enabled
+		// it should have been disabled for this operation
+		Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
+		if (Ret != kEplSuccessful) {	// PDO is valid or does not exist
+			goto Exit;
+		}
+
+		if (AccessType == kEplObdAccWrite) {
+			uiSubIndex = 0x04;	// PReqActPayloadLimit_U16
+		} else {
+			uiSubIndex = 0x05;	// PResActPayloadLimit_U16
+		}
+
+		// fetch maximum PDO size from Object 1F98h: NMT_CycleTiming_REC
+		ObdSize = sizeof(wMaxPdoSize);
+		Ret =
+		    EplObduReadEntry(0x1F98, uiSubIndex, &wMaxPdoSize,
+				     &ObdSize);
+		if (Ret != kEplSuccessful) {	// other fatal error occured
+			pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
+			goto Exit;
+		}
+		// check all objectmappings
+		for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
+		     bMappSubindex++) {
+			// read object mapping from OD
+			ObdSize = sizeof(qwObjectMapping);	// QWORD
+			Ret = EplObduReadEntry(pParam_p->m_uiIndex,
+					       bMappSubindex, &qwObjectMapping,
+					       &ObdSize);
+			if (Ret != kEplSuccessful) {	// other fatal error occured
+				pParam_p->m_dwAbortCode =
+				    EPL_SDOAC_GENERAL_ERROR;
+				goto Exit;
+			}
+			// check object mapping
+			Ret = EplPdouCheckObjectMapping(qwObjectMapping,
+							AccessType,
+							&pParam_p->
+							m_dwAbortCode,
+							&uiCurPdoSize);
+			if (Ret != kEplSuccessful) {	// illegal object mapping
+				goto Exit;
+			}
+
+			if (uiCurPdoSize > wMaxPdoSize) {	// mapping exceeds object size
+				pParam_p->m_dwAbortCode =
+				    EPL_SDOAC_GENERAL_ERROR;
+				Ret = kEplPdoVarNotFound;
+			}
+
+		}
+
+	} else {		// ObjectMapping
+		Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
+		if (Ret != kEplSuccessful) {	// PDO is valid or does not exist
+			goto Exit;
+		}
+		// check existence of object and validity of object length
+
+		qwObjectMapping = *((QWORD *) pParam_p->m_pArg);
+
+		Ret = EplPdouCheckObjectMapping(qwObjectMapping,
+						AccessType,
+						&pParam_p->m_dwAbortCode,
+						&uiCurPdoSize);
+
+	}
+
+      Exit:
+	return Ret;
 }
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -419,33 +394,32 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM* pParam_p, unsigned int uiIndex_p)
+static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM * pParam_p,
+					  unsigned int uiIndex_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplObdSize         ObdSize;
-BYTE                bObjectCount;
-
-    ObdSize = 1;
-    // read number of mapped objects from OD; this indicates if the PDO is valid
-    Ret = EplObduReadEntry(uiIndex_p, 0x00, &bObjectCount, &ObdSize);
-    if (Ret != kEplSuccessful)
-    {   // other fatal error occured
-        pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_INTERNAL_INCOMPATIBILITY;
-        goto Exit;
-    }
-    // entry read successfully
-    if (bObjectCount != 0)
-    {   // PDO in OD is still valid
-        pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_PARAM_INCOMPATIBILITY;
-        Ret = kEplPdoNotExist;
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	tEplObdSize ObdSize;
+	BYTE bObjectCount;
+
+	ObdSize = 1;
+	// read number of mapped objects from OD; this indicates if the PDO is valid
+	Ret = EplObduReadEntry(uiIndex_p, 0x00, &bObjectCount, &ObdSize);
+	if (Ret != kEplSuccessful) {	// other fatal error occured
+		pParam_p->m_dwAbortCode =
+		    EPL_SDOAC_GEN_INTERNAL_INCOMPATIBILITY;
+		goto Exit;
+	}
+	// entry read successfully
+	if (bObjectCount != 0) {	// PDO in OD is still valid
+		pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_PARAM_INCOMPATIBILITY;
+		Ret = kEplPdoNotExist;
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdouDecodeObjectMapping
@@ -466,26 +440,25 @@ Exit:
 //---------------------------------------------------------------------------
 
 static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
-                                    unsigned int* puiIndex_p,
-                                    unsigned int* puiSubIndex_p,
-                                    unsigned int* puiBitOffset_p,
-                                    unsigned int* puiBitSize_p)
+				       unsigned int *puiIndex_p,
+				       unsigned int *puiSubIndex_p,
+				       unsigned int *puiBitOffset_p,
+				       unsigned int *puiBitSize_p)
 {
-    *puiIndex_p = (unsigned int)
-                    (qwObjectMapping_p & 0x000000000000FFFFLL);
+	*puiIndex_p = (unsigned int)
+	    (qwObjectMapping_p & 0x000000000000FFFFLL);
 
-    *puiSubIndex_p = (unsigned int)
-                    ((qwObjectMapping_p & 0x0000000000FF0000LL) >> 16);
+	*puiSubIndex_p = (unsigned int)
+	    ((qwObjectMapping_p & 0x0000000000FF0000LL) >> 16);
 
-    *puiBitOffset_p = (unsigned int)
-                    ((qwObjectMapping_p & 0x0000FFFF00000000LL) >> 32);
+	*puiBitOffset_p = (unsigned int)
+	    ((qwObjectMapping_p & 0x0000FFFF00000000LL) >> 32);
 
-    *puiBitSize_p = (unsigned int)
-                    ((qwObjectMapping_p & 0xFFFF000000000000LL) >> 48);
+	*puiBitSize_p = (unsigned int)
+	    ((qwObjectMapping_p & 0xFFFF000000000000LL) >> 48);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplPdouCheckObjectMapping
@@ -508,101 +481,85 @@ static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
 //---------------------------------------------------------------------------
 
 static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
-                                       tEplObdAccess AccessType_p,
-                                       DWORD* pdwAbortCode_p,
-                                       unsigned int* puiPdoSize_p)
+					    tEplObdAccess AccessType_p,
+					    DWORD * pdwAbortCode_p,
+					    unsigned int *puiPdoSize_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplObdSize         ObdSize;
-unsigned int        uiIndex;
-unsigned int        uiSubIndex;
-unsigned int        uiBitOffset;
-unsigned int        uiBitSize;
-tEplObdAccess       AccessType;
-BOOL                fNumerical;
-
-    if (qwObjectMapping_p == 0)
-    {   // discard zero value
-        *puiPdoSize_p = 0;
-        goto Exit;
-    }
-
-    // decode object mapping
-    EplPdouDecodeObjectMapping(qwObjectMapping_p,
-                               &uiIndex,
-                               &uiSubIndex,
-                               &uiBitOffset,
-                               &uiBitSize);
-
-    if ((uiBitOffset & 0x7) != 0x0)
-    {   // bit mapping is not supported
-        *pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
-        Ret = kEplPdoGranularityMismatch;
-        goto Exit;
-    }
-
-    if ((uiBitSize & 0x7) != 0x0)
-    {   // bit mapping is not supported
-        *pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
-        Ret = kEplPdoGranularityMismatch;
-        goto Exit;
-    }
-
-    // check access type
-    Ret = EplObduGetAccessType(uiIndex, uiSubIndex, &AccessType);
-    if (Ret != kEplSuccessful)
-    {   // entry doesn't exist
-        *pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
-        goto Exit;
-    }
-
-    if ((AccessType & kEplObdAccPdo) == 0)
-    {   // object is not mappable
-        *pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
-        Ret = kEplPdoVarNotFound;
-        goto Exit;
-    }
-
-    if ((AccessType & AccessType_p) == 0)
-    {   // object is not writeable (RPDO) or readable (TPDO) respectively
-        *pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
-        Ret = kEplPdoVarNotFound;
-        goto Exit;
-    }
-
-    ObdSize = EplObduGetDataSize(uiIndex, uiSubIndex);
-    if (ObdSize < (uiBitSize >> 3))
-    {   // object does not exist or has smaller size
-        *pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
-        Ret = kEplPdoVarNotFound;
-    }
-
-    Ret = EplObduIsNumerical(uiIndex, uiSubIndex, &fNumerical);
-    if (Ret != kEplSuccessful)
-    {   // entry doesn't exist
-        *pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
-        goto Exit;
-    }
-
-    if ((fNumerical != FALSE)
-        && ((uiBitSize >> 3) != ObdSize))
-    {
-        // object is numerical,
-        // therefor size has to fit, but it does not.
-        *pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
-        Ret = kEplPdoVarNotFound;
-        goto Exit;
-    }
-
-    // calucaled needed PDO size
-    *puiPdoSize_p = (uiBitOffset >> 3) + (uiBitSize >> 3);
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	tEplObdSize ObdSize;
+	unsigned int uiIndex;
+	unsigned int uiSubIndex;
+	unsigned int uiBitOffset;
+	unsigned int uiBitSize;
+	tEplObdAccess AccessType;
+	BOOL fNumerical;
+
+	if (qwObjectMapping_p == 0) {	// discard zero value
+		*puiPdoSize_p = 0;
+		goto Exit;
+	}
+	// decode object mapping
+	EplPdouDecodeObjectMapping(qwObjectMapping_p,
+				   &uiIndex,
+				   &uiSubIndex, &uiBitOffset, &uiBitSize);
+
+	if ((uiBitOffset & 0x7) != 0x0) {	// bit mapping is not supported
+		*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
+		Ret = kEplPdoGranularityMismatch;
+		goto Exit;
+	}
+
+	if ((uiBitSize & 0x7) != 0x0) {	// bit mapping is not supported
+		*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
+		Ret = kEplPdoGranularityMismatch;
+		goto Exit;
+	}
+	// check access type
+	Ret = EplObduGetAccessType(uiIndex, uiSubIndex, &AccessType);
+	if (Ret != kEplSuccessful) {	// entry doesn't exist
+		*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
+		goto Exit;
+	}
+
+	if ((AccessType & kEplObdAccPdo) == 0) {	// object is not mappable
+		*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
+		Ret = kEplPdoVarNotFound;
+		goto Exit;
+	}
+
+	if ((AccessType & AccessType_p) == 0) {	// object is not writeable (RPDO) or readable (TPDO) respectively
+		*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
+		Ret = kEplPdoVarNotFound;
+		goto Exit;
+	}
+
+	ObdSize = EplObduGetDataSize(uiIndex, uiSubIndex);
+	if (ObdSize < (uiBitSize >> 3)) {	// object does not exist or has smaller size
+		*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
+		Ret = kEplPdoVarNotFound;
+	}
+
+	Ret = EplObduIsNumerical(uiIndex, uiSubIndex, &fNumerical);
+	if (Ret != kEplSuccessful) {	// entry doesn't exist
+		*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
+		goto Exit;
+	}
+
+	if ((fNumerical != FALSE)
+	    && ((uiBitSize >> 3) != ObdSize)) {
+		// object is numerical,
+		// therefor size has to fit, but it does not.
+		*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
+		Ret = kEplPdoVarNotFound;
+		goto Exit;
+	}
+	// calucaled needed PDO size
+	*puiPdoSize_p = (uiBitOffset >> 3) + (uiBitSize >> 3);
+
+      Exit:
+	return Ret;
 }
 
-
 #endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOU)) != 0)
 
 // EOF
-

+ 174 - 200
drivers/staging/epl/EplSdoAsndu.c

@@ -94,11 +94,9 @@
 //---------------------------------------------------------------------------
 
 // instance table
-typedef struct
-{
-    unsigned int            m_auiSdoAsndConnection[EPL_SDO_MAX_CONNECTION_ASND];
-    tEplSequLayerReceiveCb  m_fpSdoAsySeqCb;
-
+typedef struct {
+	unsigned int m_auiSdoAsndConnection[EPL_SDO_MAX_CONNECTION_ASND];
+	tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
 
 } tEplSdoAsndInstance;
 
@@ -106,7 +104,7 @@ typedef struct
 // modul globale vars
 //---------------------------------------------------------------------------
 
-static tEplSdoAsndInstance  SdoAsndInstance_g;
+static tEplSdoAsndInstance SdoAsndInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
@@ -127,8 +125,6 @@ tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p);
 //
 /***************************************************************************/
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -155,15 +151,13 @@ tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p);
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoAsnduInit(tEplSequLayerReceiveCb fpReceiveCb_p)
 {
-tEplKernel  Ret;
-
+	tEplKernel Ret;
 
-    Ret = EplSdoAsnduAddInstance(fpReceiveCb_p);
+	Ret = EplSdoAsnduAddInstance(fpReceiveCb_p);
 
-return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplSdoAsnduAddInstance
@@ -184,30 +178,26 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoAsnduAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // init control structure
-    EPL_MEMSET(&SdoAsndInstance_g, 0x00, sizeof(SdoAsndInstance_g));
+	// init control structure
+	EPL_MEMSET(&SdoAsndInstance_g, 0x00, sizeof(SdoAsndInstance_g));
 
-    // save pointer to callback-function
-    if (fpReceiveCb_p != NULL)
-    {
-        SdoAsndInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
-    }
-    else
-    {
-        Ret = kEplSdoUdpMissCb;
-    }
+	// save pointer to callback-function
+	if (fpReceiveCb_p != NULL) {
+		SdoAsndInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
+	} else {
+		Ret = kEplSdoUdpMissCb;
+	}
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
-                                   EplSdoAsnduCb,
-                                   kEplDllAsndFilterLocal);
+	Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
+				       EplSdoAsnduCb, kEplDllAsndFilterLocal);
 #endif
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -230,21 +220,19 @@ tEplKernel  Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoAsnduDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    // deregister callback function from DLL
-    Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
-                                   NULL,
-                                   kEplDllAsndFilterNone);
+	// deregister callback function from DLL
+	Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
+				       NULL, kEplDllAsndFilterNone);
 #endif
 
-return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplSdoAsnduInitCon
@@ -263,61 +251,53 @@ return Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplSdoAsnduInitCon(tEplSdoConHdl*  pSdoConHandle_p,
-                               unsigned int    uiTargetNodeId_p)
+tEplKernel PUBLIC EplSdoAsnduInitCon(tEplSdoConHdl * pSdoConHandle_p,
+				     unsigned int uiTargetNodeId_p)
 {
-tEplKernel      Ret;
-unsigned int    uiCount;
-unsigned int    uiFreeCon;
-unsigned int*   puiConnection;
-
-    Ret = kEplSuccessful;
-
-    if ((uiTargetNodeId_p == EPL_C_ADR_INVALID)
-        || (uiTargetNodeId_p >= EPL_C_ADR_BROADCAST))
-    {
-        Ret = kEplSdoAsndInvalidNodeId;
-        goto Exit;
-    }
-
-    // get free entry in control structure
-    uiCount = 0;
-    uiFreeCon = EPL_SDO_MAX_CONNECTION_ASND;
-    puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
-    while(uiCount < EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        if (*puiConnection == uiTargetNodeId_p)
-        {   // existing connection to target node found
-            // save handle for higher layer
-            *pSdoConHandle_p = (uiCount | EPL_SDO_ASND_HANDLE );
-
-            goto Exit;
-        }
-        else if (*puiConnection == 0)
-        {   // free entry-> save target nodeId
-            uiFreeCon = uiCount;
-        }
-        uiCount++;
-        puiConnection++;
-    }
-
-    if (uiFreeCon == EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        // no free connection
-        Ret = kEplSdoAsndNoFreeHandle;
-    }
-    else
-    {
-        puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeCon];
-        *puiConnection = uiTargetNodeId_p;
-        // save handle for higher layer
-        *pSdoConHandle_p = (uiFreeCon | EPL_SDO_ASND_HANDLE );
-
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	unsigned int uiCount;
+	unsigned int uiFreeCon;
+	unsigned int *puiConnection;
+
+	Ret = kEplSuccessful;
+
+	if ((uiTargetNodeId_p == EPL_C_ADR_INVALID)
+	    || (uiTargetNodeId_p >= EPL_C_ADR_BROADCAST)) {
+		Ret = kEplSdoAsndInvalidNodeId;
+		goto Exit;
+	}
+	// get free entry in control structure
+	uiCount = 0;
+	uiFreeCon = EPL_SDO_MAX_CONNECTION_ASND;
+	puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
+	while (uiCount < EPL_SDO_MAX_CONNECTION_ASND) {
+		if (*puiConnection == uiTargetNodeId_p) {	// existing connection to target node found
+			// save handle for higher layer
+			*pSdoConHandle_p = (uiCount | EPL_SDO_ASND_HANDLE);
+
+			goto Exit;
+		} else if (*puiConnection == 0) {	// free entry-> save target nodeId
+			uiFreeCon = uiCount;
+		}
+		uiCount++;
+		puiConnection++;
+	}
+
+	if (uiFreeCon == EPL_SDO_MAX_CONNECTION_ASND) {
+		// no free connection
+		Ret = kEplSdoAsndNoFreeHandle;
+	} else {
+		puiConnection =
+		    &SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeCon];
+		*puiConnection = uiTargetNodeId_p;
+		// save handle for higher layer
+		*pSdoConHandle_p = (uiFreeCon | EPL_SDO_ASND_HANDLE);
+
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -339,47 +319,47 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplSdoAsnduSendData(tEplSdoConHdl       SdoConHandle_p,
-                                    tEplFrame *          pSrcData_p,
-                                    DWORD                dwDataSize_p)
+tEplKernel PUBLIC EplSdoAsnduSendData(tEplSdoConHdl SdoConHandle_p,
+				      tEplFrame * pSrcData_p,
+				      DWORD dwDataSize_p)
 {
-tEplKernel      Ret;
-unsigned int    uiArray;
-tEplFrameInfo   FrameInfo;
-
-    Ret = kEplSuccessful;
-
-    uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
-
-    if(uiArray > EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        Ret = kEplSdoAsndInvalidHandle;
-        goto Exit;
-    }
-
-    // fillout Asnd header
-    // own node id not needed -> filled by DLL
-
-    // set message type
-    AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, (BYTE)kEplMsgTypeAsnd); // ASnd == 0x06
-    // target node id
-    AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, (BYTE) SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray]);
-    // set source-nodeid (filled by DLL 0)
-    AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
-
-    // calc size
-    dwDataSize_p += EPL_ASND_HEADER_SIZE;
-
-    // send function of DLL
-    FrameInfo.m_uiFrameSize = dwDataSize_p;
-    FrameInfo.m_pFrame = pSrcData_p;
-    EPL_MEMSET(&FrameInfo.m_NetTime , 0x00, sizeof(tEplNetTime));
+	tEplKernel Ret;
+	unsigned int uiArray;
+	tEplFrameInfo FrameInfo;
+
+	Ret = kEplSuccessful;
+
+	uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
+
+	if (uiArray > EPL_SDO_MAX_CONNECTION_ASND) {
+		Ret = kEplSdoAsndInvalidHandle;
+		goto Exit;
+	}
+	// fillout Asnd header
+	// own node id not needed -> filled by DLL
+
+	// set message type
+	AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, (BYTE) kEplMsgTypeAsnd);	// ASnd == 0x06
+	// target node id
+	AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId,
+		       (BYTE) SdoAsndInstance_g.
+		       m_auiSdoAsndConnection[uiArray]);
+	// set source-nodeid (filled by DLL 0)
+	AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
+
+	// calc size
+	dwDataSize_p += EPL_ASND_HEADER_SIZE;
+
+	// send function of DLL
+	FrameInfo.m_uiFrameSize = dwDataSize_p;
+	FrameInfo.m_pFrame = pSrcData_p;
+	EPL_MEMSET(&FrameInfo.m_NetTime, 0x00, sizeof(tEplNetTime));
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
-    Ret = EplDlluCalAsyncSend(&FrameInfo,kEplDllAsyncReqPrioGeneric);
+	Ret = EplDlluCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
 #endif
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
@@ -401,25 +381,22 @@ Exit:
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoAsnduDelCon(tEplSdoConHdl SdoConHandle_p)
 {
-tEplKernel  Ret;
-unsigned int    uiArray;
-
-    Ret = kEplSuccessful;
-
-
-    uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
-    // check parameter
-    if(uiArray > EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        Ret = kEplSdoAsndInvalidHandle;
-        goto Exit;
-    }
-
-    // set target nodeId to 0
-    SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray] = 0;
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	unsigned int uiArray;
+
+	Ret = kEplSuccessful;
+
+	uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
+	// check parameter
+	if (uiArray > EPL_SDO_MAX_CONNECTION_ASND) {
+		Ret = kEplSdoAsndInvalidHandle;
+		goto Exit;
+	}
+	// set target nodeId to 0
+	SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray] = 0;
+
+      Exit:
+	return Ret;
 }
 
 //=========================================================================//
@@ -447,63 +424,60 @@ Exit:
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-unsigned int    uiCount;
-unsigned int*   puiConnection;
-unsigned int    uiNodeId;
-unsigned int    uiFreeEntry = 0xFFFF;
-tEplSdoConHdl   SdoConHdl;
-tEplFrame*      pFrame;
-
-    pFrame = pFrameInfo_p->m_pFrame;
-
-    uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
-
-    // search corresponding entry in control structure
-    uiCount = 0;
-    puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
-    while (uiCount < EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        if (uiNodeId == *puiConnection)
-        {
-            break;
-        }
-        else if ((*puiConnection == 0)
-            && (uiFreeEntry == 0xFFFF))
-        {   // free entry
-            uiFreeEntry = uiCount;
-        }
-        uiCount++;
-        puiConnection++;
-    }
-
-    if (uiCount == EPL_SDO_MAX_CONNECTION_ASND)
-    {
-        if (uiFreeEntry != 0xFFFF)
-        {
-            puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeEntry];
-            *puiConnection = uiNodeId;
-            uiCount = uiFreeEntry;
-        }
-        else
-        {
-            EPL_DBGLVL_SDO_TRACE0("EplSdoAsnduCb(): no free handle\n");
-            goto Exit;
-        }
-    }
+	tEplKernel Ret = kEplSuccessful;
+	unsigned int uiCount;
+	unsigned int *puiConnection;
+	unsigned int uiNodeId;
+	unsigned int uiFreeEntry = 0xFFFF;
+	tEplSdoConHdl SdoConHdl;
+	tEplFrame *pFrame;
+
+	pFrame = pFrameInfo_p->m_pFrame;
+
+	uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
+
+	// search corresponding entry in control structure
+	uiCount = 0;
+	puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
+	while (uiCount < EPL_SDO_MAX_CONNECTION_ASND) {
+		if (uiNodeId == *puiConnection) {
+			break;
+		} else if ((*puiConnection == 0)
+			   && (uiFreeEntry == 0xFFFF)) {	// free entry
+			uiFreeEntry = uiCount;
+		}
+		uiCount++;
+		puiConnection++;
+	}
+
+	if (uiCount == EPL_SDO_MAX_CONNECTION_ASND) {
+		if (uiFreeEntry != 0xFFFF) {
+			puiConnection =
+			    &SdoAsndInstance_g.
+			    m_auiSdoAsndConnection[uiFreeEntry];
+			*puiConnection = uiNodeId;
+			uiCount = uiFreeEntry;
+		} else {
+			EPL_DBGLVL_SDO_TRACE0
+			    ("EplSdoAsnduCb(): no free handle\n");
+			goto Exit;
+		}
+	}
 //    if (uiNodeId == *puiConnection)
-    {   // entry found or created
-        SdoConHdl = (uiCount | EPL_SDO_ASND_HANDLE );
+	{			// entry found or created
+		SdoConHdl = (uiCount | EPL_SDO_ASND_HANDLE);
 
-        SdoAsndInstance_g.m_fpSdoAsySeqCb(SdoConHdl, &pFrame->m_Data.m_Asnd.m_Payload.m_SdoSequenceFrame, (pFrameInfo_p->m_uiFrameSize - 18));
-    }
+		SdoAsndInstance_g.m_fpSdoAsySeqCb(SdoConHdl,
+						  &pFrame->m_Data.m_Asnd.
+						  m_Payload.m_SdoSequenceFrame,
+						  (pFrameInfo_p->m_uiFrameSize -
+						   18));
+	}
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
-
 #endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_ASND)) != 0)
 // EOF
-

File diff suppressed because it is too large
+ 404 - 466
drivers/staging/epl/EplSdoAsySequ.c


File diff suppressed because it is too large
+ 408 - 465
drivers/staging/epl/EplSdoComu.c


+ 374 - 405
drivers/staging/epl/EplSdoUdpu.c

@@ -68,7 +68,6 @@
 
 ****************************************************************************/
 
-
 #include "user/EplSdoUdpu.h"
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
@@ -79,7 +78,6 @@
 #include <linux/sched.h>
 #endif
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -100,29 +98,27 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    unsigned long   m_ulIpAddr;     // in network byte order
-    unsigned int    m_uiPort;       // in network byte order
+typedef struct {
+	unsigned long m_ulIpAddr;	// in network byte order
+	unsigned int m_uiPort;	// in network byte order
 
 } tEplSdoUdpCon;
 
 // instance table
-typedef struct
-{
-    tEplSdoUdpCon           m_aSdoAbsUdpConnection[EPL_SDO_MAX_CONNECTION_UDP];
-    tEplSequLayerReceiveCb  m_fpSdoAsySeqCb;
-    SOCKET                  m_UdpSocket;
+typedef struct {
+	tEplSdoUdpCon m_aSdoAbsUdpConnection[EPL_SDO_MAX_CONNECTION_UDP];
+	tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
+	SOCKET m_UdpSocket;
 
 #if (TARGET_SYSTEM == _WIN32_)
-    HANDLE                  m_ThreadHandle;
-    LPCRITICAL_SECTION      m_pCriticalSection;
-    CRITICAL_SECTION        m_CriticalSection;
+	HANDLE m_ThreadHandle;
+	LPCRITICAL_SECTION m_pCriticalSection;
+	CRITICAL_SECTION m_CriticalSection;
 
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-    struct completion       m_CompletionUdpThread;
-    int                     m_ThreadHandle;
-    int                     m_iTerminateThread;
+	struct completion m_CompletionUdpThread;
+	int m_ThreadHandle;
+	int m_iTerminateThread;
 #endif
 
 } tEplSdoUdpInstance;
@@ -131,7 +127,7 @@ typedef struct
 // modul globale vars
 //---------------------------------------------------------------------------
 
-static tEplSdoUdpInstance  SdoUdpInstance_g;
+static tEplSdoUdpInstance SdoUdpInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
@@ -141,7 +137,7 @@ static tEplSdoUdpInstance  SdoUdpInstance_g;
 static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter);
 
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-static int EplSdoUdpThread(void * pArg_p);
+static int EplSdoUdpThread(void *pArg_p);
 #endif
 
 /***************************************************************************/
@@ -157,8 +153,6 @@ static int EplSdoUdpThread(void * pArg_p);
 //
 /***************************************************************************/
 
-
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -185,12 +179,11 @@ static int EplSdoUdpThread(void * pArg_p);
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoUdpuInit(tEplSequLayerReceiveCb fpReceiveCb_p)
 {
-tEplKernel  Ret;
-
+	tEplKernel Ret;
 
-    Ret = EplSdoUdpuAddInstance(fpReceiveCb_p);
+	Ret = EplSdoUdpuAddInstance(fpReceiveCb_p);
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -214,59 +207,54 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
 {
-tEplKernel          Ret;
+	tEplKernel Ret;
 
 #if (TARGET_SYSTEM == _WIN32_)
-int                 iError;
-WSADATA             Wsa;
+	int iError;
+	WSADATA Wsa;
 
 #endif
 
-    // set instance variables to 0
-    EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g));
+	// set instance variables to 0
+	EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g));
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // save pointer to callback-function
-    if (fpReceiveCb_p != NULL)
-    {
-        SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
-    }
-    else
-    {
-        Ret = kEplSdoUdpMissCb;
-        goto Exit;
-    }
+	// save pointer to callback-function
+	if (fpReceiveCb_p != NULL) {
+		SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
+	} else {
+		Ret = kEplSdoUdpMissCb;
+		goto Exit;
+	}
 
 #if (TARGET_SYSTEM == _WIN32_)
-    // start winsock2 for win32
-    // windows specific start of socket
-    iError = WSAStartup(MAKEWORD(2,0),&Wsa);
-    if (iError != 0)
-    {
-        Ret = kEplSdoUdpNoSocket;
-        goto Exit;
-    }
-
-    // create critical section for acccess of instnace variables
-    SdoUdpInstance_g.m_pCriticalSection = &SdoUdpInstance_g.m_CriticalSection;
-    InitializeCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+	// start winsock2 for win32
+	// windows specific start of socket
+	iError = WSAStartup(MAKEWORD(2, 0), &Wsa);
+	if (iError != 0) {
+		Ret = kEplSdoUdpNoSocket;
+		goto Exit;
+	}
+	// create critical section for acccess of instnace variables
+	SdoUdpInstance_g.m_pCriticalSection =
+	    &SdoUdpInstance_g.m_CriticalSection;
+	InitializeCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
 
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-    init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
-    SdoUdpInstance_g.m_iTerminateThread = 0;
+	init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
+	SdoUdpInstance_g.m_iTerminateThread = 0;
 #endif
 
-    SdoUdpInstance_g.m_ThreadHandle = 0;
-    SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
+	SdoUdpInstance_g.m_ThreadHandle = 0;
+	SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
 
-    Ret = EplSdoUdpuConfig(INADDR_ANY, 0);
+	Ret = EplSdoUdpuConfig(INADDR_ANY, 0);
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplSdoUdpuDelInstance
@@ -287,56 +275,52 @@ Exit:
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoUdpuDelInstance()
 {
-tEplKernel      Ret;
+	tEplKernel Ret;
 
 #if (TARGET_SYSTEM == _WIN32_)
-BOOL                fTermError;
+	BOOL fTermError;
 #endif
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    if (SdoUdpInstance_g.m_ThreadHandle != 0)
-    {   // listen thread was started
-        // close thread
+	if (SdoUdpInstance_g.m_ThreadHandle != 0) {	// listen thread was started
+		// close thread
 #if (TARGET_SYSTEM == _WIN32_)
-        fTermError = TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
-        if(fTermError == FALSE)
-        {
-            Ret = kEplSdoUdpThreadError;
-            goto Exit;
-        }
-
+		fTermError =
+		    TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
+		if (fTermError == FALSE) {
+			Ret = kEplSdoUdpThreadError;
+			goto Exit;
+		}
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-        SdoUdpInstance_g.m_iTerminateThread = 1;
-        /* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
-        send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
-        wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
+		SdoUdpInstance_g.m_iTerminateThread = 1;
+		/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
+		send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
+		wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
 #endif
 
-        SdoUdpInstance_g.m_ThreadHandle = 0;
-    }
-
-    if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET)
-    {
-        // close socket
-        closesocket(SdoUdpInstance_g.m_UdpSocket);
-        SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
-    }
+		SdoUdpInstance_g.m_ThreadHandle = 0;
+	}
 
+	if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET) {
+		// close socket
+		closesocket(SdoUdpInstance_g.m_UdpSocket);
+		SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
+	}
 #if (TARGET_SYSTEM == _WIN32_)
-    // delete critical section
-    DeleteCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+	// delete critical section
+	DeleteCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
 #endif
 
 #if (TARGET_SYSTEM == _WIN32_)
-    // for win 32
-    WSACleanup();
+	// for win 32
+	WSACleanup();
 #endif
 
 #if (TARGET_SYSTEM == _WIN32_)
-Exit:
+      Exit:
 #endif
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -356,120 +340,107 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
+tEplKernel PUBLIC EplSdoUdpuConfig(unsigned long ulIpAddr_p,
+				   unsigned int uiPort_p)
 {
-tEplKernel          Ret;
-struct sockaddr_in  Addr;
-int                 iError;
+	tEplKernel Ret;
+	struct sockaddr_in Addr;
+	int iError;
 
 #if (TARGET_SYSTEM == _WIN32_)
-BOOL                fTermError;
-unsigned long       ulThreadId;
+	BOOL fTermError;
+	unsigned long ulThreadId;
 #endif
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    if (uiPort_p == 0)
-    {   // set UDP port to default port number
-        uiPort_p = EPL_C_SDO_EPL_PORT;
-    }
-    else if (uiPort_p > 65535)
-    {
-        Ret = kEplSdoUdpSocketError;
-        goto Exit;
-    }
+	if (uiPort_p == 0) {	// set UDP port to default port number
+		uiPort_p = EPL_C_SDO_EPL_PORT;
+	} else if (uiPort_p > 65535) {
+		Ret = kEplSdoUdpSocketError;
+		goto Exit;
+	}
 
-    if (SdoUdpInstance_g.m_ThreadHandle != 0)
-    {   // listen thread was started
+	if (SdoUdpInstance_g.m_ThreadHandle != 0) {	// listen thread was started
 
-        // close old thread
+		// close old thread
 #if (TARGET_SYSTEM == _WIN32_)
-        fTermError = TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
-        if(fTermError == FALSE)
-        {
-            Ret = kEplSdoUdpThreadError;
-            goto Exit;
-        }
-
+		fTermError =
+		    TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
+		if (fTermError == FALSE) {
+			Ret = kEplSdoUdpThreadError;
+			goto Exit;
+		}
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-        SdoUdpInstance_g.m_iTerminateThread = 1;
-        /* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
-        send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
-        wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
-        SdoUdpInstance_g.m_iTerminateThread = 0;
+		SdoUdpInstance_g.m_iTerminateThread = 1;
+		/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
+		send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
+		wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
+		SdoUdpInstance_g.m_iTerminateThread = 0;
 #endif
 
-        SdoUdpInstance_g.m_ThreadHandle = 0;
-    }
-
-    if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET)
-    {
-        // close socket
-        iError = closesocket(SdoUdpInstance_g.m_UdpSocket);
-        SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
-        if(iError != 0)
-        {
-            Ret = kEplSdoUdpSocketError;
-            goto Exit;
-        }
-    }
-
-    // create Socket
-    SdoUdpInstance_g.m_UdpSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-    if (SdoUdpInstance_g.m_UdpSocket == INVALID_SOCKET)
-    {
-        Ret = kEplSdoUdpNoSocket;
-        EPL_DBGLVL_SDO_TRACE0("EplSdoUdpuConfig: socket() failed\n");
-        goto Exit;
-    }
-
-    // bind socket
-    Addr.sin_family = AF_INET;
-    Addr.sin_port = htons((unsigned short) uiPort_p);
-    Addr.sin_addr.s_addr = htonl(ulIpAddr_p);
-    iError = bind(SdoUdpInstance_g.m_UdpSocket, (struct sockaddr*)&Addr, sizeof (Addr));
-    if (iError < 0)
-    {
-        //iError = WSAGetLastError();
-        EPL_DBGLVL_SDO_TRACE1("EplSdoUdpuConfig: bind() finished with %i\n", iError);
-        Ret = kEplSdoUdpNoSocket;
-        goto Exit;
-    }
-
-    // create Listen-Thread
+		SdoUdpInstance_g.m_ThreadHandle = 0;
+	}
+
+	if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET) {
+		// close socket
+		iError = closesocket(SdoUdpInstance_g.m_UdpSocket);
+		SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
+		if (iError != 0) {
+			Ret = kEplSdoUdpSocketError;
+			goto Exit;
+		}
+	}
+	// create Socket
+	SdoUdpInstance_g.m_UdpSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+	if (SdoUdpInstance_g.m_UdpSocket == INVALID_SOCKET) {
+		Ret = kEplSdoUdpNoSocket;
+		EPL_DBGLVL_SDO_TRACE0("EplSdoUdpuConfig: socket() failed\n");
+		goto Exit;
+	}
+	// bind socket
+	Addr.sin_family = AF_INET;
+	Addr.sin_port = htons((unsigned short)uiPort_p);
+	Addr.sin_addr.s_addr = htonl(ulIpAddr_p);
+	iError =
+	    bind(SdoUdpInstance_g.m_UdpSocket, (struct sockaddr *)&Addr,
+		 sizeof(Addr));
+	if (iError < 0) {
+		//iError = WSAGetLastError();
+		EPL_DBGLVL_SDO_TRACE1
+		    ("EplSdoUdpuConfig: bind() finished with %i\n", iError);
+		Ret = kEplSdoUdpNoSocket;
+		goto Exit;
+	}
+	// create Listen-Thread
 #if (TARGET_SYSTEM == _WIN32_)
-    // for win32
-
-    // create thread
-    SdoUdpInstance_g.m_ThreadHandle = CreateThread(NULL,
-                                                    0,
-                                                    EplSdoUdpThread,
-                                                    &SdoUdpInstance_g,
-                                                    0,
-                                                    &ulThreadId);
-    if(SdoUdpInstance_g.m_ThreadHandle == NULL)
-    {
-        Ret = kEplSdoUdpThreadError;
-        goto Exit;
-    }
-
+	// for win32
+
+	// create thread
+	SdoUdpInstance_g.m_ThreadHandle = CreateThread(NULL,
+						       0,
+						       EplSdoUdpThread,
+						       &SdoUdpInstance_g,
+						       0, &ulThreadId);
+	if (SdoUdpInstance_g.m_ThreadHandle == NULL) {
+		Ret = kEplSdoUdpThreadError;
+		goto Exit;
+	}
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
 
-    SdoUdpInstance_g.m_ThreadHandle = kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
-    if(SdoUdpInstance_g.m_ThreadHandle == 0)
-    {
-        Ret = kEplSdoUdpThreadError;
-        goto Exit;
-    }
+	SdoUdpInstance_g.m_ThreadHandle =
+	    kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
+	if (SdoUdpInstance_g.m_ThreadHandle == 0) {
+		Ret = kEplSdoUdpThreadError;
+		goto Exit;
+	}
 #endif
 
-
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplSdoUdpuInitCon
@@ -488,57 +459,51 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplSdoUdpuInitCon(tEplSdoConHdl*  pSdoConHandle_p,
-                                    unsigned int    uiTargetNodeId_p)
+tEplKernel PUBLIC EplSdoUdpuInitCon(tEplSdoConHdl * pSdoConHandle_p,
+				    unsigned int uiTargetNodeId_p)
 {
-tEplKernel          Ret;
-unsigned int        uiCount;
-unsigned int        uiFreeCon;
-tEplSdoUdpCon*      pSdoUdpCon;
-
-    Ret = kEplSuccessful;
-
-    // get free entry in control structure
-    uiCount = 0;
-    uiFreeCon = EPL_SDO_MAX_CONNECTION_UDP;
-    pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[0];
-    while (uiCount < EPL_SDO_MAX_CONNECTION_UDP)
-    {
-        if ((pSdoUdpCon->m_ulIpAddr & htonl(0xFF)) == htonl(uiTargetNodeId_p))
-        {   // existing connection to target node found
-            // set handle
-            *pSdoConHandle_p = (uiCount | EPL_SDO_UDP_HANDLE);
-
-            goto Exit;
-        }
-        else if ((pSdoUdpCon->m_ulIpAddr == 0)
-                && (pSdoUdpCon->m_uiPort == 0))
-        {
-            uiFreeCon = uiCount;
-        }
-        uiCount++;
-        pSdoUdpCon++;
-    }
-
-    if (uiFreeCon == EPL_SDO_MAX_CONNECTION_UDP)
-    {
-        // error no free handle
-        Ret = kEplSdoUdpNoFreeHandle;
-    }
-    else
-    {
-        pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiFreeCon];
-        // save infos for connection
-        pSdoUdpCon->m_uiPort = htons(EPL_C_SDO_EPL_PORT);
-        pSdoUdpCon->m_ulIpAddr = htonl(0xC0A86400 | uiTargetNodeId_p);   // 192.168.100.uiTargetNodeId_p
-
-        // set handle
-        *pSdoConHandle_p = (uiFreeCon | EPL_SDO_UDP_HANDLE);
-
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	unsigned int uiCount;
+	unsigned int uiFreeCon;
+	tEplSdoUdpCon *pSdoUdpCon;
+
+	Ret = kEplSuccessful;
+
+	// get free entry in control structure
+	uiCount = 0;
+	uiFreeCon = EPL_SDO_MAX_CONNECTION_UDP;
+	pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[0];
+	while (uiCount < EPL_SDO_MAX_CONNECTION_UDP) {
+		if ((pSdoUdpCon->m_ulIpAddr & htonl(0xFF)) == htonl(uiTargetNodeId_p)) {	// existing connection to target node found
+			// set handle
+			*pSdoConHandle_p = (uiCount | EPL_SDO_UDP_HANDLE);
+
+			goto Exit;
+		} else if ((pSdoUdpCon->m_ulIpAddr == 0)
+			   && (pSdoUdpCon->m_uiPort == 0)) {
+			uiFreeCon = uiCount;
+		}
+		uiCount++;
+		pSdoUdpCon++;
+	}
+
+	if (uiFreeCon == EPL_SDO_MAX_CONNECTION_UDP) {
+		// error no free handle
+		Ret = kEplSdoUdpNoFreeHandle;
+	} else {
+		pSdoUdpCon =
+		    &SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiFreeCon];
+		// save infos for connection
+		pSdoUdpCon->m_uiPort = htons(EPL_C_SDO_EPL_PORT);
+		pSdoUdpCon->m_ulIpAddr = htonl(0xC0A86400 | uiTargetNodeId_p);	// 192.168.100.uiTargetNodeId_p
+
+		// set handle
+		*pSdoConHandle_p = (uiFreeCon | EPL_SDO_UDP_HANDLE);
+
+	}
+
+      Exit:
+	return Ret;
 
 }
 
@@ -561,67 +526,67 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplSdoUdpuSendData(tEplSdoConHdl       SdoConHandle_p,
-                                    tEplFrame *          pSrcData_p,
-                                    DWORD                dwDataSize_p)
+tEplKernel PUBLIC EplSdoUdpuSendData(tEplSdoConHdl SdoConHandle_p,
+				     tEplFrame * pSrcData_p, DWORD dwDataSize_p)
 {
-tEplKernel          Ret;
-int                 iError;
-unsigned int        uiArray;
-struct sockaddr_in  Addr;
-
-    Ret = kEplSuccessful;
-
-    uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
-    if(uiArray >= EPL_SDO_MAX_CONNECTION_UDP)
-    {
-        Ret = kEplSdoUdpInvalidHdl;
-        goto Exit;
-    }
-    //set message type
-    AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, 0x06); // SDO
-    // target node id (for Udp = 0)
-    AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, 0x00);
-    // set source-nodeid (for Udp = 0)
-    AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
-
-    // calc size
-    dwDataSize_p += EPL_ASND_HEADER_SIZE;
-
-    // call sendto
-    Addr.sin_family = AF_INET;
+	tEplKernel Ret;
+	int iError;
+	unsigned int uiArray;
+	struct sockaddr_in Addr;
+
+	Ret = kEplSuccessful;
+
+	uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
+	if (uiArray >= EPL_SDO_MAX_CONNECTION_UDP) {
+		Ret = kEplSdoUdpInvalidHdl;
+		goto Exit;
+	}
+	//set message type
+	AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, 0x06);	// SDO
+	// target node id (for Udp = 0)
+	AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, 0x00);
+	// set source-nodeid (for Udp = 0)
+	AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
+
+	// calc size
+	dwDataSize_p += EPL_ASND_HEADER_SIZE;
+
+	// call sendto
+	Addr.sin_family = AF_INET;
 #if (TARGET_SYSTEM == _WIN32_)
-        // enter  critical section for process function
-    EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+	// enter  critical section for process function
+	EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
 #endif
 
-    Addr.sin_port = (unsigned short) SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort;
-    Addr.sin_addr.s_addr = SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr;
+	Addr.sin_port =
+	    (unsigned short)SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].
+	    m_uiPort;
+	Addr.sin_addr.s_addr =
+	    SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr;
 
 #if (TARGET_SYSTEM == _WIN32_)
-    // leave critical section for process function
-    LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+	// leave critical section for process function
+	LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
 #endif
 
-    iError = sendto (SdoUdpInstance_g.m_UdpSocket,       // sockethandle
-                (const char*) &pSrcData_p->m_le_bMessageType,        // data to send
-                dwDataSize_p,                          // number of bytes to send
-                0,                                     // flags
-                (struct sockaddr*)&Addr,                      // target
-                sizeof(struct sockaddr_in));                  // sizeof targetadress
-    if(iError < 0)
-    {
-        EPL_DBGLVL_SDO_TRACE1("EplSdoUdpuSendData: sendto() finished with %i\n", iError);
-        Ret = kEplSdoUdpSendError;
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	iError = sendto(SdoUdpInstance_g.m_UdpSocket,	// sockethandle
+			(const char *)&pSrcData_p->m_le_bMessageType,	// data to send
+			dwDataSize_p,	// number of bytes to send
+			0,	// flags
+			(struct sockaddr *)&Addr,	// target
+			sizeof(struct sockaddr_in));	// sizeof targetadress
+	if (iError < 0) {
+		EPL_DBGLVL_SDO_TRACE1
+		    ("EplSdoUdpuSendData: sendto() finished with %i\n", iError);
+		Ret = kEplSdoUdpSendError;
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplSdoUdpuDelCon
@@ -640,29 +605,24 @@ Exit:
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplSdoUdpuDelCon(tEplSdoConHdl SdoConHandle_p)
 {
-tEplKernel      Ret;
-unsigned int    uiArray;
+	tEplKernel Ret;
+	unsigned int uiArray;
 
+	uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
 
-    uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
+	if (uiArray >= EPL_SDO_MAX_CONNECTION_UDP) {
+		Ret = kEplSdoUdpInvalidHdl;
+		goto Exit;
+	} else {
+		Ret = kEplSuccessful;
+	}
 
-    if(uiArray >= EPL_SDO_MAX_CONNECTION_UDP)
-    {
-        Ret = kEplSdoUdpInvalidHdl;
-        goto Exit;
-    }
-    else
-    {
-        Ret = kEplSuccessful;
-    }
+	// delete connection
+	SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr = 0;
+	SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort = 0;
 
-
-    // delete connection
-    SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr = 0;
-    SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort = 0;
-
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
 //=========================================================================//
@@ -691,131 +651,140 @@ Exit:
 #if (TARGET_SYSTEM == _WIN32_)
 static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter)
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-static int EplSdoUdpThread(void * pArg_p)
+static int EplSdoUdpThread(void *pArg_p)
 #endif
 {
 
-tEplSdoUdpInstance* pInstance;
-struct sockaddr_in  RemoteAddr;
-int                 iError;
-int                 iCount;
-int                 iFreeEntry;
-BYTE                abBuffer[EPL_MAX_SDO_REC_FRAME_SIZE];
-unsigned int        uiSize;
-tEplSdoConHdl       SdoConHdl;
+	tEplSdoUdpInstance *pInstance;
+	struct sockaddr_in RemoteAddr;
+	int iError;
+	int iCount;
+	int iFreeEntry;
+	BYTE abBuffer[EPL_MAX_SDO_REC_FRAME_SIZE];
+	unsigned int uiSize;
+	tEplSdoConHdl SdoConHdl;
 
 #if (TARGET_SYSTEM == _WIN32_)
-    pInstance = (tEplSdoUdpInstance*)lpParameter;
-
-    for (;;)
+	pInstance = (tEplSdoUdpInstance *) lpParameter;
 
+	for (;;)
 #elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-    pInstance = (tEplSdoUdpInstance*)pArg_p;
-    daemonize("EplSdoUdpThread");
-    allow_signal( SIGTERM );
+	pInstance = (tEplSdoUdpInstance *) pArg_p;
+	daemonize("EplSdoUdpThread");
+	allow_signal(SIGTERM);
 
-    for (;pInstance->m_iTerminateThread == 0;)
+	for (; pInstance->m_iTerminateThread == 0;)
 #endif
 
-    {
-        // wait for data
-        uiSize = sizeof(struct sockaddr);
-        iError = recvfrom(pInstance->m_UdpSocket,   // Socket
-                        (char *)&abBuffer[0],               // buffer for data
-                        sizeof(abBuffer),           // size of the buffer
-                        0,                          // flags
-                        (struct sockaddr*)&RemoteAddr,
-                        (int*)&uiSize);
+	{
+		// wait for data
+		uiSize = sizeof(struct sockaddr);
+		iError = recvfrom(pInstance->m_UdpSocket,	// Socket
+				  (char *)&abBuffer[0],	// buffer for data
+				  sizeof(abBuffer),	// size of the buffer
+				  0,	// flags
+				  (struct sockaddr *)&RemoteAddr,
+				  (int *)&uiSize);
 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-        if (iError == -ERESTARTSYS)
-        {
-            break;
-        }
+		if (iError == -ERESTARTSYS) {
+			break;
+		}
 #endif
-        if (iError > 0)
-        {
-            // get handle for higher layer
-            iCount = 0;
-            iFreeEntry = 0xFFFF;
+		if (iError > 0) {
+			// get handle for higher layer
+			iCount = 0;
+			iFreeEntry = 0xFFFF;
 #if (TARGET_SYSTEM == _WIN32_)
-        // enter  critical section for process function
-    EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+			// enter  critical section for process function
+			EnterCriticalSection(SdoUdpInstance_g.
+					     m_pCriticalSection);
 #endif
-            while (iCount < EPL_SDO_MAX_CONNECTION_UDP)
-            {
-                // check if this connection is already known
-                if((pInstance->m_aSdoAbsUdpConnection[iCount].m_ulIpAddr == RemoteAddr.sin_addr.s_addr)
-                    && (pInstance->m_aSdoAbsUdpConnection[iCount].m_uiPort == RemoteAddr.sin_port))
-                {
-                    break;
-                }
-
-                if((pInstance->m_aSdoAbsUdpConnection[iCount].m_ulIpAddr == 0)
-                    && (pInstance->m_aSdoAbsUdpConnection[iCount].m_uiPort == 0)
-                    && (iFreeEntry == 0xFFFF))
-
-                {
-                    iFreeEntry  = iCount;
-                }
-
-                iCount++;
-            }
-
-            if (iCount == EPL_SDO_MAX_CONNECTION_UDP)
-            {
-                // connection unknown
-                // see if there is a free handle
-                if (iFreeEntry != 0xFFFF)
-                {
-                    // save adress infos
-                    pInstance->m_aSdoAbsUdpConnection[iFreeEntry].m_ulIpAddr =
-                        RemoteAddr.sin_addr.s_addr;
-                    pInstance->m_aSdoAbsUdpConnection[iFreeEntry].m_uiPort =
-                        RemoteAddr.sin_port;
+			while (iCount < EPL_SDO_MAX_CONNECTION_UDP) {
+				// check if this connection is already known
+				if ((pInstance->m_aSdoAbsUdpConnection[iCount].
+				     m_ulIpAddr == RemoteAddr.sin_addr.s_addr)
+				    && (pInstance->
+					m_aSdoAbsUdpConnection[iCount].
+					m_uiPort == RemoteAddr.sin_port)) {
+					break;
+				}
+
+				if ((pInstance->m_aSdoAbsUdpConnection[iCount].
+				     m_ulIpAddr == 0)
+				    && (pInstance->
+					m_aSdoAbsUdpConnection[iCount].
+					m_uiPort == 0)
+				    && (iFreeEntry == 0xFFFF))
+				{
+					iFreeEntry = iCount;
+				}
+
+				iCount++;
+			}
+
+			if (iCount == EPL_SDO_MAX_CONNECTION_UDP) {
+				// connection unknown
+				// see if there is a free handle
+				if (iFreeEntry != 0xFFFF) {
+					// save adress infos
+					pInstance->
+					    m_aSdoAbsUdpConnection[iFreeEntry].
+					    m_ulIpAddr =
+					    RemoteAddr.sin_addr.s_addr;
+					pInstance->
+					    m_aSdoAbsUdpConnection[iFreeEntry].
+					    m_uiPort = RemoteAddr.sin_port;
 #if (TARGET_SYSTEM == _WIN32_)
-    // leave critical section for process function
-    LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+					// leave critical section for process function
+					LeaveCriticalSection(SdoUdpInstance_g.
+							     m_pCriticalSection);
 #endif
-                    // call callback
-                    SdoConHdl = iFreeEntry;
-                    SdoConHdl |= EPL_SDO_UDP_HANDLE;
-                    // offset 4 -> start of SDO Sequence header
-                    pInstance->m_fpSdoAsySeqCb(SdoConHdl, (tEplAsySdoSeq*)&abBuffer[4], (iError - 4));
-                }
-                else
-                {
-                    EPL_DBGLVL_SDO_TRACE0("Error in EplSdoUdpThread() no free handle\n");
+					// call callback
+					SdoConHdl = iFreeEntry;
+					SdoConHdl |= EPL_SDO_UDP_HANDLE;
+					// offset 4 -> start of SDO Sequence header
+					pInstance->m_fpSdoAsySeqCb(SdoConHdl,
+								   (tEplAsySdoSeq
+								    *) &
+								   abBuffer[4],
+								   (iError -
+								    4));
+				} else {
+					EPL_DBGLVL_SDO_TRACE0
+					    ("Error in EplSdoUdpThread() no free handle\n");
 #if (TARGET_SYSTEM == _WIN32_)
-    // leave critical section for process function
-    LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+					// leave critical section for process function
+					LeaveCriticalSection(SdoUdpInstance_g.
+							     m_pCriticalSection);
 #endif
-                }
-
-            }
-            else
-            {
-                // known connection
-                // call callback with correct handle
-                SdoConHdl = iCount;
-                SdoConHdl |= EPL_SDO_UDP_HANDLE;
+				}
+
+			} else {
+				// known connection
+				// call callback with correct handle
+				SdoConHdl = iCount;
+				SdoConHdl |= EPL_SDO_UDP_HANDLE;
 #if (TARGET_SYSTEM == _WIN32_)
-    // leave critical section for process function
-    LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
+				// leave critical section for process function
+				LeaveCriticalSection(SdoUdpInstance_g.
+						     m_pCriticalSection);
 #endif
-                // offset 4 -> start of SDO Sequence header
-                pInstance->m_fpSdoAsySeqCb(SdoConHdl, (tEplAsySdoSeq*)&abBuffer[4], (iError - 4));
-            }
-        } // end of  if(iError!=SOCKET_ERROR)
-    }// end of for(;;)
+				// offset 4 -> start of SDO Sequence header
+				pInstance->m_fpSdoAsySeqCb(SdoConHdl,
+							   (tEplAsySdoSeq *) &
+							   abBuffer[4],
+							   (iError - 4));
+			}
+		}		// end of  if(iError!=SOCKET_ERROR)
+	}			// end of for(;;)
 
 #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
-    complete_and_exit(&SdoUdpInstance_g.m_CompletionUdpThread, 0);
+	complete_and_exit(&SdoUdpInstance_g.m_CompletionUdpThread, 0);
 #endif
 
-    return 0;
+	return 0;
 }
 
 #endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
 
 // EOF
-

+ 84 - 91
drivers/staging/epl/EplStatusu.c

@@ -95,7 +95,6 @@
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -109,7 +108,6 @@
 //
 /***************************************************************************/
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   D E F I N I T I O N S                          //
@@ -124,9 +122,8 @@
 // local types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    tEplStatusuCbResponse m_apfnCbResponse[254];
+typedef struct {
+	tEplStatusuCbResponse m_apfnCbResponse[254];
 
 } tEplStatusuInstance;
 
@@ -134,13 +131,14 @@ typedef struct
 // local vars
 //---------------------------------------------------------------------------
 
-static tEplStatusuInstance   EplStatusuInstance_g;
+static tEplStatusuInstance EplStatusuInstance_g;
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p);
+static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo *
+						    pFrameInfo_p);
 
 //=========================================================================//
 //                                                                         //
@@ -168,14 +166,13 @@ static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p
 
 EPLDLLEXPORT tEplKernel PUBLIC EplStatusuInit()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = EplStatusuAddInstance();
+	Ret = EplStatusuAddInstance();
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplStatusuAddInstance
@@ -196,21 +193,23 @@ tEplKernel Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplStatusuAddInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof(EplStatusuInstance_g));
 
-    // register StatusResponse callback function
-    Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, EplStatusuCbStatusResponse, kEplDllAsndFilterAny);
+	// register StatusResponse callback function
+	Ret =
+	    EplDlluCalRegAsndService(kEplDllAsndStatusResponse,
+				     EplStatusuCbStatusResponse,
+				     kEplDllAsndFilterAny);
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplStatusuDelInstance
@@ -231,18 +230,19 @@ tEplKernel Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplStatusuDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // deregister StatusResponse callback function
-    Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, NULL, kEplDllAsndFilterNone);
+	// deregister StatusResponse callback function
+	Ret =
+	    EplDlluCalRegAsndService(kEplDllAsndStatusResponse, NULL,
+				     kEplDllAsndFilterNone);
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplStatusuReset
@@ -260,18 +260,17 @@ tEplKernel  Ret;
 
 EPLDLLEXPORT tEplKernel PUBLIC EplStatusuReset()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // reset instance structure
-    EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
+	// reset instance structure
+	EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof(EplStatusuInstance_g));
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplStatusuRequestStatusResponse
@@ -288,42 +287,38 @@ tEplKernel  Ret;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplStatusuRequestStatusResponse(
-                                  unsigned int        uiNodeId_p,
-                                  tEplStatusuCbResponse pfnCbResponse_p)
+tEplKernel PUBLIC EplStatusuRequestStatusResponse(unsigned int uiNodeId_p,
+						  tEplStatusuCbResponse
+						  pfnCbResponse_p)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // decrement node ID, because array is zero based
-    uiNodeId_p--;
-    if (uiNodeId_p < tabentries (EplStatusuInstance_g.m_apfnCbResponse))
-    {
+	// decrement node ID, because array is zero based
+	uiNodeId_p--;
+	if (uiNodeId_p < tabentries(EplStatusuInstance_g.m_apfnCbResponse)) {
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-        if (EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL)
-        {   // request already issued (maybe by someone else)
-            Ret = kEplInvalidOperation;
-        }
-        else
-        {
-            EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] = pfnCbResponse_p;
-            Ret = EplDlluCalIssueRequest(kEplDllReqServiceStatus, (uiNodeId_p + 1), 0xFF);
-        }
+		if (EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL) {	// request already issued (maybe by someone else)
+			Ret = kEplInvalidOperation;
+		} else {
+			EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] =
+			    pfnCbResponse_p;
+			Ret =
+			    EplDlluCalIssueRequest(kEplDllReqServiceStatus,
+						   (uiNodeId_p + 1), 0xFF);
+		}
 #else
-        Ret = kEplInvalidOperation;
+		Ret = kEplInvalidOperation;
 #endif
-    }
-    else
-    {   // invalid node ID specified
-        Ret = kEplInvalidNodeId;
-    }
+	} else {		// invalid node ID specified
+		Ret = kEplInvalidNodeId;
+	}
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -347,41 +342,39 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p)
+static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo *
+						    pFrameInfo_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-unsigned int    uiNodeId;
-unsigned int    uiIndex;
-tEplStatusuCbResponse    pfnCbResponse;
-
-    uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
-
-    uiIndex = uiNodeId - 1;
-
-    if (uiIndex < tabentries (EplStatusuInstance_g.m_apfnCbResponse))
-    {
-        // memorize pointer to callback function
-        pfnCbResponse = EplStatusuInstance_g.m_apfnCbResponse[uiIndex];
-        if (pfnCbResponse == NULL)
-        {   // response was not requested
-            goto Exit;
-        }
-        // reset callback function pointer so that caller may issue next request
-        EplStatusuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
-
-        if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_STATUSRES)
-        {   // StatusResponse not received or it has invalid size
-            Ret = pfnCbResponse(uiNodeId, NULL);
-        }
-        else
-        {   // StatusResponse received
-            Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_StatusResponse);
-        }
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	unsigned int uiNodeId;
+	unsigned int uiIndex;
+	tEplStatusuCbResponse pfnCbResponse;
+
+	uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
+
+	uiIndex = uiNodeId - 1;
+
+	if (uiIndex < tabentries(EplStatusuInstance_g.m_apfnCbResponse)) {
+		// memorize pointer to callback function
+		pfnCbResponse = EplStatusuInstance_g.m_apfnCbResponse[uiIndex];
+		if (pfnCbResponse == NULL) {	// response was not requested
+			goto Exit;
+		}
+		// reset callback function pointer so that caller may issue next request
+		EplStatusuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
+
+		if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_STATUSRES) {	// StatusResponse not received or it has invalid size
+			Ret = pfnCbResponse(uiNodeId, NULL);
+		} else {	// StatusResponse received
+			Ret =
+			    pfnCbResponse(uiNodeId,
+					  &pFrameInfo_p->m_pFrame->m_Data.
+					  m_Asnd.m_Payload.m_StatusResponse);
+		}
+	}
+
+      Exit:
+	return Ret;
 }
 
 // EOF
-

+ 138 - 164
drivers/staging/epl/EplTimeruLinuxKernel.c

@@ -86,10 +86,9 @@
 //---------------------------------------------------------------------------
 // local types
 //---------------------------------------------------------------------------
-typedef struct
-{
-    struct timer_list   m_Timer;
-    tEplTimerArg        TimerArgument;
+typedef struct {
+	struct timer_list m_Timer;
+	tEplTimerArg TimerArgument;
 
 } tEplTimeruData;
 
@@ -137,14 +136,13 @@ static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p);
 
 tEplKernel PUBLIC EplTimeruInit()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplTimeruAddInstance();
+	Ret = EplTimeruAddInstance();
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruAddInstance
@@ -161,14 +159,13 @@ tEplKernel  Ret;
 
 tEplKernel PUBLIC EplTimeruAddInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruDelInstance
@@ -187,14 +184,13 @@ tEplKernel Ret;
 
 tEplKernel PUBLIC EplTimeruDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    return Ret;
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruSetTimerMs
@@ -211,43 +207,40 @@ tEplKernel  Ret;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long   ulTime_p,
-                                        tEplTimerArg    Argument_p)
+tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
+				      unsigned long ulTime_p,
+				      tEplTimerArg Argument_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplTimeruData*     pData;
+	tEplKernel Ret = kEplSuccessful;
+	tEplTimeruData *pData;
 
-    // check pointer to handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
+	// check pointer to handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
 
-    pData = (tEplTimeruData*) EPL_MALLOC(sizeof (tEplTimeruData));
-    if (pData == NULL)
-    {
-        Ret = kEplNoResource;
-        goto Exit;
-    }
+	pData = (tEplTimeruData *) EPL_MALLOC(sizeof(tEplTimeruData));
+	if (pData == NULL) {
+		Ret = kEplNoResource;
+		goto Exit;
+	}
 
-    init_timer(&pData->m_Timer);
-    pData->m_Timer.function = EplTimeruCbMs;
-    pData->m_Timer.data = (unsigned long) pData;
-    pData->m_Timer.expires = jiffies + ulTime_p * HZ / 1000;
+	init_timer(&pData->m_Timer);
+	pData->m_Timer.function = EplTimeruCbMs;
+	pData->m_Timer.data = (unsigned long)pData;
+	pData->m_Timer.expires = jiffies + ulTime_p * HZ / 1000;
 
-    EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
+	EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
 
-    add_timer(&pData->m_Timer);
+	add_timer(&pData->m_Timer);
 
-    *pTimerHdl_p = (tEplTimerHdl) pData;
+	*pTimerHdl_p = (tEplTimerHdl) pData;
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruModifyTimerMs
@@ -264,57 +257,50 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long     ulTime_p,
-                                        tEplTimerArg      Argument_p)
+tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
+					 unsigned long ulTime_p,
+					 tEplTimerArg Argument_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplTimeruData*     pData;
-
-    // check pointer to handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    // check handle itself, i.e. was the handle initialized before
-    if (*pTimerHdl_p == 0)
-    {
-        Ret = EplTimeruSetTimerMs(pTimerHdl_p, ulTime_p, Argument_p);
-        goto Exit;
-    }
-    pData = (tEplTimeruData*) *pTimerHdl_p;
-    if ((tEplTimeruData*)pData->m_Timer.data != pData)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    mod_timer(&pData->m_Timer, (jiffies + ulTime_p * HZ / 1000));
-
-    // copy the TimerArg after the timer is restarted,
-    // so that a timer occured immediately before mod_timer
-    // won't use the new TimerArg and
-    // therefore the old timer cannot be distinguished from the new one.
-    // But if the new timer is too fast, it may get lost.
-    EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
-
-    // check if timer is really running
-    if (timer_pending(&pData->m_Timer) == 0)
-    {   // timer is not running
-        // retry starting it
-        add_timer(&pData->m_Timer);
-    }
-
-    // set handle to pointer of tEplTimeruData
+	tEplKernel Ret = kEplSuccessful;
+	tEplTimeruData *pData;
+
+	// check pointer to handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+	// check handle itself, i.e. was the handle initialized before
+	if (*pTimerHdl_p == 0) {
+		Ret = EplTimeruSetTimerMs(pTimerHdl_p, ulTime_p, Argument_p);
+		goto Exit;
+	}
+	pData = (tEplTimeruData *) * pTimerHdl_p;
+	if ((tEplTimeruData *) pData->m_Timer.data != pData) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+
+	mod_timer(&pData->m_Timer, (jiffies + ulTime_p * HZ / 1000));
+
+	// copy the TimerArg after the timer is restarted,
+	// so that a timer occured immediately before mod_timer
+	// won't use the new TimerArg and
+	// therefore the old timer cannot be distinguished from the new one.
+	// But if the new timer is too fast, it may get lost.
+	EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
+
+	// check if timer is really running
+	if (timer_pending(&pData->m_Timer) == 0) {	// timer is not running
+		// retry starting it
+		add_timer(&pData->m_Timer);
+	}
+	// set handle to pointer of tEplTimeruData
 //    *pTimerHdl_p = (tEplTimerHdl) pData;
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruDeleteTimer
@@ -329,50 +315,45 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl*     pTimerHdl_p)
+tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplTimeruData*     pData;
-
-    // check pointer to handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    // check handle itself, i.e. was the handle initialized before
-    if (*pTimerHdl_p == 0)
-    {
-        Ret = kEplSuccessful;
-        goto Exit;
-    }
-    pData = (tEplTimeruData*) *pTimerHdl_p;
-    if ((tEplTimeruData*)pData->m_Timer.data != pData)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
+	tEplKernel Ret = kEplSuccessful;
+	tEplTimeruData *pData;
+
+	// check pointer to handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+	// check handle itself, i.e. was the handle initialized before
+	if (*pTimerHdl_p == 0) {
+		Ret = kEplSuccessful;
+		goto Exit;
+	}
+	pData = (tEplTimeruData *) * pTimerHdl_p;
+	if ((tEplTimeruData *) pData->m_Timer.data != pData) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
 
 /*    if (del_timer(&pData->m_Timer) == 1)
     {
         kfree(pData);
     }
 */
-    // try to delete the timer
-    del_timer(&pData->m_Timer);
-    // free memory in any case
-    kfree(pData);
+	// try to delete the timer
+	del_timer(&pData->m_Timer);
+	// free memory in any case
+	kfree(pData);
 
-    // uninitialize handle
-    *pTimerHdl_p = 0;
+	// uninitialize handle
+	*pTimerHdl_p = 0;
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruIsTimerActive
@@ -391,33 +372,28 @@ Exit:
 
 BOOL PUBLIC EplTimeruIsTimerActive(tEplTimerHdl TimerHdl_p)
 {
-BOOL        fActive = FALSE;
-tEplTimeruData*     pData;
-
-    // check handle itself, i.e. was the handle initialized before
-    if (TimerHdl_p == 0)
-    {   // timer was not created yet, so it is not active
-        goto Exit;
-    }
-    pData = (tEplTimeruData*) TimerHdl_p;
-    if ((tEplTimeruData*)pData->m_Timer.data != pData)
-    {   // invalid timer
-        goto Exit;
-    }
-
-    // check if timer is running
-    if (timer_pending(&pData->m_Timer) == 0)
-    {   // timer is not running
-        goto Exit;
-    }
-
-    fActive = TRUE;
-
-Exit:
-    return fActive;
+	BOOL fActive = FALSE;
+	tEplTimeruData *pData;
+
+	// check handle itself, i.e. was the handle initialized before
+	if (TimerHdl_p == 0) {	// timer was not created yet, so it is not active
+		goto Exit;
+	}
+	pData = (tEplTimeruData *) TimerHdl_p;
+	if ((tEplTimeruData *) pData->m_Timer.data != pData) {	// invalid timer
+		goto Exit;
+	}
+	// check if timer is running
+	if (timer_pending(&pData->m_Timer) == 0) {	// timer is not running
+		goto Exit;
+	}
+
+	fActive = TRUE;
+
+      Exit:
+	return fActive;
 }
 
-
 //=========================================================================//
 //                                                                         //
 //          P R I V A T E   F U N C T I O N S                              //
@@ -443,30 +419,28 @@ Exit:
 //---------------------------------------------------------------------------
 static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p)
 {
-tEplKernel          Ret = kEplSuccessful;
-tEplTimeruData*     pData;
-tEplEvent           EplEvent;
-tEplTimerEventArg   TimerEventArg;
+	tEplKernel Ret = kEplSuccessful;
+	tEplTimeruData *pData;
+	tEplEvent EplEvent;
+	tEplTimerEventArg TimerEventArg;
 
-    pData = (tEplTimeruData*) ulParameter_p;
+	pData = (tEplTimeruData *) ulParameter_p;
 
-    // call event function
-    TimerEventArg.m_TimerHdl = (tEplTimerHdl)pData;
-    TimerEventArg.m_ulArg = pData->TimerArgument.m_ulArg;
+	// call event function
+	TimerEventArg.m_TimerHdl = (tEplTimerHdl) pData;
+	TimerEventArg.m_ulArg = pData->TimerArgument.m_ulArg;
 
-    EplEvent.m_EventSink = pData->TimerArgument.m_EventSink;
-    EplEvent.m_EventType = kEplEventTypeTimer;
-    EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
-    EplEvent.m_pArg = &TimerEventArg;
-    EplEvent.m_uiSize = sizeof(TimerEventArg);
+	EplEvent.m_EventSink = pData->TimerArgument.m_EventSink;
+	EplEvent.m_EventType = kEplEventTypeTimer;
+	EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
+	EplEvent.m_pArg = &TimerEventArg;
+	EplEvent.m_uiSize = sizeof(TimerEventArg);
 
-    Ret = EplEventuPost(&EplEvent);
+	Ret = EplEventuPost(&EplEvent);
 
-    // d.k. do not free memory, user has to call EplTimeruDeleteTimer()
-    //kfree(pData);
+	// d.k. do not free memory, user has to call EplTimeruDeleteTimer()
+	//kfree(pData);
 
 }
 
-
 // EOF
-

+ 45 - 56
drivers/staging/epl/EplTimeruNull.c

@@ -132,11 +132,11 @@
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruInit()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplTimeruAddInstance();
+	Ret = EplTimeruAddInstance();
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -158,11 +158,11 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruAddInstance()
 {
-tEplKernel Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -186,11 +186,11 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -212,27 +212,24 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long   ulTime_p,
-                                        tEplTimerArg    Argument_p)
+tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
+				      unsigned long ulTime_p,
+				      tEplTimerArg Argument_p)
 {
-tEplKernel          Ret;
+	tEplKernel Ret;
 
+	Ret = kEplSuccessful;
 
-    Ret = kEplSuccessful;
+	// check handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
 
-    // check handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
-
  //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruModifyTimerMs
@@ -252,24 +249,22 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long     ulTime_p,
-                                        tEplTimerArg      Argument_p)
+tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
+					 unsigned long ulTime_p,
+					 tEplTimerArg Argument_p)
 {
-tEplKernel          Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    // check parameter
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
+	// check parameter
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
 
-
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
  //---------------------------------------------------------------------------
@@ -289,25 +284,22 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl*     pTimerHdl_p)
+tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
 {
-tEplKernel  Ret;
-
-    Ret = kEplSuccessful;
+	tEplKernel Ret;
 
-    // check parameter
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
+	Ret = kEplSuccessful;
 
-    // set handle invalide
-    *pTimerHdl_p = 0;
+	// check parameter
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+	// set handle invalide
+	*pTimerHdl_p = 0;
 
-
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
@@ -317,7 +309,4 @@ Exit:
 //                                                                         //
 //=========================================================================//
 
-
-
 // EOF
-

+ 225 - 263
drivers/staging/epl/EplTimeruWin32.c

@@ -85,24 +85,22 @@
 //---------------------------------------------------------------------------
 // local types
 //---------------------------------------------------------------------------
-typedef struct
-{
-    tEplTimerArg    TimerArgument;
-    HANDLE          DelteHandle;
-    unsigned long   ulTimeout;
+typedef struct {
+	tEplTimerArg TimerArgument;
+	HANDLE DelteHandle;
+	unsigned long ulTimeout;
 
-}tEplTimeruThread;
+} tEplTimeruThread;
 
-typedef struct
-{
-    LPCRITICAL_SECTION  m_pCriticalSection;
-    CRITICAL_SECTION    m_CriticalSection;
-}tEplTimeruInstance;
+typedef struct {
+	LPCRITICAL_SECTION m_pCriticalSection;
+	CRITICAL_SECTION m_CriticalSection;
+} tEplTimeruInstance;
 //---------------------------------------------------------------------------
 // modul globale vars
 //---------------------------------------------------------------------------
 static tEplTimeruInstance EplTimeruInstance_g;
-static tEplTimeruThread   ThreadData_l;
+static tEplTimeruThread ThreadData_l;
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
@@ -146,11 +144,11 @@ DWORD PUBLIC EplSdoTimeruThreadms(LPVOID lpParameter);
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruInit()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplTimeruAddInstance();
+	Ret = EplTimeruAddInstance();
 
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -172,18 +170,16 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruAddInstance()
 {
-tEplKernel Ret;
-
-    Ret = kEplSuccessful;
+	tEplKernel Ret;
 
+	Ret = kEplSuccessful;
 
-    // create critical section
-    EplTimeruInstance_g.m_pCriticalSection = &EplTimeruInstance_g.m_CriticalSection;
-    InitializeCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+	// create critical section
+	EplTimeruInstance_g.m_pCriticalSection =
+	    &EplTimeruInstance_g.m_CriticalSection;
+	InitializeCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
 
-
-
-return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -207,11 +203,11 @@ return Ret;
 //---------------------------------------------------------------------------
 tEplKernel PUBLIC EplTimeruDelInstance()
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    return Ret;
+	return Ret;
 }
 
 //---------------------------------------------------------------------------
@@ -233,71 +229,60 @@ tEplKernel  Ret;
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long   ulTime_p,
-                                        tEplTimerArg    Argument_p)
+tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
+				      unsigned long ulTime_p,
+				      tEplTimerArg Argument_p)
 {
-tEplKernel          Ret;
-HANDLE              DeleteHandle;
-HANDLE              ThreadHandle;
-DWORD               ThreadId;
-
-
-    Ret = kEplSuccessful;
-
-    // check handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    // enter  critical section
-    EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
-
-    // first create event to delete timer
-    DeleteHandle = CreateEvent(NULL,FALSE,FALSE, NULL);
-    if(DeleteHandle == NULL)
-    {
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-    // set handle for caller
-    *pTimerHdl_p = (tEplTimerHdl)DeleteHandle;
-
-
-
-
-    // fill data for thread
-    ThreadData_l.DelteHandle = DeleteHandle;
-    EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p, sizeof(tEplTimerArg));
-    ThreadData_l.ulTimeout = ulTime_p;
-
-    // create thread to create waitable timer and wait for timer
-    ThreadHandle = CreateThread(NULL,
-                                0,
-                                EplSdoTimeruThreadms,
-                                &ThreadData_l,
-                                0,
-                                &ThreadId);
-    if(ThreadHandle == NULL)
-    {
-        // leave critical section
-        LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
-
-        // delte handle
-        CloseHandle(DeleteHandle);
-
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	HANDLE DeleteHandle;
+	HANDLE ThreadHandle;
+	DWORD ThreadId;
+
+	Ret = kEplSuccessful;
+
+	// check handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+	// enter  critical section
+	EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+
+	// first create event to delete timer
+	DeleteHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
+	if (DeleteHandle == NULL) {
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+	// set handle for caller
+	*pTimerHdl_p = (tEplTimerHdl) DeleteHandle;
+
+	// fill data for thread
+	ThreadData_l.DelteHandle = DeleteHandle;
+	EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p,
+		   sizeof(tEplTimerArg));
+	ThreadData_l.ulTimeout = ulTime_p;
+
+	// create thread to create waitable timer and wait for timer
+	ThreadHandle = CreateThread(NULL,
+				    0,
+				    EplSdoTimeruThreadms,
+				    &ThreadData_l, 0, &ThreadId);
+	if (ThreadHandle == NULL) {
+		// leave critical section
+		LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+
+		// delte handle
+		CloseHandle(DeleteHandle);
+
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 }
 
-
  //---------------------------------------------------------------------------
 //
 // Function:    EplTimeruModifyTimerMs
@@ -317,69 +302,64 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl*     pTimerHdl_p,
-                                        unsigned long     ulTime_p,
-                                        tEplTimerArg      Argument_p)
+tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
+					 unsigned long ulTime_p,
+					 tEplTimerArg Argument_p)
 {
-tEplKernel          Ret;
-HANDLE              DeleteHandle;
-HANDLE              ThreadHandle;
-DWORD               ThreadId;
-
-    Ret = kEplSuccessful;
-
-    // check parameter
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    DeleteHandle = (HANDLE)(*pTimerHdl_p);
-
-    // set event to end timer task for this timer
-    SetEvent(DeleteHandle);
-
-    // create new timer
-    // first create event to delete timer
-    DeleteHandle = CreateEvent(NULL,FALSE,FALSE, NULL);
-    if(DeleteHandle == NULL)
-    {
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-    // set handle for caller
-    *pTimerHdl_p = (tEplTimerHdl)DeleteHandle;
-
-    // enter  critical section
-    EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
-
-    // fill data for thread
-    ThreadData_l.DelteHandle = DeleteHandle;
-    EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p, sizeof(tEplTimerArg));
-    ThreadData_l.ulTimeout = ulTime_p;
-
-    // create thread to create waitable timer and wait for timer
-    ThreadHandle = CreateThread(NULL,
-                                0,
-                                EplSdoTimeruThreadms,
-                                &ThreadData_l,
-                                0,
-                                &ThreadId);
-    if(ThreadHandle == NULL)
-    {
-        // leave critical section
-        LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
-
-        // delte handle
-
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	HANDLE DeleteHandle;
+	HANDLE ThreadHandle;
+	DWORD ThreadId;
+
+	Ret = kEplSuccessful;
+
+	// check parameter
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+
+	DeleteHandle = (HANDLE) (*pTimerHdl_p);
+
+	// set event to end timer task for this timer
+	SetEvent(DeleteHandle);
+
+	// create new timer
+	// first create event to delete timer
+	DeleteHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
+	if (DeleteHandle == NULL) {
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+	// set handle for caller
+	*pTimerHdl_p = (tEplTimerHdl) DeleteHandle;
+
+	// enter  critical section
+	EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+
+	// fill data for thread
+	ThreadData_l.DelteHandle = DeleteHandle;
+	EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p,
+		   sizeof(tEplTimerArg));
+	ThreadData_l.ulTimeout = ulTime_p;
+
+	// create thread to create waitable timer and wait for timer
+	ThreadHandle = CreateThread(NULL,
+				    0,
+				    EplSdoTimeruThreadms,
+				    &ThreadData_l, 0, &ThreadId);
+	if (ThreadHandle == NULL) {
+		// leave critical section
+		LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+
+		// delte handle
+
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 }
 
  //---------------------------------------------------------------------------
@@ -399,31 +379,29 @@ Exit:
 // State:
 //
 //---------------------------------------------------------------------------
-tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl*     pTimerHdl_p)
+tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
 {
-tEplKernel  Ret;
-HANDLE      DeleteHandle;
-
-    Ret = kEplSuccessful;
+	tEplKernel Ret;
+	HANDLE DeleteHandle;
 
-    // check parameter
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
+	Ret = kEplSuccessful;
 
-    DeleteHandle = (HANDLE)(*pTimerHdl_p);
+	// check parameter
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
 
-    // set event to end timer task for this timer
-    SetEvent(DeleteHandle);
+	DeleteHandle = (HANDLE) (*pTimerHdl_p);
 
-    // set handle invalide
-    *pTimerHdl_p = 0;
+	// set event to end timer task for this timer
+	SetEvent(DeleteHandle);
 
+	// set handle invalide
+	*pTimerHdl_p = 0;
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 
 }
 
@@ -452,100 +430,84 @@ Exit:
 //---------------------------------------------------------------------------
 DWORD PUBLIC EplSdoTimeruThreadms(LPVOID lpParameter)
 {
-tEplKernel          Ret;
-tEplTimeruThread*   pThreadData;
-HANDLE              aHandles[2];
-BOOL                fReturn;
-LARGE_INTEGER       TimeoutTime;
-unsigned long       ulEvent;
-tEplEvent           EplEvent;
-tEplTimeruThread    ThreadData;
-tEplTimerEventArg   TimerEventArg;
-
-    Ret = kEplSuccessful;
-
-    // get pointer to data
-    pThreadData = (tEplTimeruThread*)lpParameter;
-    // copy thread data
-    EPL_MEMCPY(&ThreadData, pThreadData, sizeof(ThreadData));
-    pThreadData = &ThreadData;
-
-    // leave critical section
-    LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
-
-    // create waitable timer
-    aHandles[1] = CreateWaitableTimer(NULL,FALSE,NULL);
-    if(aHandles[1] == NULL)
-    {
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-    // set timer
-    // set timeout interval -> needed to be negativ
-    // -> because relative timeout
-    // -> multiply by 10000 for 100 ns timebase of function
-    TimeoutTime.QuadPart = (((long long)pThreadData->ulTimeout) * -10000);
-    fReturn = SetWaitableTimer(aHandles[1],
-                               &TimeoutTime,
-                               0,
-                               NULL,
-                               NULL,
-                               FALSE);
-    if(fReturn == 0)
-    {
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-    // save delte event handle in handle array
-    aHandles[0] = pThreadData->DelteHandle;
-
-    // wait for one of the events
-    ulEvent = WaitForMultipleObjects( 2,
-                            &aHandles[0],
-                            FALSE,
-                            INFINITE);
-    if(ulEvent == WAIT_OBJECT_0)
-    {   // delte event
-
-        // close handels
-        CloseHandle(aHandles[1]);
-        // terminate thread
-        goto Exit;
-    }
-    else if(ulEvent == (WAIT_OBJECT_0 + 1))
-    {   // timer event
-        // call event function
-        TimerEventArg.m_TimerHdl = (tEplTimerHdl)pThreadData->DelteHandle;
-        TimerEventArg.m_ulArg = pThreadData->TimerArgument.m_ulArg;
-
-        EplEvent.m_EventSink = pThreadData->TimerArgument.m_EventSink;
-        EplEvent.m_EventType = kEplEventTypeTimer;
-        EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
-        EplEvent.m_pArg = &TimerEventArg;
-        EplEvent.m_uiSize = sizeof(TimerEventArg);
-
-        Ret = EplEventuPost(&EplEvent);
-
-        // close handels
-        CloseHandle(aHandles[1]);
-        // terminate thread
-        goto Exit;
-
-    }
-    else
-    {   // error
-        ulEvent = GetLastError();
-        TRACE1("Error in WaitForMultipleObjects Errorcode: 0x%x\n",ulEvent);
-         // terminate thread
-        goto Exit;
-    }
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	tEplTimeruThread *pThreadData;
+	HANDLE aHandles[2];
+	BOOL fReturn;
+	LARGE_INTEGER TimeoutTime;
+	unsigned long ulEvent;
+	tEplEvent EplEvent;
+	tEplTimeruThread ThreadData;
+	tEplTimerEventArg TimerEventArg;
+
+	Ret = kEplSuccessful;
+
+	// get pointer to data
+	pThreadData = (tEplTimeruThread *) lpParameter;
+	// copy thread data
+	EPL_MEMCPY(&ThreadData, pThreadData, sizeof(ThreadData));
+	pThreadData = &ThreadData;
+
+	// leave critical section
+	LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
+
+	// create waitable timer
+	aHandles[1] = CreateWaitableTimer(NULL, FALSE, NULL);
+	if (aHandles[1] == NULL) {
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+	// set timer
+	// set timeout interval -> needed to be negativ
+	// -> because relative timeout
+	// -> multiply by 10000 for 100 ns timebase of function
+	TimeoutTime.QuadPart = (((long long)pThreadData->ulTimeout) * -10000);
+	fReturn = SetWaitableTimer(aHandles[1],
+				   &TimeoutTime, 0, NULL, NULL, FALSE);
+	if (fReturn == 0) {
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+	// save delte event handle in handle array
+	aHandles[0] = pThreadData->DelteHandle;
+
+	// wait for one of the events
+	ulEvent = WaitForMultipleObjects(2, &aHandles[0], FALSE, INFINITE);
+	if (ulEvent == WAIT_OBJECT_0) {	// delte event
+
+		// close handels
+		CloseHandle(aHandles[1]);
+		// terminate thread
+		goto Exit;
+	} else if (ulEvent == (WAIT_OBJECT_0 + 1)) {	// timer event
+		// call event function
+		TimerEventArg.m_TimerHdl =
+		    (tEplTimerHdl) pThreadData->DelteHandle;
+		TimerEventArg.m_ulArg = pThreadData->TimerArgument.m_ulArg;
+
+		EplEvent.m_EventSink = pThreadData->TimerArgument.m_EventSink;
+		EplEvent.m_EventType = kEplEventTypeTimer;
+		EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
+		EplEvent.m_pArg = &TimerEventArg;
+		EplEvent.m_uiSize = sizeof(TimerEventArg);
+
+		Ret = EplEventuPost(&EplEvent);
+
+		// close handels
+		CloseHandle(aHandles[1]);
+		// terminate thread
+		goto Exit;
+
+	} else {		// error
+		ulEvent = GetLastError();
+		TRACE1("Error in WaitForMultipleObjects Errorcode: 0x%x\n",
+		       ulEvent);
+		// terminate thread
+		goto Exit;
+	}
+
+      Exit:
+	return Ret;
 }
 
-
 // EOF
-

File diff suppressed because it is too large
+ 869 - 1021
drivers/staging/epl/SharedBuff.c


File diff suppressed because it is too large
+ 408 - 455
drivers/staging/epl/ShbIpc-LinuxKernel.c


File diff suppressed because it is too large
+ 646 - 748
drivers/staging/epl/ShbIpc-Win32.c


+ 43 - 56
drivers/staging/epl/SocketLinuxKernel.c

@@ -68,12 +68,10 @@
 
 ****************************************************************************/
 
-
 #include <linux/net.h>
 #include <linux/in.h>
 #include "SocketLinuxKernel.h"
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -82,34 +80,26 @@
 /*                                                                         */
 /***************************************************************************/
 
-
 //---------------------------------------------------------------------------
 // const defines
 //---------------------------------------------------------------------------
 
-
 //---------------------------------------------------------------------------
 // local types
 //---------------------------------------------------------------------------
 
-
-
 //---------------------------------------------------------------------------
 // modul globale vars
 //---------------------------------------------------------------------------
 
-
-
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-
 //---------------------------------------------------------------------------
 //  Kernel Module specific Data Structures
 //---------------------------------------------------------------------------
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -136,75 +126,72 @@
 
 SOCKET socket(int af, int type, int protocol)
 {
-int rc;
-SOCKET socket;
-
-    rc = sock_create_kern(af, type, protocol, &socket);
-    if (rc < 0)
-    {
-        socket = NULL;
-        goto Exit;
-    }
-
-Exit:
-    return socket;
+	int rc;
+	SOCKET socket;
+
+	rc = sock_create_kern(af, type, protocol, &socket);
+	if (rc < 0) {
+		socket = NULL;
+		goto Exit;
+	}
+
+      Exit:
+	return socket;
 }
 
 int bind(SOCKET socket_p, const struct sockaddr *addr, int addrlen)
 {
-int rc;
+	int rc;
 
-    rc = socket_p->ops->bind(socket_p,
-                          (struct sockaddr *)addr,
-                          addrlen);
+	rc = socket_p->ops->bind(socket_p, (struct sockaddr *)addr, addrlen);
 
-    return rc;
+	return rc;
 }
 
 int closesocket(SOCKET socket_p)
 {
-    sock_release(socket_p);
+	sock_release(socket_p);
 
-    return 0;
+	return 0;
 }
 
-int recvfrom(SOCKET socket_p, char* buf, int len, int flags, struct sockaddr *from, int * fromlen)
+int recvfrom(SOCKET socket_p, char *buf, int len, int flags,
+	     struct sockaddr *from, int *fromlen)
 {
-int rc;
-struct msghdr msg;
-struct kvec iov;
+	int rc;
+	struct msghdr msg;
+	struct kvec iov;
 
-    msg.msg_control = NULL;
-    msg.msg_controllen = 0;
-    msg.msg_name = from;     // will be struct sock_addr
-    msg.msg_namelen = *fromlen;
-    iov.iov_len = len;
-    iov.iov_base = buf;
+	msg.msg_control = NULL;
+	msg.msg_controllen = 0;
+	msg.msg_name = from;	// will be struct sock_addr
+	msg.msg_namelen = *fromlen;
+	iov.iov_len = len;
+	iov.iov_base = buf;
 
-    rc = kernel_recvmsg(socket_p, &msg, &iov, 1, iov.iov_len, 0);
+	rc = kernel_recvmsg(socket_p, &msg, &iov, 1, iov.iov_len, 0);
 
-    return rc;
+	return rc;
 }
 
-int sendto(SOCKET socket_p, const char* buf, int len, int flags, const struct sockaddr *to, int tolen)
+int sendto(SOCKET socket_p, const char *buf, int len, int flags,
+	   const struct sockaddr *to, int tolen)
 {
-int rc;
-struct msghdr msg;
-struct kvec iov;
+	int rc;
+	struct msghdr msg;
+	struct kvec iov;
 
-    msg.msg_control = NULL;
-    msg.msg_controllen = 0;
-    msg.msg_name = (struct sockaddr *)to;     // will be struct sock_addr
-    msg.msg_namelen = tolen;
-    msg.msg_flags = 0;
-    iov.iov_len = len;
-    iov.iov_base = (char *)buf;
+	msg.msg_control = NULL;
+	msg.msg_controllen = 0;
+	msg.msg_name = (struct sockaddr *)to;	// will be struct sock_addr
+	msg.msg_namelen = tolen;
+	msg.msg_flags = 0;
+	iov.iov_len = len;
+	iov.iov_base = (char *)buf;
 
-    rc = kernel_sendmsg(socket_p, &msg, &iov, 1, len);
+	rc = kernel_sendmsg(socket_p, &msg, &iov, 1, len);
 
-    return rc;
+	return rc;
 }
 
-
 // EOF
-

+ 248 - 274
drivers/staging/epl/TimerHighReskX86.c

@@ -91,27 +91,25 @@
 // const defines
 //---------------------------------------------------------------------------
 
-#define TIMER_COUNT           2            /* max 15 timers selectable */
-#define TIMER_MIN_VAL_SINGLE  5000         /* min 5us */
-#define TIMER_MIN_VAL_CYCLE   100000       /* min 100us */
+#define TIMER_COUNT           2	/* max 15 timers selectable */
+#define TIMER_MIN_VAL_SINGLE  5000	/* min 5us */
+#define TIMER_MIN_VAL_CYCLE   100000	/* min 100us */
 
 #define PROVE_OVERRUN
 
-
 #ifndef CONFIG_HIGH_RES_TIMERS
-    #error "Kernel symbol CONFIG_HIGH_RES_TIMERS is required."
+#error "Kernel symbol CONFIG_HIGH_RES_TIMERS is required."
 #endif
 
-
 // TracePoint support for realtime-debugging
 #ifdef _DBG_TRACE_POINTS_
-    void  PUBLIC  TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
-    void  PUBLIC  TgtDbgPostTraceValue (DWORD dwTraceValue_p);
-    #define TGT_DBG_SIGNAL_TRACE_POINT(p)   TgtDbgSignalTracePoint(p)
-    #define TGT_DBG_POST_TRACE_VALUE(v)     TgtDbgPostTraceValue(v)
+void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
+void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
+#define TGT_DBG_SIGNAL_TRACE_POINT(p)   TgtDbgSignalTracePoint(p)
+#define TGT_DBG_POST_TRACE_VALUE(v)     TgtDbgPostTraceValue(v)
 #else
-    #define TGT_DBG_SIGNAL_TRACE_POINT(p)
-    #define TGT_DBG_POST_TRACE_VALUE(v)
+#define TGT_DBG_SIGNAL_TRACE_POINT(p)
+#define TGT_DBG_POST_TRACE_VALUE(v)
 #endif
 #define HRT_DBG_POST_TRACE_VALUE(Event_p, uiNodeId_p, wErrorCode_p) \
     TGT_DBG_POST_TRACE_VALUE((0xE << 28) | (Event_p << 24) \
@@ -128,19 +126,17 @@
 // modul global types
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-    tEplTimerEventArg    m_EventArg;
-    tEplTimerkCallback   m_pfnCallback;
-    struct hrtimer       m_Timer;
-    BOOL                 m_fContinuously;
-    unsigned long long   m_ullPeriod;
+typedef struct {
+	tEplTimerEventArg m_EventArg;
+	tEplTimerkCallback m_pfnCallback;
+	struct hrtimer m_Timer;
+	BOOL m_fContinuously;
+	unsigned long long m_ullPeriod;
 
 } tEplTimerHighReskTimerInfo;
 
-typedef struct
-{
-    tEplTimerHighReskTimerInfo  m_aTimerInfo[TIMER_COUNT];
+typedef struct {
+	tEplTimerHighReskTimerInfo m_aTimerInfo[TIMER_COUNT];
 
 } tEplTimerHighReskInstance;
 
@@ -148,13 +144,13 @@ typedef struct
 // local vars
 //---------------------------------------------------------------------------
 
-static tEplTimerHighReskInstance    EplTimerHighReskInstance_l;
+static tEplTimerHighReskInstance EplTimerHighReskInstance_l;
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
+enum hrtimer_restart EplTimerHighReskCallback(struct hrtimer *pTimer_p);
 
 //=========================================================================//
 //                                                                         //
@@ -162,7 +158,6 @@ enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
 //                                                                         //
 //=========================================================================//
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimerHighReskInit()
@@ -179,15 +174,14 @@ enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
 
 tEplKernel PUBLIC EplTimerHighReskInit(void)
 {
-tEplKernel  Ret;
+	tEplKernel Ret;
 
-    Ret = EplTimerHighReskAddInstance();
+	Ret = EplTimerHighReskAddInstance();
 
-    return Ret;
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimerHighReskAddInstance()
@@ -204,44 +198,44 @@ tEplKernel  Ret;
 
 tEplKernel PUBLIC EplTimerHighReskAddInstance(void)
 {
-tEplKernel                   Ret;
-unsigned int                 uiIndex;
+	tEplKernel Ret;
+	unsigned int uiIndex;
 
-    Ret = kEplSuccessful;
+	Ret = kEplSuccessful;
 
-    EPL_MEMSET(&EplTimerHighReskInstance_l, 0, sizeof (EplTimerHighReskInstance_l));
+	EPL_MEMSET(&EplTimerHighReskInstance_l, 0,
+		   sizeof(EplTimerHighReskInstance_l));
 
 #ifndef CONFIG_HIGH_RES_TIMERS
-    printk("EplTimerHighResk: Kernel symbol CONFIG_HIGH_RES_TIMERS is required.\n");
-    Ret = kEplNoResource;
-    return Ret;
+	printk
+	    ("EplTimerHighResk: Kernel symbol CONFIG_HIGH_RES_TIMERS is required.\n");
+	Ret = kEplNoResource;
+	return Ret;
 #endif
 
-    /*
-     * Initialize hrtimer structures for all usable timers.
-     */
-    for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++)
-    {
-    tEplTimerHighReskTimerInfo*  pTimerInfo;
-    struct hrtimer*              pTimer;
-
-        pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
-        pTimer = &pTimerInfo->m_Timer;
-        hrtimer_init(pTimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-
-        pTimer->function = EplTimerHighReskCallback;
-
-        /*
-         * We use HRTIMER_CB_SOFTIRQ here.
-         * HRTIMER_CB_IRQSAFE is critical as the callback function
-         * would be called with IRQs disabled.
-         */
-        pTimer->cb_mode = HRTIMER_CB_SOFTIRQ;
-    }
-
-    return Ret;
-}
+	/*
+	 * Initialize hrtimer structures for all usable timers.
+	 */
+	for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++) {
+		tEplTimerHighReskTimerInfo *pTimerInfo;
+		struct hrtimer *pTimer;
+
+		pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
+		pTimer = &pTimerInfo->m_Timer;
+		hrtimer_init(pTimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
+
+		pTimer->function = EplTimerHighReskCallback;
 
+		/*
+		 * We use HRTIMER_CB_SOFTIRQ here.
+		 * HRTIMER_CB_IRQSAFE is critical as the callback function
+		 * would be called with IRQs disabled.
+		 */
+		pTimer->cb_mode = HRTIMER_CB_SOFTIRQ;
+	}
+
+	return Ret;
+}
 
 //---------------------------------------------------------------------------
 //
@@ -259,30 +253,28 @@ unsigned int                 uiIndex;
 
 tEplKernel PUBLIC EplTimerHighReskDelInstance(void)
 {
-tEplTimerHighReskTimerInfo*  pTimerInfo;
-tEplKernel                   Ret;
-unsigned int                 uiIndex;
-
-    Ret = kEplSuccessful;
-
-    for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++)
-    {
-        pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
-        pTimerInfo->m_pfnCallback = NULL;
-        pTimerInfo->m_EventArg.m_TimerHdl = 0;
-        /*
-         * In this case we can not just try to cancel the timer.
-         * We actually have to wait until its callback function
-         * has returned.
-         */
-        hrtimer_cancel(&pTimerInfo->m_Timer);
-    }
-
-    return Ret;
+	tEplTimerHighReskTimerInfo *pTimerInfo;
+	tEplKernel Ret;
+	unsigned int uiIndex;
+
+	Ret = kEplSuccessful;
+
+	for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++) {
+		pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
+		pTimerInfo->m_pfnCallback = NULL;
+		pTimerInfo->m_EventArg.m_TimerHdl = 0;
+		/*
+		 * In this case we can not just try to cancel the timer.
+		 * We actually have to wait until its callback function
+		 * has returned.
+		 */
+		hrtimer_cancel(&pTimerInfo->m_Timer);
+	}
+
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimerHighReskModifyTimerNs()
@@ -313,96 +305,89 @@ unsigned int                 uiIndex;
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplTimerHighReskModifyTimerNs(tEplTimerHdl*     pTimerHdl_p,
-                                    unsigned long long  ullTimeNs_p,
-                                    tEplTimerkCallback  pfnCallback_p,
-                                    unsigned long       ulArgument_p,
-                                    BOOL                fContinuously_p)
+tEplKernel PUBLIC EplTimerHighReskModifyTimerNs(tEplTimerHdl * pTimerHdl_p,
+						unsigned long long ullTimeNs_p,
+						tEplTimerkCallback
+						pfnCallback_p,
+						unsigned long ulArgument_p,
+						BOOL fContinuously_p)
 {
-tEplKernel                   Ret;
-unsigned int                 uiIndex;
-tEplTimerHighReskTimerInfo*  pTimerInfo;
-ktime_t                      RelTime;
-
-    Ret = kEplSuccessful;
-
-    // check pointer to handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    if (*pTimerHdl_p == 0)
-    {   // no timer created yet
-
-        // search free timer info structure
-        pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
-        for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++, pTimerInfo++)
-        {
-            if (pTimerInfo->m_EventArg.m_TimerHdl == 0)
-            {   // free structure found
-                break;
-            }
-        }
-        if (uiIndex >= TIMER_COUNT)
-        {   // no free structure found
-            Ret = kEplTimerNoTimerCreated;
-            goto Exit;
-        }
-
-        pTimerInfo->m_EventArg.m_TimerHdl = HDL_INIT(uiIndex);
-    }
-    else
-    {
-        uiIndex = HDL_TO_IDX(*pTimerHdl_p);
-        if (uiIndex >= TIMER_COUNT)
-        {   // invalid handle
-            Ret = kEplTimerInvalidHandle;
-            goto Exit;
-        }
-
-        pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
-    }
-
-    /*
-     * increment timer handle
-     * (if timer expires right after this statement, the user
-     * would detect an unknown timer handle and discard it)
-     */
-    pTimerInfo->m_EventArg.m_TimerHdl = HDL_INC(pTimerInfo->m_EventArg.m_TimerHdl);
-    *pTimerHdl_p = pTimerInfo->m_EventArg.m_TimerHdl;
-
-    // reject too small time values
-    if (    (fContinuously_p  && (ullTimeNs_p < TIMER_MIN_VAL_CYCLE))
-         || (!fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_SINGLE)) )
-    {
-        Ret = kEplTimerNoTimerCreated;
-        goto Exit;
-    }
-
-    pTimerInfo->m_EventArg.m_ulArg = ulArgument_p;
-    pTimerInfo->m_pfnCallback      = pfnCallback_p;
-    pTimerInfo->m_fContinuously    = fContinuously_p;
-    pTimerInfo->m_ullPeriod        = ullTimeNs_p;
-
-    /*
-     * HRTIMER_MODE_REL does not influence general handling of this timer.
-     * It only sets relative mode for this start operation.
-     * -> Expire time is calculated by: Now + RelTime
-     * hrtimer_start also skips pending timer events.
-     * The state HRTIMER_STATE_CALLBACK is ignored.
-     * We have to cope with that in our callback function.
-     */
-    RelTime = ktime_add_ns(ktime_set(0,0), ullTimeNs_p);
-    hrtimer_start(&pTimerInfo->m_Timer, RelTime, HRTIMER_MODE_REL);
-
-Exit:
-    return Ret;
+	tEplKernel Ret;
+	unsigned int uiIndex;
+	tEplTimerHighReskTimerInfo *pTimerInfo;
+	ktime_t RelTime;
+
+	Ret = kEplSuccessful;
+
+	// check pointer to handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+
+	if (*pTimerHdl_p == 0) {	// no timer created yet
+
+		// search free timer info structure
+		pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
+		for (uiIndex = 0; uiIndex < TIMER_COUNT;
+		     uiIndex++, pTimerInfo++) {
+			if (pTimerInfo->m_EventArg.m_TimerHdl == 0) {	// free structure found
+				break;
+			}
+		}
+		if (uiIndex >= TIMER_COUNT) {	// no free structure found
+			Ret = kEplTimerNoTimerCreated;
+			goto Exit;
+		}
+
+		pTimerInfo->m_EventArg.m_TimerHdl = HDL_INIT(uiIndex);
+	} else {
+		uiIndex = HDL_TO_IDX(*pTimerHdl_p);
+		if (uiIndex >= TIMER_COUNT) {	// invalid handle
+			Ret = kEplTimerInvalidHandle;
+			goto Exit;
+		}
+
+		pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
+	}
+
+	/*
+	 * increment timer handle
+	 * (if timer expires right after this statement, the user
+	 * would detect an unknown timer handle and discard it)
+	 */
+	pTimerInfo->m_EventArg.m_TimerHdl =
+	    HDL_INC(pTimerInfo->m_EventArg.m_TimerHdl);
+	*pTimerHdl_p = pTimerInfo->m_EventArg.m_TimerHdl;
+
+	// reject too small time values
+	if ((fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_CYCLE))
+	    || (!fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_SINGLE))) {
+		Ret = kEplTimerNoTimerCreated;
+		goto Exit;
+	}
+
+	pTimerInfo->m_EventArg.m_ulArg = ulArgument_p;
+	pTimerInfo->m_pfnCallback = pfnCallback_p;
+	pTimerInfo->m_fContinuously = fContinuously_p;
+	pTimerInfo->m_ullPeriod = ullTimeNs_p;
+
+	/*
+	 * HRTIMER_MODE_REL does not influence general handling of this timer.
+	 * It only sets relative mode for this start operation.
+	 * -> Expire time is calculated by: Now + RelTime
+	 * hrtimer_start also skips pending timer events.
+	 * The state HRTIMER_STATE_CALLBACK is ignored.
+	 * We have to cope with that in our callback function.
+	 */
+	RelTime = ktime_add_ns(ktime_set(0, 0), ullTimeNs_p);
+	hrtimer_start(&pTimerInfo->m_Timer, RelTime, HRTIMER_MODE_REL);
+
+      Exit:
+	return Ret;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimerHighReskDeleteTimer()
@@ -418,64 +403,56 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-tEplKernel PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl* pTimerHdl_p)
+tEplKernel PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl * pTimerHdl_p)
 {
-tEplKernel                  Ret = kEplSuccessful;
-unsigned int                uiIndex;
-tEplTimerHighReskTimerInfo* pTimerInfo;
-
-    // check pointer to handle
-    if(pTimerHdl_p == NULL)
-    {
-        Ret = kEplTimerInvalidHandle;
-        goto Exit;
-    }
-
-    if (*pTimerHdl_p == 0)
-    {   // no timer created yet
-        goto Exit;
-    }
-    else
-    {
-        uiIndex = HDL_TO_IDX(*pTimerHdl_p);
-        if (uiIndex >= TIMER_COUNT)
-        {   // invalid handle
-            Ret = kEplTimerInvalidHandle;
-            goto Exit;
-        }
-        pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
-        if (pTimerInfo->m_EventArg.m_TimerHdl != *pTimerHdl_p)
-        {   // invalid handle
-            goto Exit;
-        }
-    }
-
-    *pTimerHdl_p = 0;
-    pTimerInfo->m_EventArg.m_TimerHdl = 0;
-    pTimerInfo->m_pfnCallback = NULL;
-
-    /*
-     * Three return cases of hrtimer_try_to_cancel have to be tracked:
-     *  1 - timer has been removed
-     *  0 - timer was not active
-     *      We need not do anything. hrtimer timers just consist of
-     *      a hrtimer struct, which we might enqueue in the hrtimers
-     *      event list by calling hrtimer_start().
-     *      If a timer is not enqueued, it is not present in hrtimers.
-     * -1 - callback function is running
-     *      In this case we have to ensure that the timer is not
-     *      continuously restarted. This has been done by clearing
-     *      its handle.
-     */
-    hrtimer_try_to_cancel(&pTimerInfo->m_Timer);
-
-Exit:
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+	unsigned int uiIndex;
+	tEplTimerHighReskTimerInfo *pTimerInfo;
+
+	// check pointer to handle
+	if (pTimerHdl_p == NULL) {
+		Ret = kEplTimerInvalidHandle;
+		goto Exit;
+	}
+
+	if (*pTimerHdl_p == 0) {	// no timer created yet
+		goto Exit;
+	} else {
+		uiIndex = HDL_TO_IDX(*pTimerHdl_p);
+		if (uiIndex >= TIMER_COUNT) {	// invalid handle
+			Ret = kEplTimerInvalidHandle;
+			goto Exit;
+		}
+		pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
+		if (pTimerInfo->m_EventArg.m_TimerHdl != *pTimerHdl_p) {	// invalid handle
+			goto Exit;
+		}
+	}
+
+	*pTimerHdl_p = 0;
+	pTimerInfo->m_EventArg.m_TimerHdl = 0;
+	pTimerInfo->m_pfnCallback = NULL;
+
+	/*
+	 * Three return cases of hrtimer_try_to_cancel have to be tracked:
+	 *  1 - timer has been removed
+	 *  0 - timer was not active
+	 *      We need not do anything. hrtimer timers just consist of
+	 *      a hrtimer struct, which we might enqueue in the hrtimers
+	 *      event list by calling hrtimer_start().
+	 *      If a timer is not enqueued, it is not present in hrtimers.
+	 * -1 - callback function is running
+	 *      In this case we have to ensure that the timer is not
+	 *      continuously restarted. This has been done by clearing
+	 *      its handle.
+	 */
+	hrtimer_try_to_cancel(&pTimerInfo->m_Timer);
+
+      Exit:
+	return Ret;
 
 }
 
-
-
 //---------------------------------------------------------------------------
 //
 // Function:    EplTimerHighReskCallback()
@@ -490,66 +467,63 @@ Exit:
 //
 //---------------------------------------------------------------------------
 
-enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p)
+enum hrtimer_restart EplTimerHighReskCallback(struct hrtimer *pTimer_p)
 {
-unsigned int                 uiIndex;
-tEplTimerHighReskTimerInfo*  pTimerInfo;
-tEplTimerHdl                 OrgTimerHdl;
-enum hrtimer_restart         Ret;
-
-    BENCHMARK_MOD_24_SET(4);
-
-    Ret        = HRTIMER_NORESTART;
-    pTimerInfo = container_of(pTimer_p, tEplTimerHighReskTimerInfo, m_Timer);
-    uiIndex    = HDL_TO_IDX(pTimerInfo->m_EventArg.m_TimerHdl);
-    if (uiIndex >= TIMER_COUNT)
-    {   // invalid handle
-        goto Exit;
-    }
-
-    /*
-     * We store the timer handle before calling the callback function
-     * as the timer can be modified inside it.
-     */
-    OrgTimerHdl = pTimerInfo->m_EventArg.m_TimerHdl;
-
-    if (pTimerInfo->m_pfnCallback != NULL)
-    {
-        pTimerInfo->m_pfnCallback(&pTimerInfo->m_EventArg);
-    }
-
-    if (pTimerInfo->m_fContinuously)
-    {
-    ktime_t        Interval;
+	unsigned int uiIndex;
+	tEplTimerHighReskTimerInfo *pTimerInfo;
+	tEplTimerHdl OrgTimerHdl;
+	enum hrtimer_restart Ret;
+
+	BENCHMARK_MOD_24_SET(4);
+
+	Ret = HRTIMER_NORESTART;
+	pTimerInfo =
+	    container_of(pTimer_p, tEplTimerHighReskTimerInfo, m_Timer);
+	uiIndex = HDL_TO_IDX(pTimerInfo->m_EventArg.m_TimerHdl);
+	if (uiIndex >= TIMER_COUNT) {	// invalid handle
+		goto Exit;
+	}
+
+	/*
+	 * We store the timer handle before calling the callback function
+	 * as the timer can be modified inside it.
+	 */
+	OrgTimerHdl = pTimerInfo->m_EventArg.m_TimerHdl;
+
+	if (pTimerInfo->m_pfnCallback != NULL) {
+		pTimerInfo->m_pfnCallback(&pTimerInfo->m_EventArg);
+	}
+
+	if (pTimerInfo->m_fContinuously) {
+		ktime_t Interval;
 #ifdef PROVE_OVERRUN
-    ktime_t        Now;
-    unsigned long  Overruns;
+		ktime_t Now;
+		unsigned long Overruns;
 #endif
 
-        if (OrgTimerHdl != pTimerInfo->m_EventArg.m_TimerHdl)
-        {
-            /* modified timer has already been restarted */
-            goto Exit;
-        }
-
+		if (OrgTimerHdl != pTimerInfo->m_EventArg.m_TimerHdl) {
+			/* modified timer has already been restarted */
+			goto Exit;
+		}
 #ifdef PROVE_OVERRUN
-        Now      = ktime_get();
-        Interval = ktime_add_ns(ktime_set(0,0), pTimerInfo->m_ullPeriod);
-        Overruns = hrtimer_forward(pTimer_p, Now, Interval);
-        if (Overruns > 1)
-        {
-            printk("EplTimerHighResk: Continuous timer (handle 0x%lX) had to skip %lu interval(s)!\n", pTimerInfo->m_EventArg.m_TimerHdl, Overruns-1);
-        }
+		Now = ktime_get();
+		Interval =
+		    ktime_add_ns(ktime_set(0, 0), pTimerInfo->m_ullPeriod);
+		Overruns = hrtimer_forward(pTimer_p, Now, Interval);
+		if (Overruns > 1) {
+			printk
+			    ("EplTimerHighResk: Continuous timer (handle 0x%lX) had to skip %lu interval(s)!\n",
+			     pTimerInfo->m_EventArg.m_TimerHdl, Overruns - 1);
+		}
 #else
-        pTimer_p->expires = ktime_add_ns(pTimer_p->expires,
-                                         pTimerInfo->m_ullPeriod);
+		pTimer_p->expires = ktime_add_ns(pTimer_p->expires,
+						 pTimerInfo->m_ullPeriod);
 #endif
 
-        Ret = HRTIMER_RESTART;
-    }
+		Ret = HRTIMER_RESTART;
+	}
 
-Exit:
-    BENCHMARK_MOD_24_RESET(4);
-    return Ret;
+      Exit:
+	BENCHMARK_MOD_24_RESET(4);
+	return Ret;
 }
-

+ 129 - 143
drivers/staging/epl/VirtualEthernetLinux.c

@@ -59,7 +59,6 @@
 
                 Build Environment:
 
-
   -------------------------------------------------------------------------
 
   Revision History:
@@ -75,7 +74,6 @@
 
 ****************************************************************************/
 
-
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
@@ -93,13 +91,12 @@
 #include <linux/udp.h>
 #include <linux/mm.h>
 #include <linux/types.h>
-#include <linux/skbuff.h>  /* for struct sk_buff */
+#include <linux/skbuff.h>	/* for struct sk_buff */
 
 #include "kernel/VirtualEthernet.h"
 #include "kernel/EplDllkCal.h"
 #include "kernel/EplDllk.h"
 
-
 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)
 
 /***************************************************************************/
@@ -110,28 +107,24 @@
 /*                                                                         */
 /***************************************************************************/
 
-
 //---------------------------------------------------------------------------
 // const defines
 //---------------------------------------------------------------------------
 
 #ifndef EPL_VETH_TX_TIMEOUT
 //#define EPL_VETH_TX_TIMEOUT (2*HZ)
-#define EPL_VETH_TX_TIMEOUT 0       // d.k.: we use no timeout
+#define EPL_VETH_TX_TIMEOUT 0	// d.k.: we use no timeout
 #endif
 
-
 //---------------------------------------------------------------------------
 // local types
 //---------------------------------------------------------------------------
 
-
-
 //---------------------------------------------------------------------------
 // modul globale vars
 //---------------------------------------------------------------------------
 
-static struct net_device * pVEthNetDevice_g = NULL;
+static struct net_device *pVEthNetDevice_g = NULL;
 
 //---------------------------------------------------------------------------
 // local function prototypes
@@ -140,11 +133,10 @@ static struct net_device * pVEthNetDevice_g = NULL;
 static int VEthOpen(struct net_device *pNetDevice_p);
 static int VEthClose(struct net_device *pNetDevice_p);
 static int VEthXmit(struct sk_buff *pSkb_p, struct net_device *pNetDevice_p);
-static struct net_device_stats* VEthGetStats(struct net_device *pNetDevice_p);
+static struct net_device_stats *VEthGetStats(struct net_device *pNetDevice_p);
 static void VEthTimeout(struct net_device *pNetDevice_p);
 static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p);
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -171,188 +163,182 @@ static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p);
 
 static int VEthOpen(struct net_device *pNetDevice_p)
 {
-tEplKernel  Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    //open the device
+	//open the device
 //    struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice_p->priv;
 
-    //start the interface queue for the network subsystem
-    netif_start_queue(pNetDevice_p);
+	//start the interface queue for the network subsystem
+	netif_start_queue(pNetDevice_p);
 
-    // register callback function in DLL
-    Ret = EplDllkRegAsyncHandler(VEthRecvFrame);
+	// register callback function in DLL
+	Ret = EplDllkRegAsyncHandler(VEthRecvFrame);
 
-    EPL_DBGLVL_VETH_TRACE1("VEthOpen: EplDllkRegAsyncHandler returned 0x%02X\n", Ret);
+	EPL_DBGLVL_VETH_TRACE1
+	    ("VEthOpen: EplDllkRegAsyncHandler returned 0x%02X\n", Ret);
 
-    return 0;
+	return 0;
 }
 
 static int VEthClose(struct net_device *pNetDevice_p)
 {
-tEplKernel  Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    EPL_DBGLVL_VETH_TRACE0("VEthClose\n");
+	EPL_DBGLVL_VETH_TRACE0("VEthClose\n");
 
-    Ret = EplDllkDeregAsyncHandler(VEthRecvFrame);
+	Ret = EplDllkDeregAsyncHandler(VEthRecvFrame);
 
-    //stop the interface queue for the network subsystem
-    netif_stop_queue(pNetDevice_p);
-    return 0;
+	//stop the interface queue for the network subsystem
+	netif_stop_queue(pNetDevice_p);
+	return 0;
 }
 
-
 static int VEthXmit(struct sk_buff *pSkb_p, struct net_device *pNetDevice_p)
 {
-tEplKernel      Ret = kEplSuccessful;
-tEplFrameInfo   FrameInfo;
-
-    //transmit function
-    struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice_p->priv;
-
-    //save timestemp
-    pNetDevice_p->trans_start = jiffies;
-
-    FrameInfo.m_pFrame = (tEplFrame *)pSkb_p->data;
-    FrameInfo.m_uiFrameSize = pSkb_p->len;
-
-    //call send fkt on DLL
-    Ret = EplDllkCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
-    if (Ret != kEplSuccessful)
-    {
-        EPL_DBGLVL_VETH_TRACE1("VEthXmit: EplDllkCalAsyncSend returned 0x%02X\n", Ret);
-        netif_stop_queue(pNetDevice_p);
-        goto Exit;
-    }
-    else
-    {
-        EPL_DBGLVL_VETH_TRACE0("VEthXmit: frame passed to DLL\n");
-        dev_kfree_skb(pSkb_p);
-
-        //set stats for the device
-        pStats->tx_packets++;
-        pStats->tx_bytes += FrameInfo.m_uiFrameSize;
-    }
-
-Exit:
-    return 0;
+	tEplKernel Ret = kEplSuccessful;
+	tEplFrameInfo FrameInfo;
+
+	//transmit function
+	struct net_device_stats *pStats =
+	    (struct net_device_stats *)pNetDevice_p->priv;
+
+	//save timestemp
+	pNetDevice_p->trans_start = jiffies;
+
+	FrameInfo.m_pFrame = (tEplFrame *) pSkb_p->data;
+	FrameInfo.m_uiFrameSize = pSkb_p->len;
+
+	//call send fkt on DLL
+	Ret = EplDllkCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
+	if (Ret != kEplSuccessful) {
+		EPL_DBGLVL_VETH_TRACE1
+		    ("VEthXmit: EplDllkCalAsyncSend returned 0x%02X\n", Ret);
+		netif_stop_queue(pNetDevice_p);
+		goto Exit;
+	} else {
+		EPL_DBGLVL_VETH_TRACE0("VEthXmit: frame passed to DLL\n");
+		dev_kfree_skb(pSkb_p);
+
+		//set stats for the device
+		pStats->tx_packets++;
+		pStats->tx_bytes += FrameInfo.m_uiFrameSize;
+	}
+
+      Exit:
+	return 0;
 
 }
 
-
-static struct net_device_stats* VEthGetStats(struct net_device *pNetDevice_p)
+static struct net_device_stats *VEthGetStats(struct net_device *pNetDevice_p)
 {
-    EPL_DBGLVL_VETH_TRACE0("VEthGetStats\n");
+	EPL_DBGLVL_VETH_TRACE0("VEthGetStats\n");
 
-    return (struct net_device_stats *)pNetDevice_p->priv;
+	return (struct net_device_stats *)pNetDevice_p->priv;
 }
 
-
-
 static void VEthTimeout(struct net_device *pNetDevice_p)
 {
-    EPL_DBGLVL_VETH_TRACE0("VEthTimeout(\n");
+	EPL_DBGLVL_VETH_TRACE0("VEthTimeout(\n");
 
-    // $$$ d.k.: move to extra function, which is called by DLL when new space is available in TxFifo
-    if (netif_queue_stopped (pNetDevice_p))
-    {
-        netif_wake_queue (pNetDevice_p);
-    }
+	// $$$ d.k.: move to extra function, which is called by DLL when new space is available in TxFifo
+	if (netif_queue_stopped(pNetDevice_p)) {
+		netif_wake_queue(pNetDevice_p);
+	}
 }
 
-
-
 static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p)
 {
-tEplKernel  Ret = kEplSuccessful;
-    struct net_device* pNetDevice = pVEthNetDevice_g;
-    struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice->priv;
-    struct sk_buff *pSkb;
+	tEplKernel Ret = kEplSuccessful;
+	struct net_device *pNetDevice = pVEthNetDevice_g;
+	struct net_device_stats *pStats =
+	    (struct net_device_stats *)pNetDevice->priv;
+	struct sk_buff *pSkb;
 
-    EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: FrameSize=%u\n", pFrameInfo_p->m_uiFrameSize);
+	EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: FrameSize=%u\n",
+			       pFrameInfo_p->m_uiFrameSize);
 
-    pSkb = dev_alloc_skb(pFrameInfo_p->m_uiFrameSize + 2);
-    if (pSkb == NULL)
-    {
-        pStats->rx_dropped++;
-        goto Exit;
-    }
-    pSkb->dev = pNetDevice;
+	pSkb = dev_alloc_skb(pFrameInfo_p->m_uiFrameSize + 2);
+	if (pSkb == NULL) {
+		pStats->rx_dropped++;
+		goto Exit;
+	}
+	pSkb->dev = pNetDevice;
 
-    skb_reserve(pSkb, 2);
+	skb_reserve(pSkb, 2);
 
-    memcpy((void *)skb_put(pSkb, pFrameInfo_p->m_uiFrameSize), pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
+	memcpy((void *)skb_put(pSkb, pFrameInfo_p->m_uiFrameSize),
+	       pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
 
-    pSkb->protocol = eth_type_trans(pSkb, pNetDevice);
-    pSkb->ip_summed = CHECKSUM_UNNECESSARY;
+	pSkb->protocol = eth_type_trans(pSkb, pNetDevice);
+	pSkb->ip_summed = CHECKSUM_UNNECESSARY;
 
-    // call netif_rx with skb
-    netif_rx(pSkb);
+	// call netif_rx with skb
+	netif_rx(pSkb);
 
-    EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: SrcMAC=0x%llx\n", AmiGetQword48FromBe(pFrameInfo_p->m_pFrame->m_be_abSrcMac));
+	EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: SrcMAC=0x%llx\n",
+			       AmiGetQword48FromBe(pFrameInfo_p->m_pFrame->
+						   m_be_abSrcMac));
 
-    // update receive statistics
-    pStats->rx_packets++;
-    pStats->rx_bytes += pFrameInfo_p->m_uiFrameSize;
+	// update receive statistics
+	pStats->rx_packets++;
+	pStats->rx_bytes += pFrameInfo_p->m_uiFrameSize;
 
-Exit:
-    return Ret;
+      Exit:
+	return Ret;
 }
 
-
 tEplKernel PUBLIC VEthAddInstance(tEplDllkInitParam * pInitParam_p)
 {
-tEplKernel  Ret = kEplSuccessful;
+	tEplKernel Ret = kEplSuccessful;
 
-    // allocate net device structure with priv pointing to stats structure
-    pVEthNetDevice_g = alloc_netdev(sizeof (struct net_device_stats), EPL_VETH_NAME, ether_setup);
+	// allocate net device structure with priv pointing to stats structure
+	pVEthNetDevice_g =
+	    alloc_netdev(sizeof(struct net_device_stats), EPL_VETH_NAME,
+			 ether_setup);
 //    pVEthNetDevice_g = alloc_etherdev(sizeof (struct net_device_stats));
 
-    if (pVEthNetDevice_g == NULL)
-    {
-        Ret = kEplNoResource;
-        goto Exit;
-    }
-
-    pVEthNetDevice_g->open               = VEthOpen;
-    pVEthNetDevice_g->stop               = VEthClose;
-    pVEthNetDevice_g->get_stats          = VEthGetStats;
-    pVEthNetDevice_g->hard_start_xmit    = VEthXmit;
-    pVEthNetDevice_g->tx_timeout         = VEthTimeout;
-    pVEthNetDevice_g->watchdog_timeo     = EPL_VETH_TX_TIMEOUT;
-    pVEthNetDevice_g->destructor         = free_netdev;
-
-    // copy own MAC address to net device structure
-    memcpy(pVEthNetDevice_g->dev_addr, pInitParam_p->m_be_abSrcMac, 6);
-
-    //register VEth to the network subsystem
-    if (register_netdev(pVEthNetDevice_g))
-    {
-        EPL_DBGLVL_VETH_TRACE0("VEthAddInstance: Could not register VEth...\n");
-    }
-    else
-    {
-        EPL_DBGLVL_VETH_TRACE0("VEthAddInstance: Register VEth successfull...\n");
-    }
-
-Exit:
-    return Ret;
+	if (pVEthNetDevice_g == NULL) {
+		Ret = kEplNoResource;
+		goto Exit;
+	}
+
+	pVEthNetDevice_g->open = VEthOpen;
+	pVEthNetDevice_g->stop = VEthClose;
+	pVEthNetDevice_g->get_stats = VEthGetStats;
+	pVEthNetDevice_g->hard_start_xmit = VEthXmit;
+	pVEthNetDevice_g->tx_timeout = VEthTimeout;
+	pVEthNetDevice_g->watchdog_timeo = EPL_VETH_TX_TIMEOUT;
+	pVEthNetDevice_g->destructor = free_netdev;
+
+	// copy own MAC address to net device structure
+	memcpy(pVEthNetDevice_g->dev_addr, pInitParam_p->m_be_abSrcMac, 6);
+
+	//register VEth to the network subsystem
+	if (register_netdev(pVEthNetDevice_g)) {
+		EPL_DBGLVL_VETH_TRACE0
+		    ("VEthAddInstance: Could not register VEth...\n");
+	} else {
+		EPL_DBGLVL_VETH_TRACE0
+		    ("VEthAddInstance: Register VEth successfull...\n");
+	}
+
+      Exit:
+	return Ret;
 }
 
-
 tEplKernel PUBLIC VEthDelInstance(void)
 {
-tEplKernel  Ret = kEplSuccessful;
-
-    if (pVEthNetDevice_g != NULL)
-    {
-        //unregister VEth from the network subsystem
-        unregister_netdev(pVEthNetDevice_g);
-        // destructor was set to free_netdev,
-        // so we do not need to call free_netdev here
-        pVEthNetDevice_g = NULL;
-    }
-
-    return Ret;
+	tEplKernel Ret = kEplSuccessful;
+
+	if (pVEthNetDevice_g != NULL) {
+		//unregister VEth from the network subsystem
+		unregister_netdev(pVEthNetDevice_g);
+		// destructor was set to free_netdev,
+		// so we do not need to call free_netdev here
+		pVEthNetDevice_g = NULL;
+	}
+
+	return Ret;
 }
 
 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)

+ 185 - 225
drivers/staging/epl/amix86.c

@@ -80,25 +80,21 @@
 // typedef
 //---------------------------------------------------------------------------
 
-typedef struct
-{
-   WORD  m_wWord;
+typedef struct {
+	WORD m_wWord;
 
 } twStruct;
 
-typedef struct
-{
-   DWORD  m_dwDword;
+typedef struct {
+	DWORD m_dwDword;
 
 } tdwStruct;
 
-typedef struct
-{
-   QWORD  m_qwQword;
+typedef struct {
+	QWORD m_qwQword;
 
 } tqwStruct;
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -131,46 +127,39 @@ void  PUBLIC  AmiSetByteToBe (void FAR* pAddr_p, BYTE bByteVal_p)
 }
 */
 
-
-
 //------------< write WORD in big endian >--------------------------
 
-INLINE_FUNCTION void  PUBLIC  AmiSetWordToBe (void FAR* pAddr_p, WORD wWordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetWordToBe(void FAR * pAddr_p, WORD wWordVal_p)
 {
-twStruct FAR*  pwStruct;
-twStruct wValue;
+	twStruct FAR *pwStruct;
+	twStruct wValue;
 
-   wValue.m_wWord   = (WORD)((wWordVal_p & 0x00FF) << 8); //LSB to MSB
-   wValue.m_wWord  |= (WORD)((wWordVal_p & 0xFF00) >> 8); //MSB to LSB
+	wValue.m_wWord = (WORD) ((wWordVal_p & 0x00FF) << 8);	//LSB to MSB
+	wValue.m_wWord |= (WORD) ((wWordVal_p & 0xFF00) >> 8);	//MSB to LSB
 
-   pwStruct = (twStruct FAR*)pAddr_p;
-   pwStruct->m_wWord = wValue.m_wWord;
+	pwStruct = (twStruct FAR *) pAddr_p;
+	pwStruct->m_wWord = wValue.m_wWord;
 
 }
 
-
-
 //------------< write DWORD in big endian >-------------------------
 
-INLINE_FUNCTION void  PUBLIC  AmiSetDwordToBe (void FAR* pAddr_p, DWORD dwDwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetDwordToBe(void FAR * pAddr_p,
+					    DWORD dwDwordVal_p)
 {
-tdwStruct FAR*  pdwStruct;
-tdwStruct dwValue;
-
+	tdwStruct FAR *pdwStruct;
+	tdwStruct dwValue;
 
-   dwValue.m_dwDword = ((dwDwordVal_p & 0x000000FF)<<24); //LSB to MSB
-   dwValue.m_dwDword|= ((dwDwordVal_p & 0x0000FF00)<<8);
-   dwValue.m_dwDword|= ((dwDwordVal_p & 0x00FF0000)>>8 );
-   dwValue.m_dwDword|= ((dwDwordVal_p & 0xFF000000)>>24); //MSB to LSB
+	dwValue.m_dwDword = ((dwDwordVal_p & 0x000000FF) << 24);	//LSB to MSB
+	dwValue.m_dwDword |= ((dwDwordVal_p & 0x0000FF00) << 8);
+	dwValue.m_dwDword |= ((dwDwordVal_p & 0x00FF0000) >> 8);
+	dwValue.m_dwDword |= ((dwDwordVal_p & 0xFF000000) >> 24);	//MSB to LSB
 
-   pdwStruct = (tdwStruct FAR*)pAddr_p;
-   pdwStruct->m_dwDword = dwValue.m_dwDword;
+	pdwStruct = (tdwStruct FAR *) pAddr_p;
+	pdwStruct->m_dwDword = dwValue.m_dwDword;
 
 }
 
-
-
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetXXXToLe()
@@ -197,35 +186,29 @@ void  PUBLIC  AmiSetByteToLe (void FAR* pAddr_p, BYTE bByteVal_p)
 }
 */
 
-
-
 //------------< write WORD in little endian >--------------------------
 
-INLINE_FUNCTION void  PUBLIC  AmiSetWordToLe (void FAR* pAddr_p, WORD wWordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetWordToLe(void FAR * pAddr_p, WORD wWordVal_p)
 {
-twStruct FAR*  pwStruct;
+	twStruct FAR *pwStruct;
 
-   pwStruct = (twStruct FAR*)pAddr_p;
-   pwStruct->m_wWord = wWordVal_p;
+	pwStruct = (twStruct FAR *) pAddr_p;
+	pwStruct->m_wWord = wWordVal_p;
 
 }
 
-
-
 //------------< write DWORD in little endian >-------------------------
 
-INLINE_FUNCTION void  PUBLIC  AmiSetDwordToLe (void FAR* pAddr_p, DWORD dwDwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetDwordToLe(void FAR * pAddr_p,
+					    DWORD dwDwordVal_p)
 {
-tdwStruct FAR*  pdwStruct;
+	tdwStruct FAR *pdwStruct;
 
-   pdwStruct = (tdwStruct FAR*)pAddr_p;
-   pdwStruct->m_dwDword = dwDwordVal_p;
+	pdwStruct = (tdwStruct FAR *) pAddr_p;
+	pdwStruct->m_dwDword = dwDwordVal_p;
 
 }
 
-
-
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetXXXFromBe()
@@ -251,46 +234,40 @@ BYTE  PUBLIC  AmiGetByteFromBe (void FAR* pAddr_p)
 }
 */
 
-
-
 //------------< read WORD in big endian >---------------------------
 
-INLINE_FUNCTION WORD  PUBLIC  AmiGetWordFromBe (void FAR* pAddr_p)
+INLINE_FUNCTION WORD PUBLIC AmiGetWordFromBe(void FAR * pAddr_p)
 {
-twStruct FAR*  pwStruct;
-twStruct wValue;
+	twStruct FAR *pwStruct;
+	twStruct wValue;
 
-   pwStruct = (twStruct FAR*)pAddr_p;
+	pwStruct = (twStruct FAR *) pAddr_p;
 
-   wValue.m_wWord   = (WORD)((pwStruct->m_wWord & 0x00FF) << 8); //LSB to MSB
-   wValue.m_wWord  |= (WORD)((pwStruct->m_wWord & 0xFF00) >> 8); //MSB to LSB
+	wValue.m_wWord = (WORD) ((pwStruct->m_wWord & 0x00FF) << 8);	//LSB to MSB
+	wValue.m_wWord |= (WORD) ((pwStruct->m_wWord & 0xFF00) >> 8);	//MSB to LSB
 
-   return ( wValue.m_wWord );
+	return (wValue.m_wWord);
 
 }
 
-
-
-
 //------------< read DWORD in big endian >--------------------------
 
-INLINE_FUNCTION DWORD  PUBLIC  AmiGetDwordFromBe (void FAR* pAddr_p)
+INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromBe(void FAR * pAddr_p)
 {
-tdwStruct FAR*  pdwStruct;
-tdwStruct dwValue;
+	tdwStruct FAR *pdwStruct;
+	tdwStruct dwValue;
 
-   pdwStruct = (tdwStruct FAR*)pAddr_p;
+	pdwStruct = (tdwStruct FAR *) pAddr_p;
 
-   dwValue.m_dwDword = ((pdwStruct->m_dwDword & 0x000000FF)<<24); //LSB to MSB
-   dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0x0000FF00)<<8);
-   dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0x00FF0000)>>8 );
-   dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0xFF000000)>>24); //MSB to LSB
+	dwValue.m_dwDword = ((pdwStruct->m_dwDword & 0x000000FF) << 24);	//LSB to MSB
+	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x0000FF00) << 8);
+	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x00FF0000) >> 8);
+	dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0xFF000000) >> 24);	//MSB to LSB
 
-   return ( dwValue.m_dwDword );
+	return (dwValue.m_dwDword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetXXXFromLe()
@@ -316,34 +293,28 @@ BYTE  PUBLIC  AmiGetByteFromLe (void FAR* pAddr_p)
 }
 */
 
-
-
 //------------< read WORD in little endian >---------------------------
 
-INLINE_FUNCTION WORD  PUBLIC  AmiGetWordFromLe (void FAR* pAddr_p)
+INLINE_FUNCTION WORD PUBLIC AmiGetWordFromLe(void FAR * pAddr_p)
 {
-twStruct FAR*  pwStruct;
+	twStruct FAR *pwStruct;
 
-   pwStruct = (twStruct FAR*)pAddr_p;
-   return ( pwStruct->m_wWord );
+	pwStruct = (twStruct FAR *) pAddr_p;
+	return (pwStruct->m_wWord);
 
 }
 
-
-
-
 //------------< read DWORD in little endian >--------------------------
 
-INLINE_FUNCTION DWORD  PUBLIC  AmiGetDwordFromLe (void FAR* pAddr_p)
+INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromLe(void FAR * pAddr_p)
 {
-tdwStruct FAR*  pdwStruct;
+	tdwStruct FAR *pdwStruct;
 
-   pdwStruct = (tdwStruct FAR*)pAddr_p;
-   return ( pdwStruct->m_dwDword );
+	pdwStruct = (tdwStruct FAR *) pAddr_p;
+	return (pdwStruct->m_dwDword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetDword24ToBe()
@@ -359,16 +330,16 @@ tdwStruct FAR*  pdwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe(void FAR * pAddr_p,
+					      DWORD dwDwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &dwDwordVal_p)[2];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &dwDwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &dwDwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[0];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetDword24ToLe()
@@ -384,16 +355,16 @@ INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe(void FAR * pAddr_p,
+					      DWORD dwDwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &dwDwordVal_p)[0];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &dwDwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &dwDwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[2];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetDword24FromBe()
@@ -408,19 +379,18 @@ INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe (void FAR* pAddr_p)
+INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe(void FAR * pAddr_p)
 {
 
-tdwStruct      dwStruct;
+	tdwStruct dwStruct;
 
-    dwStruct.m_dwDword  = AmiGetDwordFromBe (pAddr_p);
-    dwStruct.m_dwDword >>= 8;
+	dwStruct.m_dwDword = AmiGetDwordFromBe(pAddr_p);
+	dwStruct.m_dwDword >>= 8;
 
-    return ( dwStruct.m_dwDword );
+	return (dwStruct.m_dwDword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetDword24FromLe()
@@ -435,19 +405,18 @@ tdwStruct      dwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p)
+INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe(void FAR * pAddr_p)
 {
 
-tdwStruct      dwStruct;
+	tdwStruct dwStruct;
 
-    dwStruct.m_dwDword  = AmiGetDwordFromLe (pAddr_p);
-    dwStruct.m_dwDword &= 0x00FFFFFF;
+	dwStruct.m_dwDword = AmiGetDwordFromLe(pAddr_p);
+	dwStruct.m_dwDword &= 0x00FFFFFF;
 
-    return ( dwStruct.m_dwDword );
+	return (dwStruct.m_dwDword);
 
 }
 
-
 //#ifdef USE_VAR64
 
 //---------------------------------------------------------------------------
@@ -465,21 +434,21 @@ tdwStruct      dwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[7];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[6];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[5];
-    ((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[4];
-    ((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[3];
-    ((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[2];
-    ((BYTE FAR*) pAddr_p)[6] = ((BYTE FAR*) &qwQwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[7] = ((BYTE FAR*) &qwQwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[7];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[6];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[5];
+	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[4];
+	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[3];
+	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[7] = ((BYTE FAR *) & qwQwordVal_p)[0];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword64ToLe()
@@ -495,17 +464,17 @@ INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-QWORD FAR* pqwDst;
+	QWORD FAR *pqwDst;
 
-    pqwDst  = (QWORD FAR*) pAddr_p;
-    *pqwDst = qwQwordVal_p;
+	pqwDst = (QWORD FAR *) pAddr_p;
+	*pqwDst = qwQwordVal_p;
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword64FromBe()
@@ -520,25 +489,24 @@ QWORD FAR* pqwDst;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    ((BYTE FAR*) &qwStruct.m_qwQword)[0] = ((BYTE FAR*) pAddr_p)[7];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[1] = ((BYTE FAR*) pAddr_p)[6];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[2] = ((BYTE FAR*) pAddr_p)[5];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[3] = ((BYTE FAR*) pAddr_p)[4];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[4] = ((BYTE FAR*) pAddr_p)[3];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[5] = ((BYTE FAR*) pAddr_p)[2];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[6] = ((BYTE FAR*) pAddr_p)[1];
-    ((BYTE FAR*) &qwStruct.m_qwQword)[7] = ((BYTE FAR*) pAddr_p)[0];
+	((BYTE FAR *) & qwStruct.m_qwQword)[0] = ((BYTE FAR *) pAddr_p)[7];
+	((BYTE FAR *) & qwStruct.m_qwQword)[1] = ((BYTE FAR *) pAddr_p)[6];
+	((BYTE FAR *) & qwStruct.m_qwQword)[2] = ((BYTE FAR *) pAddr_p)[5];
+	((BYTE FAR *) & qwStruct.m_qwQword)[3] = ((BYTE FAR *) pAddr_p)[4];
+	((BYTE FAR *) & qwStruct.m_qwQword)[4] = ((BYTE FAR *) pAddr_p)[3];
+	((BYTE FAR *) & qwStruct.m_qwQword)[5] = ((BYTE FAR *) pAddr_p)[2];
+	((BYTE FAR *) & qwStruct.m_qwQword)[6] = ((BYTE FAR *) pAddr_p)[1];
+	((BYTE FAR *) & qwStruct.m_qwQword)[7] = ((BYTE FAR *) pAddr_p)[0];
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword64FromLe()
@@ -553,20 +521,19 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe(void FAR * pAddr_p)
 {
 
-tqwStruct FAR* pqwStruct;
-tqwStruct      qwStruct;
+	tqwStruct FAR *pqwStruct;
+	tqwStruct qwStruct;
 
-    pqwStruct = (tqwStruct FAR*) pAddr_p;
-    qwStruct.m_qwQword = pqwStruct->m_qwQword;
+	pqwStruct = (tqwStruct FAR *) pAddr_p;
+	qwStruct.m_qwQword = pqwStruct->m_qwQword;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword40ToBe()
@@ -582,18 +549,18 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[4];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[3];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[2];
-    ((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[4];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[3];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[0];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword40ToLe()
@@ -609,15 +576,15 @@ INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
-    ((BYTE  FAR*) pAddr_p)[4] = ((BYTE  FAR*) &qwQwordVal_p)[4];
+	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[4];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword40FromBe()
@@ -632,19 +599,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromBe (pAddr_p);
-    qwStruct.m_qwQword >>= 24;
+	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
+	qwStruct.m_qwQword >>= 24;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword40FromLe()
@@ -659,19 +625,18 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromLe (pAddr_p);
-    qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
+	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
+	qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword48ToBe()
@@ -687,19 +652,19 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[5];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[4];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[3];
-    ((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[2];
-    ((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[5];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[4];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[3];
+	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[0];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword48ToLe()
@@ -715,15 +680,15 @@ INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
-    ((WORD  FAR*) pAddr_p)[2] = ((WORD  FAR*) &qwQwordVal_p)[2];
+	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
+	((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword48FromBe()
@@ -738,19 +703,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromBe (pAddr_p);
-    qwStruct.m_qwQword >>= 16;
+	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
+	qwStruct.m_qwQword >>= 16;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword48FromLe()
@@ -765,19 +729,18 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromLe (pAddr_p);
-    qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
+	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
+	qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword56ToBe()
@@ -793,20 +756,20 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[6];
-    ((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[5];
-    ((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[4];
-    ((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[3];
-    ((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[2];
-    ((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[1];
-    ((BYTE FAR*) pAddr_p)[6] = ((BYTE FAR*) &qwQwordVal_p)[0];
+	((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[6];
+	((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[5];
+	((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[4];
+	((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[3];
+	((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[1];
+	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[0];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetQword56ToLe()
@@ -822,16 +785,16 @@ INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
+INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe(void FAR * pAddr_p,
+					      QWORD qwQwordVal_p)
 {
 
-    ((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
-    ((WORD  FAR*) pAddr_p)[2] = ((WORD  FAR*) &qwQwordVal_p)[2];
-    ((BYTE  FAR*) pAddr_p)[6] = ((BYTE  FAR*) &qwQwordVal_p)[6];
+	((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
+	((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
+	((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[6];
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword56FromBe()
@@ -846,19 +809,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordV
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromBe (pAddr_p);
-    qwStruct.m_qwQword >>= 8;
+	qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
+	qwStruct.m_qwQword >>= 8;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetQword56FromLe()
@@ -873,19 +835,18 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe (void FAR* pAddr_p)
+INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe(void FAR * pAddr_p)
 {
 
-tqwStruct      qwStruct;
+	tqwStruct qwStruct;
 
-    qwStruct.m_qwQword  = AmiGetQword64FromLe (pAddr_p);
-    qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
+	qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
+	qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
 
-    return ( qwStruct.m_qwQword );
+	return (qwStruct.m_qwQword);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiSetTimeOfDay()
@@ -901,15 +862,16 @@ tqwStruct      qwStruct;
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p)
+INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay(void FAR * pAddr_p,
+					    tTimeOfDay FAR * pTimeOfDay_p)
 {
 
-    AmiSetDwordToLe (((BYTE FAR*) pAddr_p),     pTimeOfDay_p->m_dwMs & 0x0FFFFFFF);
-    AmiSetWordToLe  (((BYTE FAR*) pAddr_p) + 4, pTimeOfDay_p->m_wDays);
+	AmiSetDwordToLe(((BYTE FAR *) pAddr_p),
+			pTimeOfDay_p->m_dwMs & 0x0FFFFFFF);
+	AmiSetWordToLe(((BYTE FAR *) pAddr_p) + 4, pTimeOfDay_p->m_wDays);
 
 }
 
-
 //---------------------------------------------------------------------------
 //
 // Function:    AmiGetTimeOfDay()
@@ -925,21 +887,19 @@ INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR*
 //
 //---------------------------------------------------------------------------
 
-INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p)
+INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay(void FAR * pAddr_p,
+					    tTimeOfDay FAR * pTimeOfDay_p)
 {
 
-    pTimeOfDay_p->m_dwMs  = AmiGetDwordFromLe (((BYTE FAR*) pAddr_p)) & 0x0FFFFFFF;
-    pTimeOfDay_p->m_wDays = AmiGetWordFromLe  (((BYTE FAR*) pAddr_p) + 4);
+	pTimeOfDay_p->m_dwMs =
+	    AmiGetDwordFromLe(((BYTE FAR *) pAddr_p)) & 0x0FFFFFFF;
+	pTimeOfDay_p->m_wDays = AmiGetWordFromLe(((BYTE FAR *) pAddr_p) + 4);
 
 }
 
-
 #endif
 
-
-
 // EOF
 
 // Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler
 // damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).
-

File diff suppressed because it is too large
+ 505 - 450
drivers/staging/epl/demo_main.c


+ 201 - 212
drivers/staging/epl/proc_fs.c

@@ -91,11 +91,10 @@
 #include <linux/spinlock.h>
 
 #ifdef CONFIG_COLDFIRE
-    #include <asm/coldfire.h>
-    #include "fec.h"
+#include <asm/coldfire.h>
+#include "fec.h"
 #endif
 
-
 /***************************************************************************/
 /*                                                                         */
 /*                                                                         */
@@ -113,45 +112,44 @@
 #endif
 
 #ifndef DBG_TRACE_POINTS
-#define DBG_TRACE_POINTS    23  // # of supported debug trace points
+#define DBG_TRACE_POINTS    23	// # of supported debug trace points
 #endif
 
 #ifndef DBG_TRACE_VALUES
-#define DBG_TRACE_VALUES    24 // # of supported debug trace values (size of circular buffer)
+#define DBG_TRACE_VALUES    24	// # of supported debug trace values (size of circular buffer)
 #endif
 
 //---------------------------------------------------------------------------
 // modul global types
 //---------------------------------------------------------------------------
 
-
 //---------------------------------------------------------------------------
 // local vars
 //---------------------------------------------------------------------------
 
 #ifdef _DBG_TRACE_POINTS_
-    atomic_t            aatmDbgTracePoint_l[DBG_TRACE_POINTS];
-    DWORD               adwDbgTraceValue_l[DBG_TRACE_VALUES];
-    DWORD               dwDbgTraceValueOld_l;
-    unsigned int        uiDbgTraceValuePos_l;
-    spinlock_t          spinlockDbgTraceValue_l;
-    unsigned long       ulDbTraceValueFlags_l;
+atomic_t aatmDbgTracePoint_l[DBG_TRACE_POINTS];
+DWORD adwDbgTraceValue_l[DBG_TRACE_VALUES];
+DWORD dwDbgTraceValueOld_l;
+unsigned int uiDbgTraceValuePos_l;
+spinlock_t spinlockDbgTraceValue_l;
+unsigned long ulDbTraceValueFlags_l;
 #endif
 
 //---------------------------------------------------------------------------
 // local function prototypes
 //---------------------------------------------------------------------------
 
-static  int        EplLinProcRead       (char* pcBuffer_p, char** ppcStart_p, off_t Offset_p, int nBufferSize_p, int* pEof_p, void* pData_p);
-static int EplLinProcWrite(struct file *file, const char __user *buffer, unsigned long count, void *data);
-
-void  PUBLIC  TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
-void  PUBLIC  TgtDbgPostTraceValue (DWORD dwTraceValue_p);
+static int EplLinProcRead(char *pcBuffer_p, char **ppcStart_p, off_t Offset_p,
+			  int nBufferSize_p, int *pEof_p, void *pData_p);
+static int EplLinProcWrite(struct file *file, const char __user * buffer,
+			   unsigned long count, void *data);
 
+void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
+void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
 
 EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void);
 
-
 //=========================================================================//
 //                                                                         //
 //          P U B L I C   F U N C T I O N S                                //
@@ -160,35 +158,32 @@ EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void);
 
 tEplKernel EplLinProcInit(void)
 {
-    struct proc_dir_entry*  pProcDirEntry;
-    pProcDirEntry = create_proc_entry (EPL_PROC_DEV_NAME, S_IRUGO, NULL);
-    if (pProcDirEntry != NULL)
-    {
-        pProcDirEntry->read_proc  = EplLinProcRead;
-        pProcDirEntry->write_proc = EplLinProcWrite;
-        pProcDirEntry->data       = NULL; // device number or something else
-
-    }
-    else
-    {
-        return kEplNoResource;
-    }
+	struct proc_dir_entry *pProcDirEntry;
+	pProcDirEntry = create_proc_entry(EPL_PROC_DEV_NAME, S_IRUGO, NULL);
+	if (pProcDirEntry != NULL) {
+		pProcDirEntry->read_proc = EplLinProcRead;
+		pProcDirEntry->write_proc = EplLinProcWrite;
+		pProcDirEntry->data = NULL;	// device number or something else
+
+	} else {
+		return kEplNoResource;
+	}
 
 #ifdef _DBG_TRACE_POINTS_
-    // initialize spinlock and circular buffer position
-    spin_lock_init(&spinlockDbgTraceValue_l);
-    uiDbgTraceValuePos_l = 0;
-    dwDbgTraceValueOld_l = 0;
+	// initialize spinlock and circular buffer position
+	spin_lock_init(&spinlockDbgTraceValue_l);
+	uiDbgTraceValuePos_l = 0;
+	dwDbgTraceValueOld_l = 0;
 #endif
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
 tEplKernel EplLinProcFree(void)
 {
-    remove_proc_entry (EPL_PROC_DEV_NAME, NULL);
+	remove_proc_entry(EPL_PROC_DEV_NAME, NULL);
 
-    return kEplSuccessful;
+	return kEplSuccessful;
 }
 
 //---------------------------------------------------------------------------
@@ -196,225 +191,219 @@ tEplKernel EplLinProcFree(void)
 //---------------------------------------------------------------------------
 
 #ifdef _DBG_TRACE_POINTS_
-void  PUBLIC  TgtDbgSignalTracePoint (
-    BYTE bTracePointNumber_p)
+void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p)
 {
 
-    if (bTracePointNumber_p >= (sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0])))
-    {
-        goto Exit;
-    }
+	if (bTracePointNumber_p >=
+	    (sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0]))) {
+		goto Exit;
+	}
 
+	atomic_inc(&aatmDbgTracePoint_l[bTracePointNumber_p]);
 
-    atomic_inc (&aatmDbgTracePoint_l[bTracePointNumber_p]);
+      Exit:
 
-Exit:
-
-    return;
+	return;
 
 }
 
-void  PUBLIC  TgtDbgPostTraceValue (DWORD dwTraceValue_p)
+void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p)
 {
 
-    spin_lock_irqsave(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
-    if (dwDbgTraceValueOld_l != dwTraceValue_p)
-    {
-        adwDbgTraceValue_l[uiDbgTraceValuePos_l] = dwTraceValue_p;
-        uiDbgTraceValuePos_l = (uiDbgTraceValuePos_l + 1) % DBG_TRACE_VALUES;
-        dwDbgTraceValueOld_l = dwTraceValue_p;
-    }
-    spin_unlock_irqrestore(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
+	spin_lock_irqsave(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
+	if (dwDbgTraceValueOld_l != dwTraceValue_p) {
+		adwDbgTraceValue_l[uiDbgTraceValuePos_l] = dwTraceValue_p;
+		uiDbgTraceValuePos_l =
+		    (uiDbgTraceValuePos_l + 1) % DBG_TRACE_VALUES;
+		dwDbgTraceValueOld_l = dwTraceValue_p;
+	}
+	spin_unlock_irqrestore(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
 
-    return;
+	return;
 
 }
 #endif
 
-
 //---------------------------------------------------------------------------
 //  Read function for PROC-FS read access
 //---------------------------------------------------------------------------
 
-static  int  EplLinProcRead (
-    char* pcBuffer_p,
-    char** ppcStart_p,
-    off_t Offset_p,
-    int nBufferSize_p,
-    int* pEof_p,
-    void* pData_p)
+static int EplLinProcRead(char *pcBuffer_p,
+			  char **ppcStart_p,
+			  off_t Offset_p,
+			  int nBufferSize_p, int *pEof_p, void *pData_p)
 {
 
-int             nSize;
-int             Eof;
-tEplDllkCalStatistics* pDllkCalStats;
+	int nSize;
+	int Eof;
+	tEplDllkCalStatistics *pDllkCalStats;
 
-    nSize = 0;
-    Eof   = 0;
+	nSize = 0;
+	Eof = 0;
 
-    // count calls of this function
+	// count calls of this function
 #ifdef _DBG_TRACE_POINTS_
-    TgtDbgSignalTracePoint(0);
+	TgtDbgSignalTracePoint(0);
 #endif
 
-    //---------------------------------------------------------------
-    // generate static information
-    //---------------------------------------------------------------
-
-    // ---- Driver information ----
-    nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                       "%s    %s    (c) 2006 %s\n",
-                       EPL_PRODUCT_NAME, EPL_PRODUCT_VERSION, EPL_PRODUCT_MANUFACTURER);
+	//---------------------------------------------------------------
+	// generate static information
+	//---------------------------------------------------------------
 
+	// ---- Driver information ----
+	nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+			  "%s    %s    (c) 2006 %s\n",
+			  EPL_PRODUCT_NAME, EPL_PRODUCT_VERSION,
+			  EPL_PRODUCT_MANUFACTURER);
 
-    //---------------------------------------------------------------
-    // generate process information
-    //---------------------------------------------------------------
+	//---------------------------------------------------------------
+	// generate process information
+	//---------------------------------------------------------------
 
-    // ---- EPL state ----
-    nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                       "NMT state:                  0x%04X\n",
-                       (WORD) EplNmtkGetNmtState());
+	// ---- EPL state ----
+	nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+			  "NMT state:                  0x%04X\n",
+			  (WORD) EplNmtkGetNmtState());
 
-    EplDllkCalGetStatistics(&pDllkCalStats);
+	EplDllkCalGetStatistics(&pDllkCalStats);
 
-    nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                       "CurAsyncTxGen=%lu CurAsyncTxNmt=%lu CurAsyncRx=%lu\nMaxAsyncTxGen=%lu MaxAsyncTxNmt=%lu MaxAsyncRx=%lu\n", pDllkCalStats->m_ulCurTxFrameCountGen, pDllkCalStats->m_ulCurTxFrameCountNmt, pDllkCalStats->m_ulCurRxFrameCount, pDllkCalStats->m_ulMaxTxFrameCountGen, pDllkCalStats->m_ulMaxTxFrameCountNmt, pDllkCalStats->m_ulMaxRxFrameCount);
+	nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+			  "CurAsyncTxGen=%lu CurAsyncTxNmt=%lu CurAsyncRx=%lu\nMaxAsyncTxGen=%lu MaxAsyncTxNmt=%lu MaxAsyncRx=%lu\n",
+			  pDllkCalStats->m_ulCurTxFrameCountGen,
+			  pDllkCalStats->m_ulCurTxFrameCountNmt,
+			  pDllkCalStats->m_ulCurRxFrameCount,
+			  pDllkCalStats->m_ulMaxTxFrameCountGen,
+			  pDllkCalStats->m_ulMaxTxFrameCountNmt,
+			  pDllkCalStats->m_ulMaxRxFrameCount);
 
 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
-    // fetch running IdentRequests
-    nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                       "running IdentRequests:      0x%08lX\n",
-                       EplIdentuGetRunningRequests());
+	// fetch running IdentRequests
+	nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+			  "running IdentRequests:      0x%08lX\n",
+			  EplIdentuGetRunningRequests());
+
+	// fetch state of NmtMnu module
+	{
+		unsigned int uiMandatorySlaveCount;
+		unsigned int uiSignalSlaveCount;
+		WORD wFlags;
+
+		EplNmtMnuGetDiagnosticInfo(&uiMandatorySlaveCount,
+					   &uiSignalSlaveCount, &wFlags);
+
+		nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				  "MN  MandSlaveCount: %u  SigSlaveCount: %u  Flags: 0x%X\n",
+				  uiMandatorySlaveCount, uiSignalSlaveCount,
+				  wFlags);
+
+	}
+#endif
 
-    // fetch state of NmtMnu module
-    {
-    unsigned int    uiMandatorySlaveCount;
-    unsigned int    uiSignalSlaveCount;
-    WORD            wFlags;
+	// ---- FEC state ----
+#ifdef CONFIG_COLDFIRE
+	{
+		// Receive the base address
+		unsigned long base_addr;
+#if (EDRV_USED_ETH_CTRL == 0)
+		// Set the base address of FEC0
+		base_addr = FEC_BASE_ADDR_FEC0;
+#else
+		// Set the base address of FEC1
+		base_addr = FEC_BASE_ADDR_FEC1;
+#endif
 
-        EplNmtMnuGetDiagnosticInfo(&uiMandatorySlaveCount,
-                                   &uiSignalSlaveCount,
-                                   &wFlags);
+		nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				  "FEC_ECR = 0x%08X FEC_EIR = 0x%08X FEC_EIMR = 0x%08X\nFEC_TCR = 0x%08X FECTFSR = 0x%08X FECRFSR = 0x%08X\n",
+				  FEC_ECR(base_addr), FEC_EIR(base_addr),
+				  FEC_EIMR(base_addr), FEC_TCR(base_addr),
+				  FEC_FECTFSR(base_addr),
+				  FEC_FECRFSR(base_addr));
+	}
+#endif
 
+	// ---- DBG: TracePoints ----
+#ifdef _DBG_TRACE_POINTS_
+	{
+		int nNum;
+
+		nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				  "DbgTracePoints:\n");
+		for (nNum = 0;
+		     nNum < (sizeof(aatmDbgTracePoint_l) / sizeof(atomic_t));
+		     nNum++) {
+			nSize +=
+			    snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				     " TracePoint[%2d]: %d\n", (int)nNum,
+				     atomic_read(&aatmDbgTracePoint_l[nNum]));
+		}
+
+		nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				  "DbgTraceValues:\n");
+		for (nNum = 0; nNum < DBG_TRACE_VALUES; nNum++) {
+			if (nNum == uiDbgTraceValuePos_l) {	// next value will be stored at that position
+				nSize +=
+				    snprintf(pcBuffer_p + nSize,
+					     nBufferSize_p - nSize, "*%08lX",
+					     adwDbgTraceValue_l[nNum]);
+			} else {
+				nSize +=
+				    snprintf(pcBuffer_p + nSize,
+					     nBufferSize_p - nSize, " %08lX",
+					     adwDbgTraceValue_l[nNum]);
+			}
+			if ((nNum & 0x00000007) == 0x00000007) {	// 8 values printed -> end of line reached
+				nSize +=
+				    snprintf(pcBuffer_p + nSize,
+					     nBufferSize_p - nSize, "\n");
+			}
+		}
+		if ((nNum & 0x00000007) != 0x00000007) {	// number of values printed is not a multiple of 8 -> print new line
+			nSize +=
+			    snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
+				     "\n");
+		}
+	}
+#endif
 
-        nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                           "MN  MandSlaveCount: %u  SigSlaveCount: %u  Flags: 0x%X\n",
-                           uiMandatorySlaveCount, uiSignalSlaveCount, wFlags);
+	Eof = 1;
+	goto Exit;
 
-    }
-#endif
+      Exit:
 
-    // ---- FEC state ----
-    #ifdef CONFIG_COLDFIRE
-    {
-        // Receive the base address
-        unsigned long base_addr;
-        #if (EDRV_USED_ETH_CTRL == 0)
-            // Set the base address of FEC0
-            base_addr = FEC_BASE_ADDR_FEC0;
-        #else
-            // Set the base address of FEC1
-            base_addr = FEC_BASE_ADDR_FEC1;
-        #endif
-
-        nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                           "FEC_ECR = 0x%08X FEC_EIR = 0x%08X FEC_EIMR = 0x%08X\nFEC_TCR = 0x%08X FECTFSR = 0x%08X FECRFSR = 0x%08X\n",
-                           FEC_ECR(base_addr), FEC_EIR(base_addr), FEC_EIMR(base_addr), FEC_TCR(base_addr), FEC_FECTFSR(base_addr), FEC_FECRFSR(base_addr));
-    }
-    #endif
-
-
-    // ---- DBG: TracePoints ----
-    #ifdef _DBG_TRACE_POINTS_
-    {
-        int nNum;
-
-        nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                           "DbgTracePoints:\n");
-        for (nNum=0; nNum<(sizeof(aatmDbgTracePoint_l)/sizeof(atomic_t)); nNum++)
-        {
-            nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                               " TracePoint[%2d]: %d\n", (int)nNum,
-                               atomic_read(&aatmDbgTracePoint_l[nNum]));
-        }
-
-        nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                           "DbgTraceValues:\n");
-        for (nNum=0; nNum<DBG_TRACE_VALUES; nNum++)
-        {
-            if (nNum == uiDbgTraceValuePos_l)
-            {   // next value will be stored at that position
-                nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                                   "*%08lX", adwDbgTraceValue_l[nNum]);
-            }
-            else
-            {
-                nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                                   " %08lX", adwDbgTraceValue_l[nNum]);
-            }
-            if ((nNum & 0x00000007) == 0x00000007)
-            {   // 8 values printed -> end of line reached
-                nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                                   "\n");
-            }
-        }
-        if ((nNum & 0x00000007) != 0x00000007)
-        {   // number of values printed is not a multiple of 8 -> print new line
-            nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
-                               "\n");
-        }
-    }
-    #endif
-
-
-    Eof = 1;
-    goto Exit;
-
-
-Exit:
-
-    *pEof_p = Eof;
-
-    return (nSize);
+	*pEof_p = Eof;
 
-}
+	return (nSize);
 
+}
 
 //---------------------------------------------------------------------------
 //  Write function for PROC-FS write access
 //---------------------------------------------------------------------------
 
-static int EplLinProcWrite(struct file *file, const char __user *buffer, unsigned long count, void *data)
+static int EplLinProcWrite(struct file *file, const char __user * buffer,
+			   unsigned long count, void *data)
 {
-char            abBuffer[count + 1];
-int             iErr;
-int             iVal = 0;
-tEplNmtEvent    NmtEvent;
-
-    if (count > 0)
-    {
-        iErr = copy_from_user(abBuffer, buffer, count);
-        if (iErr != 0)
-        {
-            return count;
-        }
-        abBuffer[count] = '\0';
-
-        iErr = sscanf(abBuffer, "%i", &iVal);
-    }
-    if ((iVal <= 0) || (iVal > 0x2F))
-    {
-        NmtEvent = kEplNmtEventSwReset;
-    }
-    else
-    {
-        NmtEvent = (tEplNmtEvent) iVal;
-    }
-    // execute specified NMT command on write access of /proc/epl
-    EplNmtuNmtEvent(NmtEvent);
-
-    return count;
+	char abBuffer[count + 1];
+	int iErr;
+	int iVal = 0;
+	tEplNmtEvent NmtEvent;
+
+	if (count > 0) {
+		iErr = copy_from_user(abBuffer, buffer, count);
+		if (iErr != 0) {
+			return count;
+		}
+		abBuffer[count] = '\0';
+
+		iErr = sscanf(abBuffer, "%i", &iVal);
+	}
+	if ((iVal <= 0) || (iVal > 0x2F)) {
+		NmtEvent = kEplNmtEventSwReset;
+	} else {
+		NmtEvent = (tEplNmtEvent) iVal;
+	}
+	// execute specified NMT command on write access of /proc/epl
+	EplNmtuNmtEvent(NmtEvent);
+
+	return count;
 }
-
-

Some files were not shown because too many files changed in this diff