master/xmldev.c
author Florian Pose <fp@igh-essen.com>
Fri, 27 Oct 2006 12:43:20 +0000
changeset 455 204c435fddf9
parent 362 ae38aeb6fde9
child 489 25028ca10fdb
permissions -rw-r--r--
Minor output changes in master/debug.c.
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
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
static struct file_operations fops = {
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
    .owner   = THIS_MODULE,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
    .open    = ecxmldev_open,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
    .release = ecxmldev_release,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
    .read    = ecxmldev_read,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    .write   = ecxmldev_write
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
};
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
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
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
/**
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
   XML device constructor.
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
   \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
    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
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
    73
                   ec_master_t *master, /**< EtherCAT master */
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
                   dev_t dev_num /**< device number */
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
{
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
    77
    atomic_set(&xmldev->available, 1);
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
    cdev_init(&xmldev->cdev, &fops);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
    xmldev->cdev.owner = THIS_MODULE;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    if (cdev_add(&xmldev->cdev,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
		 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
    82
	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
    83
	return -1;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    }
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
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
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
   XML device destructor.
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
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
    95
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
    cdev_del(&xmldev->cdev);
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
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
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   101
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
   102
                      uint32_t vendor_id,
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   103
                      uint32_t product_code
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   104
                      )
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   105
{
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   106
    return 1;
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   107
}
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
 * file_operations
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
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
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
   114
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
    ec_xmldev_t *xmldev;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
    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
   118
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   119
    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
   120
        atomic_inc(&xmldev->available);
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   121
        return -EBUSY;
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
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
    filp->private_data = xmldev;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
    EC_DBG("File opened.\n");
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
    return 0;
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
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
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
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
   134
{
362
ae38aeb6fde9 Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents: 361
diff changeset
   135
    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
   136
    atomic_inc(&xmldev->available);
361
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
    EC_DBG("File closed.\n");
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
    return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
/*****************************************************************************/
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
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
   144
		      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
   145
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
    size_t len = strlen(test_str);
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
    if (*f_pos >= len) return 0;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
    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
   150
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
    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
   152
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
    *f_pos += count;
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
    return count;
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
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
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
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
   161
		       const char __user *buf,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
		       size_t count,
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
		       loff_t *f_pos)
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
{
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
    return -EFAULT;
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
}
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
29af81543ce1 Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
/*****************************************************************************/