tty/module.c
author Florian Pose <fp@igh-essen.com>
Tue, 01 Dec 2009 16:54:59 +0100
changeset 1567 1babaa430b7b
parent 1565 8c526cfe1399
child 1568 d9bbbe1883ab
permissions -rw-r--r--
Added tty example.
1565
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  published by the Free Software Foundation.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  Public License for more details.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *  ---
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
/** \file
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 * EtherCAT tty driver module.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/module.h>
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/err.h>
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include "../master/globals.h"
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
int __init ec_tty_init_module(void);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
void __exit ec_tty_cleanup_module(void);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
unsigned int debug_level = 0;
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
char *ec_master_version_str = EC_MASTER_VERSION; /**< Version string. */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
/** \cond */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
MODULE_DESCRIPTION("EtherCAT TTY driver module");
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
MODULE_LICENSE("GPL");
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
MODULE_VERSION(EC_MASTER_VERSION);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
module_param_named(debug_level, debug_level, uint, S_IRUGO);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
MODULE_PARM_DESC(debug_level, "Debug level");
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
/** \endcond */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
/** Module initialization.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
 * \return 0 on success, else < 0
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
 */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
int __init ec_tty_init_module(void)
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
{
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    int ret = 0;
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
    EC_INFO("TTY driver %s\n", EC_MASTER_VERSION);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
    return ret;
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
}
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
/** Module cleanup.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
 *
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
 * Clears all master instances.
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
 */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
void __exit ec_tty_cleanup_module(void)
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
{
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    EC_INFO("TTY module cleaned up.\n");
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
}
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
/*****************************************************************************/
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
/** \cond */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
module_init(ec_tty_init_module);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
module_exit(ec_tty_cleanup_module);
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
/** \endcond */
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
8c526cfe1399 Base files for new TTY driver.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
/*****************************************************************************/