author | Florian Pose <fp@igh-essen.com> |
Fri, 05 Oct 2007 08:13:50 +0000 | |
changeset 766 | 97e98cbd0cd2 |
parent 758 | 8fa6f825eb7d |
permissions | -rw-r--r-- |
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 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
489
diff
changeset
|
48 |
/** \cond */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
489
diff
changeset
|
49 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
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
|
51 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
/*****************************************************************************/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
|
489
25028ca10fdb
Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents:
362
diff
changeset
|
59 |
/** \cond */ |
25028ca10fdb
Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents:
362
diff
changeset
|
60 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
static struct file_operations fops = { |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
.owner = THIS_MODULE, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
.open = ecxmldev_open, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
.release = ecxmldev_release, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
.read = ecxmldev_read, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
.write = ecxmldev_write |
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 |
|
489
25028ca10fdb
Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents:
362
diff
changeset
|
69 |
/** \endcond */ |
25028ca10fdb
Updated source code documentation.
Florian Pose <fp@igh-essen.com>
parents:
362
diff
changeset
|
70 |
|
361
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 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
/** |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
XML device constructor. |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
\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
|
76 |
*/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
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
|
79 |
ec_master_t *master, /**< EtherCAT master */ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
dev_t dev_num /**< device number */ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
) |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
{ |
362
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
83 |
atomic_set(&xmldev->available, 1); |
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
cdev_init(&xmldev->cdev, &fops); |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
xmldev->cdev.owner = THIS_MODULE; |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
if (cdev_add(&xmldev->cdev, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
return -1; |
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 |
return 0; |
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 |
|
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 |
XML device destructor. |
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 |
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
|
101 |
{ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
cdev_del(&xmldev->cdev); |
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 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
/*****************************************************************************/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
362
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
107 |
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
|
108 |
uint32_t vendor_id, |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
109 |
uint32_t product_code |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
110 |
) |
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 |
return 1; |
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 |
|
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 |
* file_operations |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
117 |
*****************************************************************************/ |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
118 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
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
|
120 |
{ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
ec_xmldev_t *xmldev; |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
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
|
124 |
|
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
125 |
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
|
126 |
atomic_inc(&xmldev->available); |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
127 |
return -EBUSY; |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
128 |
} |
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
129 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
filp->private_data = xmldev; |
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 |
EC_DBG("File opened.\n"); |
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 |
return 0; |
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 |
/*****************************************************************************/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
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
|
140 |
{ |
362
ae38aeb6fde9
Allow only one open() on XML device.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
141 |
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
|
142 |
atomic_inc(&xmldev->available); |
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
EC_DBG("File closed.\n"); |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
return 0; |
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 |
/*****************************************************************************/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
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
|
150 |
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
|
151 |
{ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
size_t len = strlen(test_str); |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
if (*f_pos >= len) return 0; |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
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
|
156 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
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
|
158 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
*f_pos += 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 |
return count; |
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 |
/*****************************************************************************/ |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
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
|
167 |
const char __user *buf, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
size_t count, |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
loff_t *f_pos) |
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 |
return -EFAULT; |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
} |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
489
diff
changeset
|
174 |
/** \endcond */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
489
diff
changeset
|
175 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
/*****************************************************************************/ |