master/module.c
author Florian Pose <fp@igh-essen.com>
Wed, 05 Nov 2008 13:20:21 +0000
branchstable-1.4
changeset 1668 9a4a5e9aa40c
parent 1648 3e46fbb7eb1d
child 1685 399ef727bf62
permissions -rw-r--r--
udev rule for writing access.
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
     6
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
     8
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    12
 *  License, or (at your option) any later version.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    13
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    17
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    18
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    24
 *  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 201
diff changeset
    31
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    32
 *****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    34
/** \file
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    35
 * EtherCAT master driver module.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    36
 */
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    37
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    38
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    39
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include <linux/module.h>
1014
d39d430cfdc4 Replaced include sysfs->device.
Florian Pose <fp@igh-essen.com>
parents: 1013
diff changeset
    41
#include <linux/device.h>
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    43
#include "globals.h"
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    44
#include "master.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    45
#include "device.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    46
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    47
/*****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    48
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    49
#define MAX_MASTERS 5 /**< Maximum number of masters. */
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    50
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    51
/*****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    52
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    53
int __init ec_init_module(void);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    54
void __exit ec_cleanup_module(void);
52
c0405659a74a Neues Interface.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
    55
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    56
static int ec_mac_parse(uint8_t *, const char *, int);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    57
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    58
/*****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    59
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    60
static char *main_devices[MAX_MASTERS]; /**< Main devices parameter. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    61
static char *backup_devices[MAX_MASTERS]; /**< Backup devices parameter. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    62
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    63
static ec_master_t *masters; /**< Array of masters. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    64
static struct semaphore master_sem; /**< Master semaphore. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    65
static unsigned int master_count; /**< Number of masters. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    66
static unsigned int backup_count; /**< Number of backup devices. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    67
954
4e7be3b24622 Removed static from device.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
    68
dev_t device_number; /**< Device number for master cdevs. */
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
    69
struct class *class; /**< Device class. */
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 919
diff changeset
    70
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    71
static uint8_t macs[MAX_MASTERS][2][ETH_ALEN]; /**< MAC addresses. */
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    72
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    73
char *ec_master_version_str = EC_MASTER_VERSION; /**< Version string. */
444
31223539fc00 Compiler flag -DSVNREV only for module.c to avoid unnecessary recompiling.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
    74
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    75
/*****************************************************************************/
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    76
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    77
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    78
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
    79
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
    80
MODULE_DESCRIPTION("EtherCAT master driver module");
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
MODULE_LICENSE("GPL");
382
72500991bcc3 Altered master version string.
Florian Pose <fp@igh-essen.com>
parents: 381
diff changeset
    82
MODULE_VERSION(EC_MASTER_VERSION);
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
    83
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    84
module_param_array(main_devices, charp, &master_count, S_IRUGO);
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    85
MODULE_PARM_DESC(main_devices, "MAC addresses of main devices");
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    86
module_param_array(backup_devices, charp, &backup_count, S_IRUGO);
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    87
MODULE_PARM_DESC(backup_devices, "MAC addresses of backup devices");
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    88
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    89
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    90
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    91
/*****************************************************************************/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    92
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    93
/** Module initialization.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
    94
 *
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 919
diff changeset
    95
 * Initializes \a master_count masters.
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    96
 * \return 0 on success, else < 0
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
    97
 */
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    98
int __init ec_init_module(void)
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
{
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   100
    int i, ret = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   101
382
72500991bcc3 Altered master version string.
Florian Pose <fp@igh-essen.com>
parents: 381
diff changeset
   102
    EC_INFO("Master driver %s\n", EC_MASTER_VERSION);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   103
653
33aa0e7e5a68 Fixed missing semaphore initialization.
Florian Pose <fp@igh-essen.com>
parents: 648
diff changeset
   104
    init_MUTEX(&master_sem);
33aa0e7e5a68 Fixed missing semaphore initialization.
Florian Pose <fp@igh-essen.com>
parents: 648
diff changeset
   105
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   106
    if (master_count) {
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   107
        if (alloc_chrdev_region(&device_number, 0, master_count, "EtherCAT")) {
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   108
            EC_ERR("Failed to obtain device number(s)!\n");
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   109
            ret = -EBUSY;
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   110
            goto out_return;
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   111
        }
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 919
diff changeset
   112
    }
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 919
diff changeset
   113
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   114
    class = class_create(THIS_MODULE, "EtherCAT");
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   115
    if (IS_ERR(class)) {
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   116
        EC_ERR("Failed to create device class.\n");
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   117
        goto out_cdev;
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   118
    }
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   119
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   120
    // zero MAC addresses
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   121
    memset(macs, 0x00, sizeof(uint8_t) * MAX_MASTERS * 2 * ETH_ALEN);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   122
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   123
    // process MAC parameters
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   124
    for (i = 0; i < master_count; i++) {
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   125
        if (ec_mac_parse(macs[i][0], main_devices[i], 0)) {
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   126
            ret = -EINVAL;
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   127
            goto out_class;
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   128
        }
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   129
        
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   130
        if (i < backup_count && ec_mac_parse(macs[i][1], backup_devices[i], 1)) {
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   131
            ret = -EINVAL;
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   132
            goto out_class;
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   133
        }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   134
    }
1648
3e46fbb7eb1d Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1189
diff changeset
   135
3e46fbb7eb1d Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1189
diff changeset
   136
    // initialize static master variables
3e46fbb7eb1d Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1189
diff changeset
   137
    ec_master_init_static();
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   138
    
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   139
    if (master_count) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   140
        if (!(masters = kmalloc(sizeof(ec_master_t) * master_count,
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   141
                        GFP_KERNEL))) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   142
            EC_ERR("Failed to allocate memory for EtherCAT masters.\n");
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   143
            ret = -ENOMEM;
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   144
            goto out_class;
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   145
        }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   146
    }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   147
    
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   148
    for (i = 0; i < master_count; i++) {
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   149
        if (ec_master_init(&masters[i], i, macs[i][0], macs[i][1],
1013
52256b75f975 Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1012
diff changeset
   150
                    device_number, class)) {
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   151
            ret = -ENOMEM;
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   152
            goto out_free_masters;
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   153
        }
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   154
    }
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   155
    
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   156
    EC_INFO("%u master%s waiting for devices.\n",
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   157
            master_count, (master_count == 1 ? "" : "s"));
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   158
    return ret;
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   159
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   160
out_free_masters:
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   161
    for (i--; i >= 0; i--)
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   162
        ec_master_clear(&masters[i]);
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   163
    kfree(masters);
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   164
out_class:
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   165
    class_destroy(class);
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 919
diff changeset
   166
out_cdev:
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   167
    if (master_count)
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   168
        unregister_chrdev_region(device_number, master_count);
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   169
out_return:
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   170
    return ret;
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   173
/*****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   175
/** Module cleanup.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   176
 *
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   177
 * Clears all master instances.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   178
 */
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   179
void __exit ec_cleanup_module(void)
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
{
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   181
    unsigned int i;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   182
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   183
    for (i = 0; i < master_count; i++) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   184
        ec_master_clear(&masters[i]);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   185
    }
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   186
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   187
    if (master_count)
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   188
        kfree(masters);
1012
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   189
    
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   190
    class_destroy(class);
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   191
    
89f87a901ce5 Create device class. Preparation for device numbers in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
   192
    if (master_count)
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   193
        unregister_chrdev_region(device_number, master_count);
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   194
    
575
9a2121b500b1 Layed out device ID functionality in own files.
Florian Pose <fp@igh-essen.com>
parents: 573
diff changeset
   195
    EC_INFO("Master module cleaned up.\n");
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   198
/*****************************************************************************
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   199
 * MAC address functions
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   200
 ****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   201
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   202
/**
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   203
 * \return true, if two MAC addresses are equal.
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   204
 */
840
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   205
int ec_mac_equal(
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   206
        const uint8_t *mac1, /**< First MAC address. */
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   207
        const uint8_t *mac2 /**< Second MAC address. */
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   208
        )
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   209
{
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   210
    unsigned int i;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   211
    
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   212
    for (i = 0; i < ETH_ALEN; i++)
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   213
        if (mac1[i] != mac2[i])
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   214
            return 0;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   215
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   216
    return 1;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   217
}
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   218
                
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   219
/*****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   220
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   221
/** Print a MAC address to a buffer.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   222
 *
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   223
 * \return number of bytes written.
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   224
 */
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   225
ssize_t ec_mac_print(
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   226
        const uint8_t *mac, /**< MAC address */
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   227
        char *buffer /**< target buffer */
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   228
        )
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   229
{
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   230
    off_t off = 0;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   231
    unsigned int i;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   232
    
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   233
    for (i = 0; i < ETH_ALEN; i++) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   234
        off += sprintf(buffer + off, "%02X", mac[i]);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   235
        if (i < ETH_ALEN - 1) off += sprintf(buffer + off, ":");
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   236
    }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   237
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   238
    return off;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   239
}
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   240
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   241
/*****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   242
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   243
/**
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   244
 * \return true, if the MAC address is all-zero.
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   245
 */
840
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   246
int ec_mac_is_zero(
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   247
        const uint8_t *mac /**< MAC address. */
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   248
        )
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   249
{
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   250
    unsigned int i;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   251
    
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   252
    for (i = 0; i < ETH_ALEN; i++)
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   253
        if (mac[i])
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   254
            return 0;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   255
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   256
    return 1;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   257
}
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   258
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   259
/*****************************************************************************/
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   260
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   261
/**
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   262
 * \return true, if the given MAC address is the broadcast address.
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   263
 */
840
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   264
int ec_mac_is_broadcast(
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   265
        const uint8_t *mac /**< MAC address. */
64beeb6ce8e3 Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   266
        )
700
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   267
{
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   268
    unsigned int i;
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   269
    
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   270
    for (i = 0; i < ETH_ALEN; i++)
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   271
        if (mac[i] != 0xff)
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   272
            return 0;
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   273
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   274
    return 1;
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   275
}
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   276
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   277
/*****************************************************************************/
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   278
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   279
/** Parse a MAC address from a string.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   280
 *
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   281
 * The MAC address must follow the regexp
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 700
diff changeset
   282
 * "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}".
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   283
 *
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   284
 * \return 0 on success, else < 0
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   285
 */
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   286
static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   287
{
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   288
    unsigned int i, value;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   289
    const char *orig = src;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   290
    char *rem;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   291
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   292
    if (!strlen(src)) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   293
        if (allow_empty){
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   294
            return 0;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   295
        }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   296
        else {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   297
            EC_ERR("MAC address may not be empty.\n");
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   298
            return -EINVAL;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   299
        }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   300
    }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   301
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   302
    for (i = 0; i < ETH_ALEN; i++) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   303
        value = simple_strtoul(src, &rem, 16);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   304
        if (rem != src + 2
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   305
                || value > 0xFF
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   306
                || (i < ETH_ALEN - 1 && *rem != ':')) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   307
            EC_ERR("Invalid MAC address \"%s\".\n", orig);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   308
            return -EINVAL;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   309
        }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   310
        mac[i] = value;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   311
        if (i < ETH_ALEN - 1)
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   312
            src = rem + 1; // skip colon
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   313
    }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   314
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   315
    return 0;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   316
}
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   317
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   318
/*****************************************************************************/
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   319
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   320
/** Outputs frame contents for debugging purposes.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   321
 */
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   322
void ec_print_data(const uint8_t *data, /**< pointer to data */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   323
                   size_t size /**< number of bytes to output */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   324
                   )
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   325
{
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   326
    unsigned int i;
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   327
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   328
    EC_DBG("");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   329
    for (i = 0; i < size; i++) {
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   330
        printk("%02X ", data[i]);
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   331
        if ((i + 1) % 16 == 0) {
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   332
            printk("\n");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   333
            EC_DBG("");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   334
        }
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   335
    }
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   336
    printk("\n");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   337
}
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   338
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   339
/*****************************************************************************/
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   340
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   341
/** Outputs frame contents and differences for debugging purposes.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   342
 */
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   343
void ec_print_data_diff(const uint8_t *d1, /**< first data */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   344
                        const uint8_t *d2, /**< second data */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   345
                        size_t size /** number of bytes to output */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   346
                        )
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   347
{
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   348
    unsigned int i;
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   349
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   350
    EC_DBG("");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   351
    for (i = 0; i < size; i++) {
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   352
        if (d1[i] == d2[i]) printk(".. ");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   353
        else printk("%02X ", d2[i]);
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   354
        if ((i + 1) % 16 == 0) {
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   355
            printk("\n");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   356
            EC_DBG("");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   357
        }
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   358
    }
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   359
    printk("\n");
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   360
}
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   361
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   362
/*****************************************************************************/
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   363
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   364
/** Prints slave states in clear text.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   365
 */
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   366
size_t ec_state_string(uint8_t states, /**< slave states */
403
7bb931deccd9 Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents: 383
diff changeset
   367
                       char *buffer /**< target buffer
7bb931deccd9 Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents: 383
diff changeset
   368
                                       (min. EC_STATE_STRING_SIZE bytes) */
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   369
                       )
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   370
{
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   371
    off_t off = 0;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   372
    unsigned int first = 1;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   373
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   374
    if (!states) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   375
        off += sprintf(buffer + off, "(unknown)");
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   376
        return off;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   377
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   378
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   379
    if (states & EC_SLAVE_STATE_INIT) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   380
        off += sprintf(buffer + off, "INIT");
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   381
        first = 0;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   382
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   383
    if (states & EC_SLAVE_STATE_PREOP) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   384
        if (!first) off += sprintf(buffer + off, ", ");
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   385
        off += sprintf(buffer + off, "PREOP");
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   386
        first = 0;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   387
    }
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 806
diff changeset
   388
    if (states & EC_SLAVE_STATE_SAFEOP) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   389
        if (!first) off += sprintf(buffer + off, ", ");
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 806
diff changeset
   390
        off += sprintf(buffer + off, "SAFEOP");
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   391
        first = 0;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   392
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   393
    if (states & EC_SLAVE_STATE_OP) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   394
        if (!first) off += sprintf(buffer + off, ", ");
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   395
        off += sprintf(buffer + off, "OP");
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   396
    }
403
7bb931deccd9 Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents: 383
diff changeset
   397
    if (states & EC_SLAVE_STATE_ACK_ERR) {
453
2ecaa53c6291 Changed output of ec_state_string() for error flag to "+ ERROR".
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   398
        if (!first) off += sprintf(buffer + off, " + ");
2ecaa53c6291 Changed output of ec_state_string() for error flag to "+ ERROR".
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   399
        off += sprintf(buffer + off, "ERROR");
403
7bb931deccd9 Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents: 383
diff changeset
   400
    }
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   401
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 321
diff changeset
   402
    return off;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   403
}
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 249
diff changeset
   404
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   405
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   406
 *  Device interface
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   407
 *****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   408
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   409
/** Offers an EtherCAT device to a certain master.
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   410
 *
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   411
 * The master decides, if it wants to use the device for EtherCAT operation,
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   412
 * or not. It is important, that the offered net_device is not used by the
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   413
 * kernel IP stack. If the master, accepted the offer, the address of the
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   414
 * newly created EtherCAT device is returned, else \a NULL is returned.
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   415
 *
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   416
 * \return Pointer to device, if accepted, or NULL if declined.
806
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   417
 * \ingroup DeviceInterface
ab8daaabbe48 Renamed master module parameters, re-formatted code documentation.
Florian Pose <fp@igh-essen.com>
parents: 794
diff changeset
   418
 */
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   419
ec_device_t *ecdev_offer(
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   420
        struct net_device *net_dev, /**< net_device to offer */
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   421
        ec_pollfunc_t poll, /**< device poll function */
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   422
        struct module *module /**< pointer to the module */
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   423
        )
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   424
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   425
    ec_master_t *master;
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   426
    char str[20];
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   427
    unsigned int i;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   428
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   429
    for (i = 0; i < master_count; i++) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   430
        master = &masters[i];
700
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   431
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   432
        down(&master->device_sem);
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   433
        if (master->main_device.dev) { // master already has a device
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   434
            up(&master->device_sem);
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   435
            continue;
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   436
        }
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   437
            
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   438
        if (ec_mac_equal(master->main_mac, net_dev->dev_addr)
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   439
                || ec_mac_is_broadcast(master->main_mac)) {
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   440
            ec_mac_print(net_dev->dev_addr, str);
578
f402b4bd2f4d Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents: 576
diff changeset
   441
            EC_INFO("Accepting device %s for master %u.\n",
f402b4bd2f4d Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents: 576
diff changeset
   442
                    str, master->index);
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   443
579
17c6fd3b076e Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents: 578
diff changeset
   444
            ec_device_attach(&master->main_device, net_dev, poll, module);
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   445
            up(&master->device_sem);
579
17c6fd3b076e Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents: 578
diff changeset
   446
            
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   447
            sprintf(net_dev->name, "ec%u", master->index);
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   448
            return &master->main_device; // offer accepted
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   449
        }
700
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   450
        else {
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   451
            up(&master->device_sem);
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   452
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   453
            if (master->debug_level) {
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   454
                ec_mac_print(net_dev->dev_addr, str);
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   455
                EC_DBG("Master %u declined device %s.\n", master->index, str);
a6b61f1a062d Broadcast MAC address accepts first device.
Florian Pose <fp@igh-essen.com>
parents: 653
diff changeset
   456
            }
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   457
        }
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   458
    }
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   459
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   460
    return NULL; // offer declined
497
04552130dd54 Re-introduced ecdev_open() and ecdev_close(), to avoid a race condition regarding the link state.
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
   461
}
04552130dd54 Re-introduced ecdev_open() and ecdev_close(), to avoid a race condition regarding the link state.
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
   462
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   463
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   464
 *  Realtime interface
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   465
 *****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   466
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   467
ec_master_t *ecrt_request_master(unsigned int master_index)
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   468
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   469
    ec_master_t *master;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   470
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   471
    EC_INFO("Requesting master %u...\n", master_index);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   472
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   473
    if (master_index >= master_count) {
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   474
        EC_ERR("Invalid master index %u.\n", master_index);
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   475
        goto out_return;
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   476
    }
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 579
diff changeset
   477
    master = &masters[master_index];
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   478
1189
acc6430bfb32 Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents: 1029
diff changeset
   479
    if (down_interruptible(&master_sem))
acc6430bfb32 Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents: 1029
diff changeset
   480
        goto out_return;
acc6430bfb32 Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents: 1029
diff changeset
   481
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   482
    if (master->reserved) {
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   483
        up(&master_sem);
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   484
        EC_ERR("Master %u is already in use!\n", master_index);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   485
        goto out_return;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   486
    }
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   487
    master->reserved = 1;
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   488
    up(&master_sem);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   489
1189
acc6430bfb32 Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents: 1029
diff changeset
   490
    if (down_interruptible(&master->device_sem))
acc6430bfb32 Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents: 1029
diff changeset
   491
        goto out_release;
648
0a6d38ec463f Made waiting for device semaphore uninterruptible.
Florian Pose <fp@igh-essen.com>
parents: 647
diff changeset
   492
    
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1014
diff changeset
   493
    if (master->phase != EC_IDLE) {
381
006d3653701d Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents: 378
diff changeset
   494
        up(&master->device_sem);
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   495
        EC_ERR("Master %u still waiting for devices!\n", master_index);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   496
        goto out_release;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   497
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   498
579
17c6fd3b076e Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents: 578
diff changeset
   499
    if (!try_module_get(master->main_device.module)) {
381
006d3653701d Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents: 378
diff changeset
   500
        up(&master->device_sem);
006d3653701d Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents: 378
diff changeset
   501
        EC_ERR("Device module is unloading!\n");
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   502
        goto out_release;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   503
    }
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   504
381
006d3653701d Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents: 378
diff changeset
   505
    up(&master->device_sem);
006d3653701d Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents: 378
diff changeset
   506
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1014
diff changeset
   507
    if (ec_master_enter_operation_phase(master)) {
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1014
diff changeset
   508
        EC_ERR("Failed to enter OPERATION phase!\n");
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 444
diff changeset
   509
        goto out_module_put;
377
ecac8252f114 Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   510
    }
ecac8252f114 Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   511
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   512
    EC_INFO("Successfully requested master %u.\n", master_index);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   513
    return master;
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   514
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   515
 out_module_put:
579
17c6fd3b076e Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents: 578
diff changeset
   516
    module_put(master->main_device.module);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   517
 out_release:
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   518
    master->reserved = 0;
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   519
 out_return:
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   520
    return NULL;
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   523
/*****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   524
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   525
void ecrt_release_master(ec_master_t *master)
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   526
{
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   527
    EC_INFO("Releasing master %u...\n", master->index);
531
8d9339e7453f Warn on duplicate master releasing.
Florian Pose <fp@igh-essen.com>
parents: 525
diff changeset
   528
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   529
    if (!master->reserved) {
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   530
        EC_WARN("Master %u was was not requested!\n", master->index);
531
8d9339e7453f Warn on duplicate master releasing.
Florian Pose <fp@igh-essen.com>
parents: 525
diff changeset
   531
        return;
8d9339e7453f Warn on duplicate master releasing.
Florian Pose <fp@igh-essen.com>
parents: 525
diff changeset
   532
    }
8d9339e7453f Warn on duplicate master releasing.
Florian Pose <fp@igh-essen.com>
parents: 525
diff changeset
   533
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1014
diff changeset
   534
    ec_master_leave_operation_phase(master);
151
1961b674466c Plugfest: master_open()/close() ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
   535
579
17c6fd3b076e Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents: 578
diff changeset
   536
    module_put(master->main_device.module);
647
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   537
    master->reserved = 0;
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   538
dc556a8c8fed Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents: 639
diff changeset
   539
    EC_INFO("Released master %u.\n", master->index);
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   540
}
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   541
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   542
/*****************************************************************************/
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   543
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   544
unsigned int ecrt_version_magic(void)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   545
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   546
    return ECRT_VERSION_MAGIC;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   547
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   548
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   549
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   550
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   551
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   552
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   553
module_init(ec_init_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   554
module_exit(ec_cleanup_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   555
573
cdee4ea90ce9 Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents: 572
diff changeset
   556
EXPORT_SYMBOL(ecdev_offer);
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 954
diff changeset
   557
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   558
EXPORT_SYMBOL(ecrt_request_master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   559
EXPORT_SYMBOL(ecrt_release_master);
545
6c4322e118d6 Added EXPORT macro for ecrt_version_magic().
Florian Pose <fp@igh-essen.com>
parents: 541
diff changeset
   560
EXPORT_SYMBOL(ecrt_version_magic);
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   561
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   562
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   563
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   564
/*****************************************************************************/