master/xmldev.c
author Florian Pose <fp@igh-essen.com>
Wed, 19 Sep 2007 09:44:48 +0000
changeset 736 53afedcb52f6
parent 489 25028ca10fdb
child 758 8fa6f825eb7d
permissions -rw-r--r--
Ignore TAGS.
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   EtherCAT XML device.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include <linux/module.h>
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "master.h"
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include "xmldev.h"
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
static char *test_str = "hello world!\n";
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
int ecxmldev_open(struct inode *, struct file *);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
int ecxmldev_release(struct inode *, struct file *);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
ssize_t ecxmldev_read(struct file *, char __user *, size_t, loff_t *);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
ssize_t ecxmldev_write(struct file *, const char __user *, size_t, loff_t *);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
489
25028ca10fdb Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents: 362
diff changeset
    57
/** \cond */
25028ca10fdb Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents: 362
diff changeset
    58
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
static struct file_operations fops = {
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
    .owner   = THIS_MODULE,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
    .open    = ecxmldev_open,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    .release = ecxmldev_release,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
    .read    = ecxmldev_read,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
    .write   = ecxmldev_write
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
};
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
489
25028ca10fdb Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents: 362
diff changeset
    67
/** \endcond */
25028ca10fdb Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents: 362
diff changeset
    68
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
/**
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
   XML device constructor.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
   \return 0 in case of success, else < 0
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
*/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
int ec_xmldev_init(ec_xmldev_t *xmldev, /**< EtherCAT XML device */
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
                   ec_master_t *master, /**< EtherCAT master */
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
                   dev_t dev_num /**< device number */
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
                   )
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
{
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
    81
    atomic_set(&xmldev->available, 1);
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
    cdev_init(&xmldev->cdev, &fops);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
    xmldev->cdev.owner = THIS_MODULE;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    if (cdev_add(&xmldev->cdev,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
		 MKDEV(MAJOR(dev_num), master->index), 1)) {
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	EC_ERR("Failed to add character device!\n");
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	return -1;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    }
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
    return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
/**
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
   XML device destructor.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
*/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
void ec_xmldev_clear(ec_xmldev_t *xmldev /**< EtherCAT XML device */)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
    cdev_del(&xmldev->cdev);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   105
int ec_xmldev_request(ec_xmldev_t *xmldev,
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   106
                      uint32_t vendor_id,
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   107
                      uint32_t product_code
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   108
                      )
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   109
{
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   110
    return 1;
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   111
}
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   112
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   113
/******************************************************************************
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   114
 * file_operations
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   115
 *****************************************************************************/
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   116
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
int ecxmldev_open(struct inode *inode, struct file *filp)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
    ec_xmldev_t *xmldev;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
    xmldev = container_of(inode->i_cdev, ec_xmldev_t, cdev);
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   122
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   123
    if (!atomic_dec_and_test(&xmldev->available)) {
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   124
        atomic_inc(&xmldev->available);
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   125
        return -EBUSY;
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   126
    }
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   127
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
    filp->private_data = xmldev;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
    EC_DBG("File opened.\n");
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
    return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
int ecxmldev_release(struct inode *inode, struct file *filp)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
{
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   139
    ec_xmldev_t *xmldev = container_of(inode->i_cdev, ec_xmldev_t, cdev);
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   140
    atomic_inc(&xmldev->available);
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
    EC_DBG("File closed.\n");
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
    return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
ssize_t ecxmldev_read(struct file *filp, char __user *buf,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
		      size_t count, loff_t *f_pos)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    size_t len = strlen(test_str);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
    if (*f_pos >= len) return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
    if (*f_pos + count > len) count = len - *f_pos;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    if (copy_to_user(buf, test_str + *f_pos, count)) return -EFAULT;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
    *f_pos += count;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
    return count;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
ssize_t ecxmldev_write(struct file *filp,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
		       const char __user *buf,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
		       size_t count,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
		       loff_t *f_pos)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
    return -EFAULT;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
/*****************************************************************************/